Skip to content

Commit

Permalink
Backport of Fix default Ent image tag in acceptance tests into releas…
Browse files Browse the repository at this point in the history
…e/1.0.x (#2699)

backport of commit da99ce4

Co-authored-by: Michael Zalimeni <michael.zalimeni@hashicorp.com>
  • Loading branch information
hc-github-team-consul-core and zalimeni authored Jul 31, 2023
1 parent cf4fdc2 commit 6b165cc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ kind:
kind create cluster --name dc2 --image $(KIND_NODE_IMAGE)


# Helper target for loading local dev images (run with `DEV_IMAGE=...` to load non-k8s images)
kind-load:
kind load docker-image --name dc1 $(DEV_IMAGE)
kind load docker-image --name dc2 $(DEV_IMAGE)
kind load docker-image --name dc3 $(DEV_IMAGE)
kind load docker-image --name dc4 $(DEV_IMAGE)

# ===========> Shared Targets

help: ## Show targets and their descriptions.
Expand Down
21 changes: 8 additions & 13 deletions acceptance/framework/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,16 @@ func (t *TestConfig) entImage() (string, error) {
}

// Otherwise, assume that we have an image tag with a version in it.
consulImageSplits := strings.Split(v.Global.Image, ":")
if len(consulImageSplits) != 2 {
return "", fmt.Errorf("could not determine consul version from global.image: %s", v.Global.Image)
}
consulImageVersion := consulImageSplits[1]

var preRelease string
// Handle versions like 1.9.0-rc1.
if strings.Contains(consulImageVersion, "-") {
split := strings.Split(consulImageVersion, "-")
consulImageVersion = split[0]
preRelease = fmt.Sprintf("-%s", split[1])
// Use the same Docker repository and tagging scheme, but replace 'consul' with 'consul-enterprise'.
imageTag := strings.Replace(v.Global.Image, "/consul:", "/consul-enterprise:", 1)

// We currently add an '-ent' suffix to release versions of enterprise images (nightly previews
// do not include this suffix).
if strings.HasPrefix(imageTag, "hashicorp/consul-enterprise:") {
imageTag = fmt.Sprintf("%s-ent", imageTag)
}

return fmt.Sprintf("hashicorp/consul-enterprise:%s%s-ent", consulImageVersion, preRelease), nil
return imageTag, nil
}

func (c *TestConfig) SkipWhenOpenshiftAndCNI(t *testing.T) {
Expand Down
29 changes: 19 additions & 10 deletions acceptance/framework/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,34 @@ func TestConfig_HelmValuesFromConfig_EntImage(t *testing.T) {
expErr string
}{
{
consulImage: "hashicorp/consul:1.9.0",
expImage: "hashicorp/consul-enterprise:1.9.0-ent",
consulImage: "hashicorp/consul:1.15.3",
expImage: "hashicorp/consul-enterprise:1.15.3-ent",
},
{
consulImage: "hashicorp/consul:1.8.5-rc1",
expImage: "hashicorp/consul-enterprise:1.8.5-rc1-ent",
consulImage: "hashicorp/consul:1.16.0-rc1",
expImage: "hashicorp/consul-enterprise:1.16.0-rc1-ent",
},
{
consulImage: "hashicorp/consul:1.7.0-beta3",
expImage: "hashicorp/consul-enterprise:1.7.0-beta3-ent",
},
{
consulImage: "invalid",
expErr: "could not determine consul version from global.image: invalid",
consulImage: "hashicorp/consul:1.14.0-beta1",
expImage: "hashicorp/consul-enterprise:1.14.0-beta1-ent",
},
{
consulImage: "hashicorp/consul@sha256:oioi2452345kjhlkh",
expImage: "hashicorp/consul@sha256:oioi2452345kjhlkh",
},
// Nightly tags differ from release tags ('-ent' suffix is omitted)
{
consulImage: "docker.mirror.hashicorp.services/hashicorppreview/consul:1.17-dev",
expImage: "docker.mirror.hashicorp.services/hashicorppreview/consul-enterprise:1.17-dev",
},
{
consulImage: "docker.mirror.hashicorp.services/hashicorppreview/consul:1.17-dev-ubi",
expImage: "docker.mirror.hashicorp.services/hashicorppreview/consul-enterprise:1.17-dev-ubi",
},
{
consulImage: "docker.mirror.hashicorp.services/hashicorppreview/consul@sha256:oioi2452345kjhlkh",
expImage: "docker.mirror.hashicorp.services/hashicorppreview/consul@sha256:oioi2452345kjhlkh",
},
}
for _, tt := range tests {
t.Run(tt.consulImage, func(t *testing.T) {
Expand Down

0 comments on commit 6b165cc

Please sign in to comment.