コード例 #1
0
func TestGetStateRunWithFullFormatOption(t *testing.T) {
	settings := &fakesettings.FakeSettingsService{}
	settings.AgentId = "my-agent-id"
	settings.Vm.Name = "vm-abc-def"

	specService, jobSupervisor, fakeVitals, action := buildGetStateAction(settings)
	jobSupervisor.StatusStatus = "running"

	specService.Spec = boshas.V1ApplySpec{
		Deployment: "fake-deployment",
	}

	expectedVitals := boshvitals.Vitals{
		Load: []string{"foo", "bar", "baz"},
	}
	fakeVitals.GetVitals = expectedVitals
	expectedVm := map[string]interface{}{"name": "vm-abc-def"}

	state, err := action.Run("full")
	assert.NoError(t, err)

	boshassert.MatchesJsonString(t, state.AgentId, `"my-agent-id"`)
	boshassert.MatchesJsonString(t, state.JobState, `"running"`)
	boshassert.MatchesJsonString(t, state.Deployment, `"fake-deployment"`)
	assert.Equal(t, *state.Vitals, expectedVitals)
	boshassert.MatchesJsonMap(t, state.Vm, expectedVm)
}
コード例 #2
0
ファイル: mount_disk_test.go プロジェクト: velankanisys/bosh
func init() {
	Describe("Testing with Ginkgo", func() {
		It("mount disk should be asynchronous", func() {
			settings := &fakesettings.FakeSettingsService{}
			_, action := buildMountDiskAction(settings)
			Expect(action.IsAsynchronous()).To(BeTrue())
		})

		It("is not persistent", func() {
			settings := &fakesettings.FakeSettingsService{}
			_, action := buildMountDiskAction(settings)
			Expect(action.IsPersistent()).To(BeFalse())
		})

		It("mount disk", func() {
			settings := &fakesettings.FakeSettingsService{}
			settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
			platform, mountDisk := buildMountDiskAction(settings)

			result, err := mountDisk.Run("vol-123")
			Expect(err).NotTo(HaveOccurred())
			boshassert.MatchesJsonString(GinkgoT(), result, "{}")

			Expect(settings.SettingsWereLoaded).To(BeTrue())

			Expect(platform.MountPersistentDiskDevicePath).To(Equal("/dev/sdf"))
			Expect(platform.MountPersistentDiskMountPoint).To(Equal("/foo/store"))
		})

		It("mount disk when store already mounted", func() {
			settings := &fakesettings.FakeSettingsService{}
			settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
			platform, mountDisk := buildMountDiskAction(settings)

			platform.IsMountPointResult = true

			result, err := mountDisk.Run("vol-123")
			Expect(err).NotTo(HaveOccurred())
			boshassert.MatchesJsonString(GinkgoT(), result, "{}")

			Expect(platform.IsMountPointPath).To(Equal("/foo/store"))

			Expect(platform.MountPersistentDiskDevicePath).To(Equal("/dev/sdf"))
			Expect(platform.MountPersistentDiskMountPoint).To(Equal("/foo/store_migration_target"))
		})

		It("mount disk when device path not found", func() {
			settings := &fakesettings.FakeSettingsService{}
			settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
			_, mountDisk := buildMountDiskAction(settings)

			_, err := mountDisk.Run("vol-456")
			Expect(err).To(HaveOccurred())
		})
	})
}
コード例 #3
0
ファイル: response_test.go プロジェクト: velankanisys/bosh
func init() {
	Describe("Testing with Ginkgo", func() {
		It("json with value", func() {

			resp := NewValueResponse("some value")
			boshassert.MatchesJsonString(GinkgoT(), resp, `{"value":"some value"}`)
		})
		It("json with exception", func() {

			resp := NewExceptionResponse("oops!")
			boshassert.MatchesJsonString(GinkgoT(), resp, `{"exception":{"message":"oops!"}}`)
		})
	})
}
コード例 #4
0
ファイル: mount_disk_test.go プロジェクト: nkuacac/bosh
func init() {
	Describe("Testing with Ginkgo", func() {
		It("mount disk should be asynchronous", func() {
			settings := &fakesettings.FakeSettingsService{}
			_, action := buildMountDiskAction(settings)
			assert.True(GinkgoT(), action.IsAsynchronous())
		})
		It("mount disk", func() {

			settings := &fakesettings.FakeSettingsService{}
			settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
			platform, mountDisk := buildMountDiskAction(settings)

			result, err := mountDisk.Run("vol-123")
			assert.NoError(GinkgoT(), err)
			boshassert.MatchesJsonString(GinkgoT(), result, "{}")

			assert.True(GinkgoT(), settings.SettingsWereRefreshed)

			assert.Equal(GinkgoT(), platform.MountPersistentDiskDevicePath, "/dev/sdf")
			assert.Equal(GinkgoT(), platform.MountPersistentDiskMountPoint, "/foo/store")
		})
		It("mount disk when store already mounted", func() {

			settings := &fakesettings.FakeSettingsService{}
			settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
			platform, mountDisk := buildMountDiskAction(settings)

			platform.IsMountPointResult = true

			result, err := mountDisk.Run("vol-123")
			assert.NoError(GinkgoT(), err)
			boshassert.MatchesJsonString(GinkgoT(), result, "{}")

			assert.Equal(GinkgoT(), platform.IsMountPointPath, "/foo/store")

			assert.Equal(GinkgoT(), platform.MountPersistentDiskDevicePath, "/dev/sdf")
			assert.Equal(GinkgoT(), platform.MountPersistentDiskMountPoint, "/foo/store_migration_target")
		})
		It("mount disk when device path not found", func() {

			settings := &fakesettings.FakeSettingsService{}
			settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
			_, mountDisk := buildMountDiskAction(settings)

			_, err := mountDisk.Run("vol-456")
			assert.Error(GinkgoT(), err)
		})
	})
}
コード例 #5
0
func init() {
	Describe("Testing with Ginkgo", func() {
		It("unmount disk should be asynchronous", func() {
			platform := fakeplatform.NewFakePlatform()
			action := buildUnmountDiskAction(platform)
			Expect(action.IsAsynchronous()).To(BeTrue())
		})

		It("is not persistent", func() {
			platform := fakeplatform.NewFakePlatform()
			action := buildUnmountDiskAction(platform)
			Expect(action.IsPersistent()).To(BeFalse())
		})

		It("unmount disk when the disk is mounted", func() {

			platform := fakeplatform.NewFakePlatform()
			platform.UnmountPersistentDiskDidUnmount = true

			unmountDisk := buildUnmountDiskAction(platform)

			result, err := unmountDisk.Run("vol-123")
			Expect(err).ToNot(HaveOccurred())
			boshassert.MatchesJsonString(GinkgoT(), result, `{"message":"Unmounted partition of /dev/sdf"}`)

			Expect(platform.UnmountPersistentDiskDevicePath).To(Equal("/dev/sdf"))
		})
		It("unmount disk when the disk is not mounted", func() {

			platform := fakeplatform.NewFakePlatform()
			platform.UnmountPersistentDiskDidUnmount = false

			mountDisk := buildUnmountDiskAction(platform)

			result, err := mountDisk.Run("vol-123")
			Expect(err).ToNot(HaveOccurred())
			boshassert.MatchesJsonString(GinkgoT(), result, `{"message":"Partition of /dev/sdf is not mounted"}`)

			Expect(platform.UnmountPersistentDiskDevicePath).To(Equal("/dev/sdf"))
		})
		It("unmount disk when device path not found", func() {

			platform := fakeplatform.NewFakePlatform()
			mountDisk := buildUnmountDiskAction(platform)

			_, err := mountDisk.Run("vol-456")
			Expect(err).To(HaveOccurred())
		})
	})
}
コード例 #6
0
ファイル: agent_test.go プロジェクト: joanesespanol/bosh
func assertRequestIsProcessedSynchronously(t *testing.T, req boshmbus.Request) {
	settings, handler, platform, taskService, actionFactory := getAgentDependencies()

	// when action is successful
	actionFactory.CreateAction = &fakeaction.TestAction{
		RunValue: "some value",
	}

	agent := New(settings, handler, platform, taskService, actionFactory)

	err := agent.Run()
	assert.NoError(t, err)
	assert.True(t, handler.ReceivedRun)

	resp := handler.Func(req)
	assert.Equal(t, req.Method, actionFactory.CreateMethod)
	assert.Equal(t, req.GetPayload(), actionFactory.CreateAction.RunPayload)
	assert.Equal(t, boshmbus.NewValueResponse("some value"), resp)

	// when action returns an error
	actionFactory.CreateAction = &fakeaction.TestAction{
		RunErr: errors.New("some error"),
	}

	agent = New(settings, handler, platform, taskService, actionFactory)
	agent.Run()

	resp = handler.Func(req)
	boshassert.MatchesJsonString(t, resp, `{"exception":{"message":"some error"}}`)
}
コード例 #7
0
ファイル: list_disk_test.go プロジェクト: nkuacac/bosh
func init() {
	Describe("Testing with Ginkgo", func() {
		It("list disk should be synchronous", func() {

			settings := &fakesettings.FakeSettingsService{}
			platform := fakeplatform.NewFakePlatform()
			action := NewListDisk(settings, platform)
			assert.False(GinkgoT(), action.IsAsynchronous())
		})
		It("list disk run", func() {

			settings := &fakesettings.FakeSettingsService{
				Disks: boshsettings.Disks{
					Persistent: map[string]string{
						"volume-1": "/dev/sda",
						"volume-2": "/dev/sdb",
						"volume-3": "/dev/sdc",
					},
				},
			}
			platform := fakeplatform.NewFakePlatform()
			platform.MountedDevicePaths = []string{"/dev/sdb", "/dev/sdc"}

			action := NewListDisk(settings, platform)
			value, err := action.Run()
			assert.NoError(GinkgoT(), err)
			boshassert.MatchesJsonString(GinkgoT(), value, `["volume-2","volume-3"]`)
		})
	})
}
コード例 #8
0
ファイル: logs_test.go プロジェクト: velankanisys/bosh
func testLogs(t assert.TestingT, logType string, filters []string, expectedFilters []string) {
	deps, action := buildLogsAction()

	deps.copier.FilteredCopyToTempTempDir = "/fake-temp-dir"
	deps.compressor.CompressFilesInDirTarballPath = "logs_test.go"
	deps.blobstore.CreateBlobId = "my-blob-id"

	logs, err := action.Run(logType, filters)
	assert.NoError(t, err)

	var expectedPath string
	switch logType {
	case "job":
		expectedPath = filepath.Join("/fake", "dir", "sys", "log")
	case "agent":
		expectedPath = filepath.Join("/fake", "dir", "bosh", "log")
	}

	assert.Equal(t, expectedPath, deps.copier.FilteredCopyToTempDir)
	assert.Equal(t, expectedFilters, deps.copier.FilteredCopyToTempFilters)

	assert.Equal(t, deps.copier.FilteredCopyToTempTempDir, deps.compressor.CompressFilesInDirDir)
	assert.Equal(t, deps.copier.CleanUpTempDir, deps.compressor.CompressFilesInDirDir)

	assert.Equal(t, deps.compressor.CompressFilesInDirTarballPath, deps.blobstore.CreateFileName)

	boshassert.MatchesJsonString(t, logs, `{"blobstore_id":"my-blob-id"}`)
}
コード例 #9
0
func init() {
	Describe("Testing with Ginkgo", func() {
		It("migrate disk should be asynchronous", func() {
			_, action := buildMigrateDiskAction()
			Expect(action.IsAsynchronous()).To(BeTrue())
		})

		It("is not persistent", func() {
			_, action := buildMigrateDiskAction()
			Expect(action.IsPersistent()).To(BeFalse())
		})

		It("migrate disk action run", func() {

			platform, action := buildMigrateDiskAction()

			value, err := action.Run()
			Expect(err).ToNot(HaveOccurred())
			boshassert.MatchesJsonString(GinkgoT(), value, "{}")

			Expect(platform.MigratePersistentDiskFromMountPoint).To(Equal("/foo/store"))
			Expect(platform.MigratePersistentDiskToMountPoint).To(Equal("/foo/store_migration_target"))
		})
	})
}
コード例 #10
0
func init() {
	Describe("Testing with Ginkgo", func() {
		It("get", func() {
			fs, specPath, service := buildV1Service()
			fs.WriteToFile(specPath, `{"deployment":"fake-deployment-name"}`)

			spec, err := service.Get()
			assert.NoError(GinkgoT(), err)
			expectedSpec := V1ApplySpec{
				Deployment: "fake-deployment-name",
			}
			assert.Equal(GinkgoT(), expectedSpec, spec)
		})
		It("set", func() {

			fs, specPath, service := buildV1Service()

			spec := V1ApplySpec{
				JobSpec: JobSpec{
					Name: "fake-job",
				},
			}

			err := service.Set(spec)
			assert.NoError(GinkgoT(), err)
			specPathStats := fs.GetFileTestStat(specPath)
			assert.NotNil(GinkgoT(), specPathStats)
			boshassert.MatchesJsonString(GinkgoT(), spec, specPathStats.Content)
		})
	})
}
コード例 #11
0
func TestMigrateDiskActionRun(t *testing.T) {
	platform, action := buildMigrateDiskAction()

	value, err := action.Run()
	assert.NoError(t, err)
	boshassert.MatchesJsonString(t, value, "{}")

	assert.Equal(t, platform.MigratePersistentDiskFromMountPoint, "/foo/store")
	assert.Equal(t, platform.MigratePersistentDiskToMountPoint, "/foo/store_migration_target")
}
コード例 #12
0
ファイル: unmount_disk_test.go プロジェクト: nkuacac/bosh
func init() {
	Describe("Testing with Ginkgo", func() {
		It("unmount disk should be asynchronous", func() {
			platform := fakeplatform.NewFakePlatform()
			action := buildUnmountDiskAction(platform)
			assert.True(GinkgoT(), action.IsAsynchronous())
		})
		It("unmount disk when the disk is mounted", func() {

			platform := fakeplatform.NewFakePlatform()
			platform.UnmountPersistentDiskDidUnmount = true

			unmountDisk := buildUnmountDiskAction(platform)

			result, err := unmountDisk.Run("vol-123")
			assert.NoError(GinkgoT(), err)
			boshassert.MatchesJsonString(GinkgoT(), result, `{"message":"Unmounted partition of /dev/sdf"}`)

			assert.Equal(GinkgoT(), platform.UnmountPersistentDiskDevicePath, "/dev/sdf")
		})
		It("unmount disk when the disk is not mounted", func() {

			platform := fakeplatform.NewFakePlatform()
			platform.UnmountPersistentDiskDidUnmount = false

			mountDisk := buildUnmountDiskAction(platform)

			result, err := mountDisk.Run("vol-123")
			assert.NoError(GinkgoT(), err)
			boshassert.MatchesJsonString(GinkgoT(), result, `{"message":"Partition of /dev/sdf is not mounted"}`)

			assert.Equal(GinkgoT(), platform.UnmountPersistentDiskDevicePath, "/dev/sdf")
		})
		It("unmount disk when device path not found", func() {

			platform := fakeplatform.NewFakePlatform()
			mountDisk := buildUnmountDiskAction(platform)

			_, err := mountDisk.Run("vol-456")
			assert.Error(GinkgoT(), err)
		})
	})
}
コード例 #13
0
func TestUnmountDiskWhenTheDiskIsNotMounted(t *testing.T) {
	platform := fakeplatform.NewFakePlatform()
	platform.UnmountPersistentDiskDidUnmount = false

	mountDisk := buildUnmountDiskAction(platform)

	result, err := mountDisk.Run("vol-123")
	assert.NoError(t, err)
	boshassert.MatchesJsonString(t, result, `{"message":"Partition of /dev/sdf is not mounted"}`)

	assert.Equal(t, platform.UnmountPersistentDiskDevicePath, "/dev/sdf")
}
コード例 #14
0
ファイル: unmount_disk_test.go プロジェクト: ian-plosker/bosh
func TestUnmountDiskWhenTheDiskIsMounted(t *testing.T) {
	platform := fakeplatform.NewFakePlatform()
	platform.UnmountPersistentDiskDidUnmount = true

	unmountDisk := buildUnmountDiskAction(platform)
	payload := `{"arguments":["vol-123"]}`

	result, err := unmountDisk.Run([]byte(payload))
	assert.NoError(t, err)
	boshassert.MatchesJsonString(t, result, `{"message":"Unmounted partition of /dev/sdf"}`)

	assert.Equal(t, platform.UnmountPersistentDiskDevicePath, "/dev/sdf")
}
コード例 #15
0
func TestDispatchRespondsWithExceptionWhenTheMethodIsUnknown(t *testing.T) {
	logger, taskService, actionFactory, actionRunner := getActionDispatcherDependencies()

	req := boshhandler.NewRequest("reply to me", "gibberish", []byte{})

	actionFactory.CreateErr = true

	dispatcher := NewActionDispatcher(logger, taskService, actionFactory, actionRunner)

	resp := dispatcher.Dispatch(req)

	boshassert.MatchesJsonString(t, resp, `{"exception":{"message":"unknown message gibberish"}}`)
	assert.Equal(t, actionFactory.CreateMethod, "gibberish")
}
コード例 #16
0
ファイル: agent_test.go プロジェクト: joanesespanol/bosh
func TestRunRespondsWithExceptionWhenTheMethodIsUnknown(t *testing.T) {
	req := boshmbus.NewRequest("reply to me", "gibberish", []byte{})

	settings, handler, platform, taskService, actionFactory := getAgentDependencies()
	agent := New(settings, handler, platform, taskService, actionFactory)

	err := agent.Run()
	assert.NoError(t, err)
	assert.True(t, handler.ReceivedRun)

	resp := handler.Func(req)

	boshassert.MatchesJsonString(t, resp, `{"exception":{"message":"unknown message gibberish"}}`)
}
コード例 #17
0
func TestGetTaskRunReturnsARunningTask(t *testing.T) {
	taskService, action := buildGetTaskAction()

	taskService.Tasks = map[string]boshtask.Task{
		"57": boshtask.Task{
			Id:    "found-57-id",
			State: boshtask.TaskStateRunning,
		},
	}

	taskValue, err := action.Run("57")
	assert.NoError(t, err)
	boshassert.MatchesJsonString(t, taskValue, `{"agent_task_id":"found-57-id","state":"running"}`)
}
コード例 #18
0
ファイル: apply_test.go プロジェクト: UhuruSoftware/bosh_old
func TestApplyReturnsApplied(t *testing.T) {
	_, _, action := buildApplyAction()

	applySpec := boshas.V1ApplySpec{
		JobSpec: boshas.JobSpec{
			Name: "router",
		},
	}

	value, err := action.Run(applySpec)
	assert.NoError(t, err)

	boshassert.MatchesJsonString(t, value, `"applied"`)
}
コード例 #19
0
ファイル: mount_disk_test.go プロジェクト: reneedv/bosh
func TestMountDisk(t *testing.T) {
	settings := &fakesettings.FakeSettingsService{}
	settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
	platform, mountDisk := buildMountDiskAction(settings)

	result, err := mountDisk.Run("vol-123")
	assert.NoError(t, err)
	boshassert.MatchesJsonString(t, result, "{}")

	assert.True(t, settings.SettingsWereRefreshed)

	assert.Equal(t, platform.MountPersistentDiskDevicePath, "/dev/sdf")
	assert.Equal(t, platform.MountPersistentDiskMountPoint, "/foo/store")
}
コード例 #20
0
func TestGetTaskRunReturnsASuccessfulTask(t *testing.T) {
	taskService, action := buildGetTaskAction()

	taskService.Tasks = map[string]boshtask.Task{
		"57": boshtask.Task{
			Id:    "found-57-id",
			State: boshtask.TaskStateDone,
			Value: "some-task-value",
		},
	}

	taskValue, err := action.Run("57")
	assert.NoError(t, err)
	boshassert.MatchesJsonString(t, taskValue, `"some-task-value"`)
}
コード例 #21
0
func TestDispatchHandlesSynchronousActionWhenErr(t *testing.T) {
	logger, taskService, actionFactory, actionRunner := getActionDispatcherDependencies()

	// when action returns an error
	actionFactory.CreateAction = &fakeaction.TestAction{}
	actionRunner.RunErr = errors.New("some error")

	dispatcher := NewActionDispatcher(logger, taskService, actionFactory, actionRunner)

	req := boshhandler.NewRequest("reply to me!", "some action", []byte("some payload"))
	resp := dispatcher.Dispatch(req)
	expectedJson := fmt.Sprintf("{\"exception\":{\"message\":\"Action Failed %s: some error\"}}", req.Method)
	boshassert.MatchesJsonString(t, resp, expectedJson)
	assert.Equal(t, actionFactory.CreateMethod, "some action")
}
コード例 #22
0
ファイル: drain_test.go プロジェクト: viglesiasce/bosh
func TestDrainReturnsIntegerValueOfDrainscriptStdoutAfterTrimmingWhitespace(t *testing.T) {
	cmdRunner, fs, _, specService, action := buildDrain()

	currentSpec := boshas.V1ApplySpec{}
	currentSpec.JobSpec.Template = "foo"
	specService.Spec = currentSpec

	drainScriptPath := filepath.Join("/fake-dir/jobs", currentSpec.JobSpec.Template, "bin", "drain")
	fs.WriteToFile(drainScriptPath, "")
	cmdRunner.AddCmdResult(drainScriptPath+" job_check_status hash_unchanged", fakesys.FakeCmdResult{Stdout: "-56\n"})

	value, err := action.Run(drainTypeStatus)
	assert.NoError(t, err)
	boshassert.MatchesJsonString(t, value, "-56")
}
コード例 #23
0
func TestSet(t *testing.T) {
	fs, specPath, service := buildV1Service()

	spec := V1ApplySpec{
		JobSpec: JobSpec{
			Name: "fake-job",
		},
	}

	err := service.Set(spec)
	assert.NoError(t, err)
	specPathStats := fs.GetFileTestStat(specPath)
	assert.NotNil(t, specPathStats)
	boshassert.MatchesJsonString(t, spec, specPathStats.Content)
}
コード例 #24
0
ファイル: mount_disk_test.go プロジェクト: reneedv/bosh
func TestMountDiskWhenStoreAlreadyMounted(t *testing.T) {
	settings := &fakesettings.FakeSettingsService{}
	settings.Disks.Persistent = map[string]string{"vol-123": "/dev/sdf"}
	platform, mountDisk := buildMountDiskAction(settings)

	platform.IsMountPointResult = true

	result, err := mountDisk.Run("vol-123")
	assert.NoError(t, err)
	boshassert.MatchesJsonString(t, result, "{}")

	assert.Equal(t, platform.IsMountPointPath, "/foo/store")

	assert.Equal(t, platform.MountPersistentDiskDevicePath, "/dev/sdf")
	assert.Equal(t, platform.MountPersistentDiskMountPoint, "/foo/store_migration_target")
}
コード例 #25
0
func TestGetTaskRunReturnsAFailedTask(t *testing.T) {
	taskService, action := buildGetTaskAction()

	taskService.Tasks = map[string]boshtask.Task{
		"57": boshtask.Task{
			Id:    "found-57-id",
			State: boshtask.TaskStateFailed,
			Error: errors.New("Oops we failed..."),
		},
	}

	taskValue, err := action.Run("57")
	assert.Error(t, err)
	assert.Equal(t, "Oops we failed...", err.Error())
	boshassert.MatchesJsonString(t, taskValue, `null`)
}
コード例 #26
0
func TestExternalValidateWritesConfigFile(t *testing.T) {
	fs, runner, uuidGen, configPath := getExternalBlobstoreDependencies()

	options := map[string]string{"fake-key": "fake-value"}

	blobstore := newExternalBlobstore("fake-provider", options, fs, runner, uuidGen, configPath)

	runner.CommandExistsValue = true
	assert.NoError(t, blobstore.Validate())

	s3CliConfig, err := fs.ReadFile(configPath)
	assert.NoError(t, err)

	expectedJson := map[string]string{"fake-key": "fake-value"}
	boshassert.MatchesJsonString(t, expectedJson, s3CliConfig)
}
コード例 #27
0
ファイル: get_task_test.go プロジェクト: ian-plosker/bosh
func TestGetTaskRunReturnsAFailedTask(t *testing.T) {
	taskService, action := buildGetTaskAction()

	taskService.Tasks = map[string]boshtask.Task{
		"57": boshtask.Task{
			Id:    "found-57-id",
			State: boshtask.TaskStateFailed,
			Error: "Oops we failed...",
		},
	}

	taskValue, err := action.Run([]byte(`{"arguments":["57"]}`))
	assert.NoError(t, err)
	boshassert.MatchesJsonString(t, taskValue,
		`{"agent_task_id":"found-57-id","state":"failed","exception":"Oops we failed..."}`)
}
コード例 #28
0
ファイル: get_task_test.go プロジェクト: ian-plosker/bosh
func TestGetTaskRunReturnsASuccessfulTask(t *testing.T) {
	taskService, action := buildGetTaskAction()

	taskService.Tasks = map[string]boshtask.Task{
		"57": boshtask.Task{
			Id:    "found-57-id",
			State: boshtask.TaskStateDone,
			Value: "some-task-value",
		},
	}

	taskValue, err := action.Run([]byte(`{"arguments":["57"]}`))
	assert.NoError(t, err)
	boshassert.MatchesJsonString(t, taskValue,
		`{"agent_task_id":"found-57-id","state":"done","value":"some-task-value"}`)
}
コード例 #29
0
ファイル: get_task_test.go プロジェクト: joshuamckenty/bosh
func TestGetTaskRunReturns(t *testing.T) {
	settings, fs, platform, taskService := getFakeFactoryDependencies()
	taskService.Tasks = map[string]boshtask.Task{
		"57": boshtask.Task{
			Id:    "found-57-id",
			State: boshtask.TaskStateFailed,
		},
	}

	factory := NewFactory(settings, fs, platform, taskService)
	getTask := factory.Create("get_task")

	taskValue, err := getTask.Run([]byte(`{"arguments":["57"]}`))
	assert.NoError(t, err)

	boshassert.MatchesJsonString(t, taskValue, `{"agent_task_id":"found-57-id","state":"failed"}`)
}
コード例 #30
0
ファイル: get_task_test.go プロジェクト: nicregez/bosh
func TestGetTaskRunReturnsASuccessfulTask(t *testing.T) {
	settings, platform, blobstore, taskService := getFakeFactoryDependencies()
	taskService.Tasks = map[string]boshtask.Task{
		"57": boshtask.Task{
			Id:    "found-57-id",
			State: boshtask.TaskStateDone,
			Value: "some-task-value",
		},
	}

	factory := NewFactory(settings, platform, blobstore, taskService)
	getTask := factory.Create("get_task")

	taskValue, err := getTask.Run([]byte(`{"arguments":["57"]}`))
	assert.NoError(t, err)

	boshassert.MatchesJsonString(t, taskValue, `{"agent_task_id":"found-57-id","state":"done","value":"some-task-value"}`)
}