Skip to content

Commit

Permalink
Revert "fix a bug in upgrade test"
Browse files Browse the repository at this point in the history
This reverts commit ad79429.
  • Loading branch information
huikang committed Aug 7, 2023
1 parent ad79429 commit eae5324
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 32 deletions.
27 changes: 6 additions & 21 deletions test/integration/consul-container/libs/cluster/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import (
"path/filepath"
"testing"

"github.com/hashicorp/go-version"
"github.com/stretchr/testify/require"
"golang.org/x/mod/semver"

"github.com/hashicorp/consul/test/integration/consul-container/libs/utils"
)

// TODO: switch from semver to go-version

const (
remoteCertDirectory = "/consul/config/certs"

Expand Down Expand Up @@ -66,7 +68,6 @@ type BuildOptions struct {
// cluster when none is specified.
ConsulImageName string

// TODO: switch from string to go-version.Version type
// ConsulVersion is the default Consul version for agents in the cluster
// when none is specified.
ConsulVersion string
Expand Down Expand Up @@ -206,8 +207,7 @@ func NewConfigBuilder(ctx *BuildContext) *Builder {
b.conf.Set("ports.http", 8500)
}

tmpVersion, _ := version.NewVersion(ctx.consulVersion)
if ctx.consulVersion == "local" || tmpVersion.GreaterThanOrEqual(utils.Version_1_14) {
if ctx.consulVersion == "local" || semver.Compare("v"+ctx.consulVersion, "v1.14.0") >= 0 {
// Enable GRPCTLS for version after v1.14.0
b.conf.Set("ports.grpc_tls", 8503)
}
Expand All @@ -220,8 +220,7 @@ func NewConfigBuilder(ctx *BuildContext) *Builder {

ls := string(ctx.logStore)
if ls != "" && (ctx.consulVersion == "local" ||
// semver.Compare("v"+ctx.consulVersion, "v1.15.0") >= 0) {
tmpVersion.GreaterThanOrEqual(utils.Version_1_15)) {
semver.Compare("v"+ctx.consulVersion, "v1.15.0") >= 0) {
// Enable logstore backend for version after v1.15.0
if ls != string(LogStore_WAL) && ls != string(LogStore_BoltDB) {
ls = string(LogStore_BoltDB)
Expand Down Expand Up @@ -270,13 +269,6 @@ func (b *Builder) Datacenter(name string) *Builder {
}

func (b *Builder) Peering(enable bool) *Builder {
if b.context.consulVersion != "local" {
tmpVersion, _ := version.NewVersion(b.context.consulVersion)
if tmpVersion.LessThan(utils.Version_1_14) {
return b
}
}

b.conf.Set("peering.enabled", enable)
return b
}
Expand Down Expand Up @@ -380,14 +372,7 @@ func (b *Builder) injectContextOptions(t *testing.T) {
if b.context.injectAutoEncryption {
if server {
b.conf.Set("auto_encrypt.allow_tls", true) // This setting is different between client and servers
if b.context.consulVersion == "local" {
b.conf.Set("tls.grpc.use_auto_cert", true) // This is required for peering to work over the non-GRPC_TLS port
} else {
tmpVersion, _ := version.NewVersion(b.context.consulVersion)
if tmpVersion.GreaterThanOrEqual(utils.Version_1_14) {
b.conf.Set("tls.grpc.use_auto_cert", true) // This is required for peering to work over the non-GRPC_TLS port
}
}
b.conf.Set("tls.grpc.use_auto_cert", true) // This is required for peering to work over the non-GRPC_TLS port
// VerifyIncoming does not apply to client agents for auto-encrypt
} else {
b.conf.Set("auto_encrypt.tls", true) // This setting is different between client and servers
Expand Down
1 change: 0 additions & 1 deletion test/integration/consul-container/libs/utils/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var (

Debug bool
Version_1_14, _ = version.NewVersion("1.14")
Version_1_15, _ = version.NewVersion("1.15")
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,12 @@ var (
func TestStandardUpgradeToTarget_fromLatest(t *testing.T) {
tcs = append(tcs,
testcase{
// Use the case of "1.12.3" ==> "1.13.0" to verify the upgrade test can
// Use the case of "1.12.3" ==> "1.13.0" to verify the test can
// catch the upgrade bug found in snapshot of 1.13.0
oldVersion: "1.12.3",
targetVersion: "1.13.0",
expectErr: true,
},
testcase{
// Use the case of "1.12.3" ==> "1.13.1" to verify the upgrade test can
// pass after the above bug fixed in 1.13.1
oldVersion: "1.12.3",
targetVersion: "1.13.1",
expectErr: false,
},
)

tcs = append(tcs, testcase{
Expand All @@ -59,7 +52,7 @@ func TestStandardUpgradeToTarget_fromLatest(t *testing.T) {
const numServers = 1
buildOpts := &libcluster.BuildOptions{
ConsulImageName: utils.GetLatestImageName(),
ConsulVersion: tc.oldVersion,
ConsulVersion: utils.LatestVersion,
Datacenter: "dc1",
InjectAutoEncryption: true,
}
Expand Down Expand Up @@ -123,7 +116,7 @@ func TestStandardUpgradeToTarget_fromLatest(t *testing.T) {
require.Equal(r, serviceName, service[0].ServiceName)
})
} else {
require.ErrorContains(t, err, "failed to start container")
require.ErrorContains(t, err, "context deadline exceeded")
}
}

Expand Down

0 comments on commit eae5324

Please sign in to comment.