Example #1
0
func init() {
	Describe("Testing with Ginkgo", func() {
		var (
			action   MigrateDiskAction
			platform *fakeplatform.FakePlatform
		)

		BeforeEach(func() {
			platform, action = buildMigrateDiskAction()
		})

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

		AssertActionIsNotResumable(action)
		AssertActionIsNotCancelable(action)

		It("migrate disk action run", func() {
			value, err := action.Run()
			Expect(err).ToNot(HaveOccurred())
			boshassert.MatchesJSONString(GinkgoT(), value, "{}")

			Expect(platform.MigratePersistentDiskFromMountPoint).To(boshassert.MatchPath("/foo/store"))
			Expect(platform.MigratePersistentDiskToMountPoint).To(boshassert.MatchPath("/foo/store_migration_target"))
		})
	})
}
Example #2
0
func validatePlatformSetupWithPassword(platform *fakeplatform.FakePlatform, expectedPwd string) {
	Expect(platform.CreateUserUsername).To(Equal("fake-user"))
	Expect(platform.CreateUserPassword).To(Equal(expectedPwd))
	Expect(platform.CreateUserBasePath).To(boshassert.MatchPath("/foo/bosh_ssh"))
	Expect(platform.AddUserToGroupsGroups["fake-user"]).To(Equal(
		[]string{boshsettings.VCAPUsername, boshsettings.AdminGroup, boshsettings.SudoersGroup, boshsettings.SshersGroup},
	))
	Expect(platform.SetupSSHPublicKeys["fake-user"]).To(ConsistOf("fake-public-key"))
}
Example #3
0
						},
					}
				})

				Context("when mounting succeeds", func() {
					It("returns without an error after mounting store directory", func() {
						result, err := action.Run("fake-disk-cid")
						Expect(err).NotTo(HaveOccurred())
						Expect(result).To(Equal(map[string]string{}))

						Expect(platform.MountPersistentDiskSettings).To(Equal(boshsettings.DiskSettings{
							ID:       "fake-disk-cid",
							VolumeID: "fake-volume-id",
							Path:     "fake-device-path",
						}))
						Expect(platform.MountPersistentDiskMountPoint).To(boshassert.MatchPath("/fake-base-dir/store"))
					})
				})

				Context("when mounting fails", func() {
					It("returns error after trying to mount store directory", func() {
						platform.MountPersistentDiskErr = errors.New("fake-mount-persistent-disk-err")

						_, err := action.Run("fake-disk-cid")
						Expect(err).To(HaveOccurred())
						Expect(err.Error()).To(ContainSubstring("fake-mount-persistent-disk-err"))
					})
				})
			})

			Context("when disk cid cannot be resolved to a device path from infrastructure settings", func() {
		scriptProvider = boshscript.NewConcreteJobScriptProvider(
			runner,
			fs,
			dirProvider,
			&fakeaction.FakeClock{},
			logger,
		)
	})

	Describe("NewScript", func() {
		It("returns script with relative job paths to the base directory", func() {
			script := scriptProvider.NewScript("myjob", "the-best-hook-ever")
			Expect(script.Tag()).To(Equal("myjob"))

			expPath := "/the/base/dir/jobs/myjob/bin/the-best-hook-ever" + boshscript.ScriptExt
			Expect(script.Path()).To(boshassert.MatchPath(expPath))
		})
	})

	Describe("NewDrainScript", func() {
		It("returns drain script", func() {
			params := &fakedrain.FakeScriptParams{}
			script := scriptProvider.NewDrainScript("foo", params)
			Expect(script.Tag()).To(Equal("foo"))

			expPath := "/the/base/dir/jobs/foo/bin/drain" + boshscript.ScriptExt
			Expect(script.Path()).To(boshassert.MatchPath(expPath))
			Expect(script.(boshdrain.ConcreteScript).Params()).To(Equal(params))
		})
	})
Example #5
0
			copier.FilteredCopyToTempTempDir = "/fake-temp-dir"
			compressor.CompressFilesInDirTarballPath = "logs_test.tar"
			blobstore.CreateBlobID = "my-blob-id"

			logs, err := action.Run(logType, filters)
			Expect(err).ToNot(HaveOccurred())

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

			Expect(copier.FilteredCopyToTempDir).To(boshassert.MatchPath(expectedPath))
			Expect(copier.FilteredCopyToTempFilters).To(Equal(expectedFilters))

			Expect(copier.FilteredCopyToTempTempDir).To(Equal(compressor.CompressFilesInDirDir))
			Expect(copier.CleanUpTempDir).To(Equal(compressor.CompressFilesInDirDir))

			Expect(compressor.CompressFilesInDirTarballPath).To(Equal(blobstore.CreateFileNames[0]))

			boshassert.MatchesJSONString(GinkgoT(), logs, `{"blobstore_id":"my-blob-id"}`)
		}

		It("logs errs if given invalid log type", func() {
			_, err := action.Run("other-logs", []string{})
			Expect(err).To(HaveOccurred())
		})