func deployConsul(deploymentPrefix string, count int, client bosh.Client, config Config, releaseVersion string, manifestGenerator ManifestGenerator) (manifest consul.ManifestV2, kv consulclient.HTTPKV, err error) {
	guid, err := NewGUID()
	if err != nil {
		return
	}

	info, err := client.Info()
	if err != nil {
		return
	}

	manifestConfig := consul.ConfigV2{
		DirectorUUID:   info.UUID,
		Name:           fmt.Sprintf("consul-%s-%s", deploymentPrefix, guid),
		TurbulenceHost: config.TurbulenceHost,
		WindowsClients: config.WindowsClients,
	}

	var iaasConfig iaas.Config
	switch info.CPI {
	case "aws_cpi":
		manifestConfig.PersistentDiskType = config.BOSH.Errand.DefaultPersistentDiskType
		manifestConfig.VMType = config.BOSH.Errand.DefaultVMType

		awsConfig := buildAWSConfig(config)
		if len(config.AWS.Subnets) > 0 {
			subnet := config.AWS.Subnets[0]

			var cidrBlock string
			cidrPool := NewCIDRPool(subnet.Range, 24, 27)
			cidrBlock, err = cidrPool.Get(ginkgoConfig.GinkgoConfig.ParallelNode)
			if err != nil {
				return
			}

			awsConfig.Subnets = append(awsConfig.Subnets, iaas.AWSConfigSubnet{ID: subnet.ID, Range: cidrBlock, AZ: subnet.AZ, SecurityGroup: subnet.SecurityGroup})
			manifestConfig.AZs = append(manifestConfig.AZs, consul.ConfigAZ{IPRange: cidrBlock, Nodes: count, Name: "z1"})
		} else {
			err = errors.New("AWSSubnet is required for AWS IAAS deployment")
			return
		}

		iaasConfig = awsConfig
	case "warden_cpi":
		iaasConfig = iaas.NewWardenConfig()

		var cidrBlock string
		cidrPool := NewCIDRPool("10.244.4.0", 24, 27)
		cidrBlock, err = cidrPool.Get(ginkgoConfig.GinkgoConfig.ParallelNode)
		if err != nil {
			return
		}

		manifestConfig.AZs = []consul.ConfigAZ{
			{
				IPRange: cidrBlock,
				Nodes:   count,
				Name:    "z1",
			},
		}
	default:
		err = errors.New("unknown infrastructure type")
		return
	}

	manifest, err = manifestGenerator(manifestConfig, iaasConfig)
	if err != nil {
		return
	}

	for i := range manifest.Releases {
		if manifest.Releases[i].Name == "consul" {
			manifest.Releases[i].Version = releaseVersion
		}
	}

	yaml, err := manifest.ToYAML()
	if err != nil {
		return
	}

	yaml, err = client.ResolveManifestVersions(yaml)
	if err != nil {
		return
	}

	err = consul.FromYAML(yaml, &manifest)
	if err != nil {
		return
	}

	_, err = client.Deploy(yaml)
	if err != nil {
		return
	}

	err = VerifyDeploymentRelease(client, manifestConfig.Name, releaseVersion)
	if err != nil {
		return
	}

	kv = consulclient.NewHTTPKV(fmt.Sprintf("http://%s:6769", manifest.InstanceGroups[1].Networks[0].StaticIPs[0]))
	return
}
		It("deploys successfully with minimal interruption", func() {
			if config.WindowsClients {
				Skip("bosh 1.0 style manifests do not support windows vms")
			}

			By("deploying 3 node cluster across two AZs with BOSH 1.0 manifest", func() {
				var err error
				manifest, err = helpers.DeployMultiAZConsul("migrate-instance-group", boshClient, config)
				Expect(err).NotTo(HaveOccurred())

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

				for i, ip := range manifest.Jobs[2].Networks[0].StaticIPs {
					kv = consulclient.NewHTTPKV(fmt.Sprintf("http://%s:6769", ip))
					spammers = append(spammers, helpers.NewSpammer(kv, 1*time.Second, fmt.Sprintf("test-consumer-%d", i)))
				}
			})

			By("starting spammer", func() {
				for _, spammer := range spammers {
					spammer.Spam()
				}
			})

			By("deploying 3 node cluster across two AZs with BOSH 2.0 manifest", func() {
				manifestv2, err := helpers.DeployMultiAZConsulMigration(boshClient, config, manifest.Name)
				Expect(err).NotTo(HaveOccurred())

				Eventually(func() ([]bosh.VM, error) {
		It("gets the key-value based on the key", func() {
			server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
				Expect(req.URL.Path).To(Equal("/consul/v1/kv/some-key"))

				Expect(req.Method).To(Equal("GET"))

				params, err := url.ParseQuery(req.URL.RawQuery)
				Expect(err).NotTo(HaveOccurred())

				_, ok := params["raw"]
				Expect(ok).To(BeTrue())

				w.Write([]byte("some-value"))
			}))

			kv := consulclient.NewHTTPKV(server.URL)

			value, err := kv.Get("some-key")
			Expect(err).NotTo(HaveOccurred())

			Expect(value).To(Equal("some-value"))
		})

		Context("failure cases", func() {
			Context("when consul cant find a value based on the key", func() {
				It("should return an error", func() {
					server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
						w.WriteHeader(http.StatusNotFound)
					}))

					kv := consulclient.NewHTTPKV(server.URL)