当前位置: 首页>>代码示例>>Golang>>正文


Golang FakePlatform.GetFs方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/bosh-agent/platform/fakes.FakePlatform.GetFs方法的典型用法代码示例。如果您正苦于以下问题:Golang FakePlatform.GetFs方法的具体用法?Golang FakePlatform.GetFs怎么用?Golang FakePlatform.GetFs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/bosh-agent/platform/fakes.FakePlatform的用法示例。


在下文中一共展示了FakePlatform.GetFs方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: init

func init() {
	Describe("ReleaseApplySpec", func() {
		var (
			platform *fakeplatform.FakePlatform
			action   ReleaseApplySpecAction
		)

		BeforeEach(func() {
			platform = fakeplatform.NewFakePlatform()
			action = NewReleaseApplySpec(platform)
		})

		It("is synchronous", func() {
			Expect(action.IsAsynchronous()).To(BeFalse())
		})

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

		It("run", func() {
			err := platform.GetFs().WriteFileString("/var/vcap/micro/apply_spec.json", `{"json":["objects"]}`)
			Expect(err).ToNot(HaveOccurred())

			value, err := action.Run()
			Expect(err).ToNot(HaveOccurred())

			Expect(value).To(Equal(map[string]interface{}{"json": []interface{}{"objects"}}))
		})
	})
}
开发者ID:EMC-CMD,项目名称:bosh-agent,代码行数:31,代码来源:release_apply_spec_test.go

示例2: init

func init() {
	Describe("Stop", func() {
		var (
			jobSupervisor   *fakejobsuper.FakeJobSupervisor
			platform        *fakeplatform.FakePlatform
			settingsService *fakesettings.FakeSettingsService
			logger          boshlog.Logger
			specService     *fakeas.FakeV1Service
			dualDCSupport   *nimbus.DualDCSupport
			action          StopAction
		)

		BeforeEach(func() {
			jobSupervisor = fakejobsuper.NewFakeJobSupervisor()
			platform = fakeplatform.NewFakePlatform()
			logger = boshlog.NewLogger(boshlog.LevelNone)
			specService = fakeas.NewFakeV1Service()
			settingsService = &fakesettings.FakeSettingsService{}
			dualDCSupport = nimbus.NewDualDCSupport(
				platform.GetRunner(),
				platform.GetFs(),
				platform.GetDirProvider(),
				specService,
				settingsService,
				logger,
			)
			action = NewStop(jobSupervisor, dualDCSupport, platform)
		})

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

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

		It("returns stopped", func() {
			stopped, err := action.Run()
			Expect(err).ToNot(HaveOccurred())
			Expect(stopped).To(Equal("stopped"))
		})

		It("stops job supervisor services", func() {
			_, err := action.Run()
			Expect(err).ToNot(HaveOccurred())
			Expect(jobSupervisor.Stopped).To(BeTrue())
		})
	})
}
开发者ID:nimbus-cloud,项目名称:bosh-agent,代码行数:50,代码来源:stop_test.go

示例3:

	})

	It("get_task", func() {
		action, err := factory.Create("get_task")
		Expect(err).ToNot(HaveOccurred())
		Expect(action).To(Equal(NewGetTask(taskService)))
	})

	It("cancel_task", func() {
		action, err := factory.Create("cancel_task")
		Expect(err).ToNot(HaveOccurred())
		Expect(action).To(Equal(NewCancelTask(taskService)))
	})

	It("get_state", func() {
		ntpService := boshntp.NewConcreteService(platform.GetFs(), platform.GetDirProvider())
		action, err := factory.Create("get_state")
		Expect(err).ToNot(HaveOccurred())
		Expect(action).To(Equal(NewGetState(settingsService, specService, jobSupervisor, platform.GetVitalsService(), ntpService)))
	})

	It("list_disk", func() {
		action, err := factory.Create("list_disk")
		Expect(err).ToNot(HaveOccurred())
		Expect(action).To(Equal(NewListDisk(settingsService, platform, logger)))
	})

	It("migrate_disk", func() {
		action, err := factory.Create("migrate_disk")
		Expect(err).ToNot(HaveOccurred())
		Expect(action).To(Equal(NewMigrateDisk(platform, platform.GetDirProvider())))
开发者ID:gu-bin,项目名称:bosh-agent,代码行数:31,代码来源:concrete_factory_test.go

示例4:

	})

	Describe("Get", func() {
		It("returns nats handler", func() {
			settingsService.Settings.Mbus = "nats://lol"
			handler, err := provider.Get(platform, dirProvider)
			Expect(err).ToNot(HaveOccurred())

			// yagnats.NewClient returns new object every time
			expectedHandler := NewNatsHandler(settingsService, yagnats.NewClient(), logger)
			Expect(reflect.TypeOf(handler)).To(Equal(reflect.TypeOf(expectedHandler)))
		})

		It("returns https handler", func() {
			url, err := gourl.Parse("https://lol")
			Expect(err).ToNot(HaveOccurred())

			settingsService.Settings.Mbus = "https://lol"
			handler, err := provider.Get(platform, dirProvider)
			Expect(err).ToNot(HaveOccurred())
			Expect(handler).To(Equal(micro.NewHTTPSHandler(url, logger, platform.GetFs(), dirProvider)))
		})

		It("returns an error if not supported", func() {
			settingsService.Settings.Mbus = "unknown-scheme://lol"
			_, err := provider.Get(platform, dirProvider)
			Expect(err).To(HaveOccurred())
		})
	})
})
开发者ID:nimbus-cloud,项目名称:bosh-agent,代码行数:30,代码来源:handler_provider_test.go

示例5:

		It("get external when external command in path", func() {
			options := map[string]interface{}{"key": "value"}

			platform.Runner.CommandExistsValue = true

			blobstore, err := provider.Get(boshsettings.Blobstore{
				Type:    "fake-external-type",
				Options: options,
			})
			Expect(err).ToNot(HaveOccurred())

			expectedBlobstore := NewExternalBlobstore(
				"fake-external-type",
				options,
				platform.GetFs(),
				platform.GetRunner(),
				boshuuid.NewGenerator(),
				"/var/vcap/bosh/etc/blobstore-fake-external-type.json",
			)
			expectedBlobstore = NewSHA1VerifiableBlobstore(expectedBlobstore)
			expectedBlobstore = NewRetryableBlobstore(expectedBlobstore, 3, logger)
			Expect(blobstore).To(Equal(expectedBlobstore))

			err = expectedBlobstore.Validate()
			Expect(err).ToNot(HaveOccurred())
		})

		It("get external errs when external command not in path", func() {
			options := map[string]interface{}{"key": "value"}
开发者ID:keaty,项目名称:bosh-provisioner,代码行数:29,代码来源:provider_test.go

示例6: init


//.........这里部分代码省略.........
				Expect(err).NotTo(HaveOccurred())
				Expect(0).To(Equal(len(platform.UserPasswords)))
			})

			It("sets ntp", func() {
				settingsService.Settings.Ntp = []string{
					"0.north-america.pool.ntp.org",
					"1.north-america.pool.ntp.org",
				}

				err := bootstrap()
				Expect(err).NotTo(HaveOccurred())
				Expect(2).To(Equal(len(platform.SetTimeWithNtpServersServers)))
				Expect("0.north-america.pool.ntp.org").To(Equal(platform.SetTimeWithNtpServersServers[0]))
				Expect("1.north-america.pool.ntp.org").To(Equal(platform.SetTimeWithNtpServersServers[1]))
			})

			It("setups up monit user", func() {
				err := bootstrap()
				Expect(err).NotTo(HaveOccurred())
				Expect(platform.SetupMonitUserSetup).To(BeTrue())
			})

			It("starts monit", func() {
				err := bootstrap()
				Expect(err).NotTo(HaveOccurred())
				Expect(platform.StartMonitStarted).To(BeTrue())
			})

			Describe("RemoveDevTools", func() {

				It("removes development tools if settings.env.bosh.remove_dev_tools is true", func() {
					settingsService.Settings.Env.Bosh.RemoveDevTools = true
					platform.GetFs().WriteFileString(path.Join(dirProvider.EtcDir(), "dev_tools_file_list"), "/usr/bin/gfortran")

					err := bootstrap()
					Expect(err).NotTo(HaveOccurred())
					Expect(platform.IsRemoveDevToolsCalled).To(BeTrue())
					Expect(platform.PackageFileListPath).To(Equal(path.Join(dirProvider.EtcDir(), "dev_tools_file_list")))
				})

				It("does NOTHING if settings.env.bosh.remove_dev_tools is NOT set", func() {
					err := bootstrap()
					Expect(err).NotTo(HaveOccurred())
					Expect(platform.IsRemoveDevToolsCalled).To(BeFalse())
				})

				It("does NOTHING if if settings.env.bosh.remove_dev_tools is true AND dev_tools_file_list does NOT exist", func() {
					settingsService.Settings.Env.Bosh.RemoveDevTools = true
					err := bootstrap()
					Expect(err).NotTo(HaveOccurred())
					Expect(platform.IsRemoveDevToolsCalled).To(BeFalse())
				})
			})

			Describe("Mount persistent disk", func() {
				Context("when there is more than one persistent disk", func() {
					It("returns error", func() {
						settingsService.Settings.Disks = boshsettings.Disks{
							Persistent: map[string]interface{}{
								"vol-123": "/dev/sdb",
								"vol-456": "/dev/sdc",
							},
						}

						err := bootstrap()
开发者ID:yingkitw,项目名称:bosh-agent,代码行数:67,代码来源:bootstrap_test.go

示例7: init

func init() {
	Describe("ApplyAction", func() {
		var (
			applier         *fakeappl.FakeApplier
			specService     *fakeas.FakeV1Service
			settingsService *fakesettings.FakeSettingsService
			platform        *fakeplatform.FakePlatform
			dualDCSupport   *nimbus.DualDCSupport
			logger          boshlog.Logger
			action          ApplyAction
		)

		BeforeEach(func() {
			applier = fakeappl.NewFakeApplier()
			specService = fakeas.NewFakeV1Service()
			settingsService = &fakesettings.FakeSettingsService{}
			platform = fakeplatform.NewFakePlatform()
			logger = boshlog.NewLogger(boshlog.LevelNone)
			dualDCSupport = nimbus.NewDualDCSupport(
				platform.GetRunner(),
				platform.GetFs(),
				platform.GetDirProvider(),
				specService,
				settingsService,
				logger,
			)

			action = NewApply(applier, specService, settingsService, dualDCSupport, platform)
		})

		It("apply should be asynchronous", func() {
			Expect(action.IsAsynchronous()).To(BeTrue())
		})

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

		Describe("Run", func() {
			settings := boshsettings.Settings{AgentID: "fake-agent-id"}

			BeforeEach(func() {
				settingsService.Settings = settings
			})

			Context("when desired spec has configuration hash", func() {
				currentApplySpec := boshas.V1ApplySpec{ConfigurationHash: "fake-current-config-hash"}
				desiredApplySpec := boshas.V1ApplySpec{ConfigurationHash: "fake-desired-config-hash"}
				populatedDesiredApplySpec := boshas.V1ApplySpec{
					ConfigurationHash: "fake-populated-desired-config-hash",
				}

				Context("when current spec can be retrieved", func() {
					BeforeEach(func() {
						specService.Spec = currentApplySpec
					})

					It("populates dynamic networks in desired spec", func() {
						_, err := action.Run(desiredApplySpec)
						Expect(err).ToNot(HaveOccurred())
						Expect(specService.PopulateDHCPNetworksSpec).To(Equal(desiredApplySpec))
						Expect(specService.PopulateDHCPNetworksSettings).To(Equal(settings))
					})

					Context("when resolving dynamic networks succeeds", func() {
						BeforeEach(func() {
							specService.PopulateDHCPNetworksResultSpec = populatedDesiredApplySpec
						})

						It("runs applier with populated desired spec", func() {
							_, err := action.Run(desiredApplySpec)
							Expect(err).ToNot(HaveOccurred())
							Expect(applier.Applied).To(BeTrue())
							Expect(applier.ApplyCurrentApplySpec).To(Equal(currentApplySpec))
							Expect(applier.ApplyDesiredApplySpec).To(Equal(populatedDesiredApplySpec))
						})

						Context("when applier succeeds applying desired spec", func() {
							Context("when saving desires spec as current spec succeeds", func() {
								It("returns 'applied' after setting populated desired spec as current spec", func() {
									value, err := action.Run(desiredApplySpec)
									Expect(err).ToNot(HaveOccurred())
									Expect(value).To(Equal("applied"))

									Expect(specService.Spec).To(Equal(populatedDesiredApplySpec))
								})
							})

							Context("when saving populated desires spec as current spec fails", func() {
								It("returns error because agent was not able to remember that is converged to desired spec", func() {
									specService.SetErr = errors.New("fake-set-error")

									_, err := action.Run(desiredApplySpec)
									Expect(err).To(HaveOccurred())
									Expect(err.Error()).To(ContainSubstring("fake-set-error"))
								})
							})
						})

						Context("when applier fails applying desired spec", func() {
//.........这里部分代码省略.........
开发者ID:nimbus-cloud,项目名称:bosh-agent,代码行数:101,代码来源:apply_test.go

示例8:

var _ = Describe("SyncDNS", func() {
	var (
		syncDNS             SyncDNS
		fakeBlobstore       *fakeblobstore.FakeBlobstore
		fakeSettingsService *fakesettings.FakeSettingsService
		fakePlatform        *fakeplatform.FakePlatform
		fakeFileSystem      *fakesys.FakeFileSystem
		logger              *fakelogger.FakeLogger
	)

	BeforeEach(func() {
		logger = &fakelogger.FakeLogger{}
		fakeBlobstore = fakeblobstore.NewFakeBlobstore()
		fakeSettingsService = &fakesettings.FakeSettingsService{}
		fakePlatform = fakeplatform.NewFakePlatform()
		fakeFileSystem = fakePlatform.GetFs().(*fakesys.FakeFileSystem)

		syncDNS = NewSyncDNS(fakeBlobstore, fakeSettingsService, fakePlatform, logger)
	})

	It("returns IsAsynchronous false", func() {
		async := syncDNS.IsAsynchronous()
		Expect(async).To(BeFalse())
	})

	It("returns IsPersistent false", func() {
		persistent := syncDNS.IsPersistent()
		Expect(persistent).To(BeFalse())
	})

	It("returns error 'Not supported' when resumed", func() {
开发者ID:mattcui,项目名称:bosh-init,代码行数:31,代码来源:sync_dns_test.go

示例9:

			specService,
			jobScriptProvider,
			logger,
		)
	})

	It("returns error if action cannot be created", func() {
		action, err := factory.Create("fake-unknown-action")
		Expect(err).To(HaveOccurred())
		Expect(action).To(BeNil())
	})

	It("apply", func() {
		action, err := factory.Create("apply")
		Expect(err).ToNot(HaveOccurred())
		Expect(action).To(Equal(NewApply(applier, specService, settingsService, boshdir.NewProvider("/var/vcap").InstanceDir(), platform.GetFs())))
	})

	It("drain", func() {
		action, err := factory.Create("drain")
		Expect(err).ToNot(HaveOccurred())
		// Cannot do equality check since channel is used in initializer
		Expect(action).To(BeAssignableToTypeOf(DrainAction{}))
	})

	It("fetch_logs", func() {
		action, err := factory.Create("fetch_logs")
		Expect(err).ToNot(HaveOccurred())
		Expect(action).To(Equal(NewFetchLogs(platform.GetCompressor(), platform.GetCopier(), blobstore, platform.GetDirProvider())))
	})
开发者ID:jianqiu,项目名称:bosh-agent,代码行数:30,代码来源:concrete_factory_test.go

示例10:

				options.UseRegistry = true
			})

			ItConfiguresSourcesToUseRegistry := func(useServerName bool) {
				Context("when using HTTP source", func() {
					BeforeEach(func() {
						options.Sources = []SourceOptions{
							HTTPSourceOptions{URI: "http://fake-url"},
						}
					})

					It("returns a settings source that uses HTTP to fetch settings", func() {
						resolver := NewRegistryEndpointResolver(NewDigDNSResolver(platform.GetRunner(), logger))
						httpMetadataService := NewHTTPMetadataService("http://fake-url", resolver, platform, logger)
						multiSourceMetadataService := NewMultiSourceMetadataService(httpMetadataService)
						registryProvider := NewRegistryProvider(multiSourceMetadataService, platform, useServerName, platform.GetFs(), logger)
						httpSettingsSource := NewComplexSettingsSource(multiSourceMetadataService, registryProvider, logger)

						settingsSource, err := factory.New()
						Expect(err).ToNot(HaveOccurred())
						Expect(settingsSource).To(Equal(httpSettingsSource))
					})
				})

				Context("when using ConfigDrive source", func() {
					BeforeEach(func() {
						options.Sources = []SourceOptions{
							ConfigDriveSourceOptions{
								DiskPaths: []string{"/fake-disk-path"},

								MetaDataPath: "fake-meta-data-path",
开发者ID:EMC-CMD,项目名称:bosh-agent,代码行数:31,代码来源:settings_source_factory_test.go

示例11:

	AssertActionIsLoggable(action)

	AssertActionIsNotResumable(action)
	AssertActionIsNotCancelable(action)

	Context("on success", func() {
		It("returns 'updated'", func() {
			result, err := action.Run(newUpdateSettings)
			Expect(err).ToNot(HaveOccurred())
			Expect(result).To(Equal("updated"))
		})

		It("writes the updated settings to a file", func() {
			action.Run(newUpdateSettings)
			expectedPath := filepath.Join(platform.GetDirProvider().BoshDir(), "update_settings.json")
			exists := platform.GetFs().FileExists(expectedPath)
			Expect(exists).To(Equal(true))
		})
	})

	Context("when it cannot write the update settings file", func() {
		BeforeEach(func() {
			platform.Fs.WriteFileError = errors.New("Fake write error")
		})

		It("returns an error", func() {
			_, err := action.Run(newUpdateSettings)
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("Fake write error"))
		})
	})
开发者ID:mattcui,项目名称:bosh-agent,代码行数:31,代码来源:update_settings_test.go

示例12: init

func init() {
	Describe("Start", func() {
		var (
			jobSupervisor   *fakejobsuper.FakeJobSupervisor
			applier         *fakeappl.FakeApplier
			specService     *fakeas.FakeV1Service
			platform        *fakeplatform.FakePlatform
			settingsService *fakesettings.FakeSettingsService
			logger          boshlog.Logger
			dualDCSupport   *nimbus.DualDCSupport
			action          StartAction
		)

		BeforeEach(func() {
			jobSupervisor = fakejobsuper.NewFakeJobSupervisor()
			applier = fakeappl.NewFakeApplier()
			specService = fakeas.NewFakeV1Service()
			action = NewStart(jobSupervisor, applier, specService, dualDCSupport, platform)
			platform = fakeplatform.NewFakePlatform()
			logger = boshlog.NewLogger(boshlog.LevelNone)
			settingsService = &fakesettings.FakeSettingsService{}
			dualDCSupport = nimbus.NewDualDCSupport(
				platform.GetRunner(),
				platform.GetFs(),
				platform.GetDirProvider(),
				specService,
				settingsService,
				logger,
			)
			action = NewStart(jobSupervisor, applier, specService, dualDCSupport, platform)
		})

		It("is synchronous", func() {
			Expect(action.IsAsynchronous()).To(BeFalse())
		})

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

		It("returns started", func() {
			started, err := action.Run()
			Expect(err).ToNot(HaveOccurred())
			Expect(started).To(Equal("started"))
		})

		It("starts monitor services", func() {
			_, err := action.Run()
			Expect(err).ToNot(HaveOccurred())
			Expect(jobSupervisor.Started).To(BeTrue())
		})

		It("configures jobs", func() {
			_, err := action.Run()
			Expect(err).ToNot(HaveOccurred())
			Expect(applier.Configured).To(BeTrue())
		})

		It("apply errs if a job fails configuring", func() {
			applier.ConfiguredError = errors.New("fake error")
			_, err := action.Run()

			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("Configuring jobs"))
		})
	})
}
开发者ID:nimbus-cloud,项目名称:bosh-agent,代码行数:67,代码来源:start_test.go


注:本文中的github.com/cloudfoundry/bosh-agent/platform/fakes.FakePlatform.GetFs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。