Esempio n. 1
0
	BeforeEach(func() {
		fakeScripts = make(map[string]*fakedrain.FakeScript)
		logger = boshlog.NewLogger(boshlog.LevelNone)
		notifier = fakenotif.NewFakeNotifier()
		specService = fakeas.NewFakeV1Service()
		jobScriptProvider = &fakescript.FakeJobScriptProvider{}
		jobSupervisor = fakejobsuper.NewFakeJobSupervisor()
		action = NewDrain(notifier, specService, jobScriptProvider, jobSupervisor, logger)
	})

	BeforeEach(func() {
		jobScriptProvider.NewDrainScriptStub = func(jobName string, params boshdrain.ScriptParams) boshscript.Script {
			_, exists := fakeScripts[jobName]
			if !exists {
				fakeScript := fakedrain.NewFakeScript(jobName)
				fakeScript.Params = params
				fakeScripts[jobName] = fakeScript
			}
			return fakeScripts[jobName]
		}
	})

	It("is asynchronous", func() {
		Expect(action.IsAsynchronous()).To(BeTrue())
	})

	It("is not persistent", func() {
		Expect(action.IsPersistent()).To(BeFalse())
	})
Esempio n. 2
0
	BeforeEach(func() {
		fakeScripts = make(map[string]*fakedrain.FakeScript)
		logger = boshlog.NewLogger(boshlog.LevelNone)
		notifier = fakenotif.NewFakeNotifier()
		specService = fakeas.NewFakeV1Service()
		jobScriptProvider = &fakescript.FakeJobScriptProvider{}
		jobSupervisor = fakejobsuper.NewFakeJobSupervisor()
		action = NewDrain(notifier, specService, jobScriptProvider, jobSupervisor, logger)
	})

	BeforeEach(func() {
		jobScriptProvider.NewDrainScriptStub = func(jobName string, params boshdrain.ScriptParams) boshscript.CancellableScript {
			_, exists := fakeScripts[jobName]
			if !exists {
				fakeScript := fakedrain.NewFakeScript(jobName)
				fakeScript.Params = params
				fakeScripts[jobName] = fakeScript
			}
			return fakeScripts[jobName]
		}
	})

	AssertActionIsAsynchronous(action)
	AssertActionIsNotPersistent(action)
	AssertActionIsLoggable(action)

	AssertActionIsNotResumable(action)

	Describe("Run", func() {
		var (
Esempio n. 3
0
				existingScript.ExistsReturns(true)
				scripts = append(scripts, existingScript)
			})

			It("returns error", func() {
				existingScript.RunReturns(nil)
				err := parallelScript.Cancel()
				Expect(err).To(HaveOccurred())
			})
		})

		Context("when script exists and is cancelable", func() {
			var existingScript *fakedrainscript.FakeScript

			BeforeEach(func() {
				existingScript = fakedrainscript.NewFakeScript("fake-tag")
				scripts = append(scripts, existingScript)
			})

			It("succeeds", func() {
				err := parallelScript.Cancel()
				Expect(err).ToNot(HaveOccurred())
			})
		})

		Context("when run cancelable scripts in parallel", func() {
			var existingScript1 *fakedrainscript.FakeScript
			var existingScript2 *fakedrainscript.FakeScript

			BeforeEach(func() {
				existingScript1 = fakedrainscript.NewFakeScript("fake-job1")