Eventually(func() ([]bosh.VM, error) {
				return helpers.DeploymentVMs(boshClient, manifest.Name)
			}, "1m", "10s").Should(ConsistOf(helpers.GetVMsFromManifest(manifest)))

			spammer = helpers.NewSpammer(kv, 1*time.Second, "test-consumer-0")
		})

		By("setting a persistent value", func() {
			err := kv.Set(testKey, testValue)
			Expect(err).NotTo(HaveOccurred())
		})

		By("deploying with the new consul-release", func() {
			for i := range manifest.Releases {
				if manifest.Releases[i].Name == "consul" {
					manifest.Releases[i].Version = helpers.ConsulReleaseVersion()
				}
			}

			yaml, err := manifest.ToYAML()
			Expect(err).NotTo(HaveOccurred())

			spammer.Spam()

			_, err = boshClient.Deploy(yaml)
			Expect(err).NotTo(HaveOccurred())

			Eventually(func() ([]bosh.VM, error) {
				return helpers.DeploymentVMs(boshClient, manifest.Name)
			}, "1m", "10s").Should(ConsistOf(helpers.GetVMsFromManifest(manifest)))
	consulReleaseVersion string
)

func TestDeploy(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "turbulence")
}

var _ = BeforeSuite(func() {
	configPath, err := helpers.ConfigPath()
	Expect(err).NotTo(HaveOccurred())

	config, err = helpers.LoadConfig(configPath)
	Expect(err).NotTo(HaveOccurred())

	consulReleaseVersion = helpers.ConsulReleaseVersion()
	boshClient = bosh.NewClient(bosh.Config{
		URL:              fmt.Sprintf("https://%s:25555", config.BOSH.Target),
		Username:         config.BOSH.Username,
		Password:         config.BOSH.Password,
		AllowInsecureSSL: true,
	})
})

func lockedDeployments() ([]string, error) {
	var lockNames []string
	locks, err := boshClient.Locks()
	if err != nil {
		return []string{}, err
	}
	for _, lock := range locks {
	})

	Describe("ConsulReleaseVersion", func() {
		var releaseVersion string

		BeforeEach(func() {
			releaseVersion = os.Getenv("CONSUL_RELEASE_VERSION")
		})

		AfterEach(func() {
			os.Setenv("CONSUL_RELEASE_VERSION", releaseVersion)
		})

		It("retrieves the consul release version number from the env", func() {
			os.Setenv("CONSUL_RELEASE_VERSION", "some-release-number")
			version := helpers.ConsulReleaseVersion()
			Expect(version).To(Equal("some-release-number"))
		})

		It("returns 'latest' if the env is not set", func() {
			os.Setenv("CONSUL_RELEASE_VERSION", "")
			version := helpers.ConsulReleaseVersion()
			Expect(version).To(Equal("latest"))
		})
	})

	Describe("ConfigPath", func() {
		var configPath string

		BeforeEach(func() {
			configPath = os.Getenv("CONSATS_CONFIG")