func VerifyDeploymentRelease(client bosh.Client, deploymentName string, releaseVersion string) (err error) {
	deployments, err := client.Deployments()
	if err != nil {
		return
	}

	for _, deployment := range deployments {
		if deployment.Name == deploymentName {
			for _, release := range deployment.Releases {
				if release.Name == "consul" {
					switch {
					case len(release.Versions) > 1:
						err = errors.New("too many releases")
					case len(release.Versions) == 1 && release.Versions[0] != releaseVersion:
						err = fmt.Errorf("expected consul-release version %q but got %q", releaseVersion, release.Versions[0])
					}
				}
			}
		}
	}

	return
}
示例#2
0
	Expect(err).NotTo(HaveOccurred())

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

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

var _ = Describe("precheck", func() {
	It("confirms that there are no conflicting deployments", func() {
		deployments, err := client.Deployments()
		Expect(err).NotTo(HaveOccurred())

		for _, deployment := range deployments {
			for _, name := range []string{"consul", "turbulence-consul"} {
				ok, err := MatchRegexp(fmt.Sprintf("%s-\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}", name)).Match(deployment.Name)

				if err != nil {
					Fail(err.Error())
				}
				if ok {
					Fail(fmt.Sprintf("existing deployment %s", deployment.Name))
				}
			}
		}
	})