Skip to content

Commit

Permalink
Fix default Ent image tag in acceptance tests
Browse files Browse the repository at this point in the history
Rather than hard-coding the Docker repository and parsing the non-Ent
image tag for a version, simply replace the image name and retain other
coordinates. This is consistent with our tagging scheme introduced in
hashicorp/consul#13541 and will allow for using
`hashicorppreview` images seamlessly regardless of whether OSS or Ent is
being tested.
  • Loading branch information
zalimeni committed Jul 28, 2023
1 parent b6d3e61 commit aa7f476
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
18 changes: 2 additions & 16 deletions acceptance/framework/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package config

import (
"fmt"
"math"
"os"
"path/filepath"
Expand Down Expand Up @@ -217,21 +216,8 @@ 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])
}

return fmt.Sprintf("hashicorp/consul-enterprise:%s%s-ent", consulImageVersion, preRelease), nil
// Use the same Docker repository and tagging scheme, but replace 'consul' with 'consul-enterprise'.
return strings.Replace(v.Global.Image, "/consul:", "/consul-enterprise:", 1), nil
}

func (c *TestConfig) SkipWhenOpenshiftAndCNI(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions acceptance/framework/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,19 @@ func TestConfig_HelmValuesFromConfig_EntImage(t *testing.T) {
}{
{
consulImage: "hashicorp/consul:1.9.0",
expImage: "hashicorp/consul-enterprise:1.9.0-ent",
expImage: "hashicorp/consul-enterprise:1.9.0",
},
{
consulImage: "hashicorp/consul:1.8.5-rc1",
expImage: "hashicorp/consul-enterprise:1.8.5-rc1-ent",
expImage: "hashicorp/consul-enterprise:1.8.5-rc1",
},
{
consulImage: "hashicorp/consul:1.7.0-beta3",
expImage: "hashicorp/consul-enterprise:1.7.0-beta3-ent",
expImage: "hashicorp/consul-enterprise:1.7.0-beta3",
},
{
consulImage: "invalid",
expErr: "could not determine consul version from global.image: invalid",
consulImage: "docker.mirror.hashicorp.services/hashicorppreview/consul:1.7.0-beta3",
expImage: "docker.mirror.hashicorp.services/hashicorppreview/consul-enterprise:1.7.0-beta3",
},
{
consulImage: "hashicorp/consul@sha256:oioi2452345kjhlkh",
Expand Down

0 comments on commit aa7f476

Please sign in to comment.