本文整理匯總了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",
})
})
})
}
示例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"))
})
})
}
示例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)
}
示例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"))
}
示例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"]`)
})
})
}
示例6: TestStartRunReturnsStarted
func TestStartRunReturnsStarted(t *testing.T) {
_, action := buildStartAction()
started, err := action.Run()
assert.NoError(t, err)
assert.Equal(t, "started", started)
}
示例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"}`)
}
示例8: TestStartRunStartsMonitorServices
func TestStartRunStartsMonitorServices(t *testing.T) {
jobSupervisor, action := buildStartAction()
_, err := action.Run()
assert.NoError(t, err)
assert.True(t, jobSupervisor.Started)
}
示例9: TestStopRunStopsJobSupervisorServices
func TestStopRunStopsJobSupervisorServices(t *testing.T) {
jobSupervisor, action := buildStopAction()
_, err := action.Run()
assert.NoError(t, err)
assert.True(t, jobSupervisor.Stopped)
}
示例10: TestDrainRunStatusErrsWhenWithoutDrainScript
func TestDrainRunStatusErrsWhenWithoutDrainScript(t *testing.T) {
_, fakeDrainProvider, action := buildDrain()
fakeDrainProvider.NewDrainScriptDrainScript.ExistsBool = false
_, err := action.Run(DrainTypeStatus)
assert.Error(t, err)
}
示例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())
}
示例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")
}
示例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)
}
示例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")
}
示例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"))
}