當前位置: 首頁>>代碼示例>>Golang>>正文


Golang action.Run函數代碼示例

本文整理匯總了Golang中bosh/agent/action.Run函數的典型用法代碼示例。如果您正苦於以下問題:Golang Run函數的具體用法?Golang Run怎麽用?Golang Run使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Run函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: init

func init() {
	Describe("Testing with Ginkgo", func() {
		It("ssh should be synchronous", func() {
			settings := &fakesettings.FakeSettingsService{}
			_, action := buildSshAction(settings)
			Expect(action.IsAsynchronous()).To(BeFalse())
		})

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

		It("ssh setup without default ip", func() {

			settings := &fakesettings.FakeSettingsService{}
			_, action := buildSshAction(settings)

			params := SshParams{
				User:      "some-user",
				Password:  "some-pwd",
				PublicKey: "some-key",
			}
			_, err := action.Run("setup", params)
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("No default ip"))
		})
		It("ssh setup with username and password", func() {

			testSshSetupWithGivenPassword(GinkgoT(), "some-password")
		})
		It("ssh setup without password", func() {

			testSshSetupWithGivenPassword(GinkgoT(), "")
		})
		It("ssh run cleanup deletes ephemeral user", func() {

			settings := &fakesettings.FakeSettingsService{}
			platform, action := buildSshAction(settings)

			params := SshParams{UserRegex: "^foobar.*"}
			response, err := action.Run("cleanup", params)
			Expect(err).ToNot(HaveOccurred())
			Expect("^foobar.*").To(Equal(platform.DeleteEphemeralUsersMatchingRegex))

			boshassert.MatchesJsonMap(GinkgoT(), response, map[string]interface{}{
				"command": "cleanup",
				"status":  "success",
			})
		})
	})
}
開發者ID:velankanisys,項目名稱:bosh,代碼行數:53,代碼來源:ssh_test.go

示例2: init

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"))
		})
	})
}
開發者ID:Bosh-for-Cpi,項目名稱:bosh-2605,代碼行數:25,代碼來源:migrate_disk_test.go

示例3: testSshSetupWithGivenPassword

func testSshSetupWithGivenPassword(t assert.TestingT, expectedPwd string) {
	settings := &fakesettings.FakeSettingsService{}
	settings.DefaultIp = "ww.xx.yy.zz"

	platform, action := buildSshAction(settings)

	expectedUser := "some-user"
	expectedKey := "some public key content"

	params := SshParams{
		User:      expectedUser,
		PublicKey: expectedKey,
		Password:  expectedPwd,
	}

	response, err := action.Run("setup", params)
	assert.NoError(t, err)

	assert.Equal(t, expectedUser, platform.CreateUserUsername)
	assert.Equal(t, expectedPwd, platform.CreateUserPassword)
	assert.Equal(t, "/foo/bosh_ssh", platform.CreateUserBasePath)
	assert.Equal(t, []string{boshsettings.VCAP_USERNAME, boshsettings.ADMIN_GROUP}, platform.AddUserToGroupsGroups[expectedUser])
	assert.Equal(t, expectedKey, platform.SetupSshPublicKeys[expectedUser])

	expectedJson := map[string]interface{}{
		"command": "setup",
		"status":  "success",
		"ip":      "ww.xx.yy.zz",
	}

	boshassert.MatchesJsonMap(t, response, expectedJson)
}
開發者ID:velankanisys,項目名稱:bosh,代碼行數:32,代碼來源:ssh_test.go

示例4: testSSHSetupWithGivenPassword

func testSSHSetupWithGivenPassword(expectedPwd string) {
	settingsService := &fakesettings.FakeSettingsService{}
	settingsService.Settings.Networks = boshsettings.Networks{
		"fake-net": boshsettings.Network{IP: "ww.xx.yy.zz"},
	}

	platform, action := buildSSHAction(settingsService)

	params := SSHParams{
		User:      "fake-user",
		PublicKey: "fake-public-key",
		Password:  expectedPwd,
	}

	response, err := action.Run("setup", params)
	Expect(err).ToNot(HaveOccurred())
	Expect(response).To(Equal(SSHResult{
		Command: "setup",
		Status:  "success",
		IP:      "ww.xx.yy.zz",
	}))

	Expect(platform.CreateUserUsername).To(Equal("fake-user"))
	Expect(platform.CreateUserPassword).To(Equal(expectedPwd))
	Expect(platform.CreateUserBasePath).To(Equal("/foo/bosh_ssh"))

	Expect(platform.AddUserToGroupsGroups["fake-user"]).To(Equal(
		[]string{boshsettings.VCAPUsername, boshsettings.AdminGroup},
	))

	Expect(platform.SetupSSHPublicKeys["fake-user"]).To(Equal("fake-public-key"))
}
開發者ID:amulyas,項目名稱:bosh-cloudstack-cpi,代碼行數:32,代碼來源:ssh_test.go

示例5: init

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"]`)
		})
	})
}
開發者ID:nkuacac,項目名稱:bosh,代碼行數:30,代碼來源:list_disk_test.go

示例6: TestStartRunReturnsStarted

func TestStartRunReturnsStarted(t *testing.T) {
	_, action := buildStartAction()

	started, err := action.Run()
	assert.NoError(t, err)
	assert.Equal(t, "started", started)
}
開發者ID:reneedv,項目名稱:bosh,代碼行數:7,代碼來源:start_test.go

示例7: testLogs

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"}`)
}
開發者ID:velankanisys,項目名稱:bosh,代碼行數:28,代碼來源:logs_test.go

示例8: TestStartRunStartsMonitorServices

func TestStartRunStartsMonitorServices(t *testing.T) {
	jobSupervisor, action := buildStartAction()

	_, err := action.Run()
	assert.NoError(t, err)
	assert.True(t, jobSupervisor.Started)
}
開發者ID:reneedv,項目名稱:bosh,代碼行數:7,代碼來源:start_test.go

示例9: TestStopRunStopsJobSupervisorServices

func TestStopRunStopsJobSupervisorServices(t *testing.T) {
	jobSupervisor, action := buildStopAction()

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

	assert.True(t, jobSupervisor.Stopped)
}
開發者ID:reneedv,項目名稱:bosh,代碼行數:8,代碼來源:stop_test.go

示例10: TestDrainRunStatusErrsWhenWithoutDrainScript

func TestDrainRunStatusErrsWhenWithoutDrainScript(t *testing.T) {
	_, fakeDrainProvider, action := buildDrain()

	fakeDrainProvider.NewDrainScriptDrainScript.ExistsBool = false

	_, err := action.Run(DrainTypeStatus)
	assert.Error(t, err)
}
開發者ID:reneedv,項目名稱:bosh,代碼行數:8,代碼來源:drain_test.go

示例11: TestGetTaskRunWhenTaskIsNotFound

func TestGetTaskRunWhenTaskIsNotFound(t *testing.T) {
	taskService, action := buildGetTaskAction()

	taskService.Tasks = map[string]boshtask.Task{}

	_, err := action.Run("57")
	assert.Error(t, err)
	assert.Equal(t, "Task with id 57 could not be found", err.Error())
}
開發者ID:reneedv,項目名稱:bosh,代碼行數:9,代碼來源:get_task_test.go

示例12: TestApplyRunErrsWhenApplierFails

func TestApplyRunErrsWhenApplierFails(t *testing.T) {
	applier, _, action := buildApplyAction()

	applier.ApplyError = errors.New("fake-apply-error")

	_, err := action.Run(boshas.V1ApplySpec{ConfigurationHash: "fake-config-hash"})
	assert.Error(t, err)
	assert.Contains(t, err.Error(), "fake-apply-error")
}
開發者ID:reneedv,項目名稱:bosh,代碼行數:9,代碼來源:apply_test.go

示例13: TestDrainErrsWhenDrainScriptExitsWithError

func TestDrainErrsWhenDrainScriptExitsWithError(t *testing.T) {
	_, fakeDrainScriptProvider, action := buildDrain()

	fakeDrainScriptProvider.NewDrainScriptDrainScript.RunExitStatus = 0
	fakeDrainScriptProvider.NewDrainScriptDrainScript.RunError = errors.New("Fake error")

	value, err := action.Run(DrainTypeStatus)
	assert.Equal(t, value, 0)
	assert.Error(t, err)
}
開發者ID:reneedv,項目名稱:bosh,代碼行數:10,代碼來源:drain_test.go

示例14: TestMigrateDiskActionRun

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")
}
開發者ID:reneedv,項目名稱:bosh,代碼行數:10,代碼來源:migrate_disk_test.go

示例15: TestPrepareNetworkChange

func TestPrepareNetworkChange(t *testing.T) {
	action, fs := buildPrepareAction()
	fs.WriteToFile("/etc/udev/rules.d/70-persistent-net.rules", "")

	resp, err := action.Run()

	assert.NoError(t, err)
	assert.Equal(t, "ok", resp)
	assert.False(t, fs.FileExists("/etc/udev/rules.d/70-persistent-net.rules"))
}
開發者ID:reneedv,項目名稱:bosh,代碼行數:10,代碼來源:prepare_network_change_test.go


注:本文中的bosh/agent/action.Run函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。