Skip to content

Commit

Permalink
upgrade test: use docker.mirror.hashicorp.services to avoid docker login
Browse files Browse the repository at this point in the history
  • Loading branch information
huikang committed Apr 28, 2023
1 parent e4a341c commit bbc2b3a
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ jobs:
${{ matrix.test-cases }} \
--target-image ${{ env.CONSUL_LATEST_IMAGE_NAME }} \
--target-version local \
--latest-image ${{ env.CONSUL_LATEST_IMAGE_NAME }} \
--latest-image docker.mirror.hashicorp.services/${{ env.CONSUL_LATEST_IMAGE_NAME }} \
--latest-version latest
ls -lrt
env:
Expand Down
3 changes: 2 additions & 1 deletion test/integration/consul-container/libs/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (c *Cluster) Remove(n Agent) error {
// helpers below.
//
// This lets us have tests that assert that an upgrade will fail.
func (c *Cluster) StandardUpgrade(t *testing.T, ctx context.Context, targetVersion string) error {
func (c *Cluster) StandardUpgrade(t *testing.T, ctx context.Context, targetImage string, targetVersion string) error {
var err error
// We take a snapshot, but note that we currently do nothing with it.
if c.ACLEnabled {
Expand Down Expand Up @@ -348,6 +348,7 @@ func (c *Cluster) StandardUpgrade(t *testing.T, ctx context.Context, targetVersi

upgradeFn := func(agent Agent, clientFactory func() (*api.Client, error)) error {
config := agent.GetConfig()
config.Image = targetImage
config.Version = targetVersion

if agent.IsServer() {
Expand Down
7 changes: 7 additions & 0 deletions test/integration/consul-container/libs/utils/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ func GetTargetImageName() string {
return targetImageName
}

func GetLatestImageName() string {
if Debug {
return LatestImageName + "-dbg"
}
return LatestImageName
}

func DockerImage(image, version string) string {
v := image + ":" + version
if image == DefaultImageNameENT && isSemVer(version) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestACL_NodeToken(t *testing.T) {
cluster.Agents[1].GetAgentName())
require.NoError(t, err)

err = cluster.StandardUpgrade(t, context.Background(), utils.TargetVersion)
err = cluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), utils.TargetVersion)
require.NoError(t, err)

// Post upgrade validation: agent token can be used to query the node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestBasic(t *testing.T) {

// upgrade the cluster to the Target version
t.Logf("initiating standard upgrade to version=%q", utils.TargetVersion)
err = cluster.StandardUpgrade(t, context.Background(), utils.TargetVersion)
err = cluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), utils.TargetVersion)

require.NoError(t, err)
libcluster.WaitForLeader(t, cluster, client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ var (
func TestStandardUpgradeToTarget_fromLatest(t *testing.T) {
t.Parallel()

tcs = append(tcs,
testcase{
// 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,
},
)
// tcs = append(tcs,
// testcase{
// // 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,
// },
// )

tcs = append(tcs, testcase{
oldVersion: utils.LatestVersion,
Expand All @@ -51,7 +51,7 @@ func TestStandardUpgradeToTarget_fromLatest(t *testing.T) {

run := func(t *testing.T, tc testcase) {
configCtx := libcluster.NewBuildContext(t, libcluster.BuildOptions{
ConsulImageName: utils.GetTargetImageName(),
ConsulImageName: utils.GetLatestImageName(),
ConsulVersion: tc.oldVersion,
})

Expand Down Expand Up @@ -107,7 +107,7 @@ func TestStandardUpgradeToTarget_fromLatest(t *testing.T) {

// upgrade the cluster to the Target version
t.Logf("initiating standard upgrade to version=%q", tc.targetVersion)
err = cluster.StandardUpgrade(t, context.Background(), tc.targetVersion)
err = cluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), tc.targetVersion)

if !tc.expectErr {
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestIngressGateway_GRPC_UpgradeToTarget_fromLatest(t *testing.T) {
}

t.Logf("Upgrade to version %s", utils.TargetVersion)
err = cluster.StandardUpgrade(t, context.Background(), utils.TargetVersion)
err = cluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), utils.TargetVersion)
require.NoError(t, err)
require.NoError(t, igw.Restart())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func TestIngressGateway_SDS_UpgradeToTarget_fromLatest(t *testing.T) {

// Upgrade the cluster to utils.TargetVersion
t.Logf("Upgrade to version %s", utils.TargetVersion)
err = cluster.StandardUpgrade(t, context.Background(), utils.TargetVersion)
err = cluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), utils.TargetVersion)
require.NoError(t, err)
require.NoError(t, igw.Restart())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func TestIngressGateway_UpgradeToTarget_fromLatest(t *testing.T) {

// Upgrade the cluster to utils.utils.TargetVersion
t.Logf("Upgrade to version %s", utils.TargetVersion)
err = cluster.StandardUpgrade(t, context.Background(), utils.TargetVersion)
err = cluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), utils.TargetVersion)
require.NoError(t, err)
require.NoError(t, igw.Restart())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestTrafficManagement_ResolveDefaultSubset(t *testing.T) {
assertionFn()

// Upgrade cluster, restart sidecars then begin service traffic validation
require.NoError(t, cluster.StandardUpgrade(t, context.Background(), utils.TargetVersion))
require.NoError(t, cluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), utils.TargetVersion))
require.NoError(t, staticClientProxy.Restart())
require.NoError(t, staticServerProxy.Restart())
require.NoError(t, serverConnectProxyV1.Restart())
Expand Down Expand Up @@ -198,7 +198,7 @@ func TestTrafficManagement_ResolverDefaultOnlyPassing(t *testing.T) {
assertionFn()

// Upgrade cluster, restart sidecars then begin service traffic validation
require.NoError(t, cluster.StandardUpgrade(t, context.Background(), utils.TargetVersion))
require.NoError(t, cluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), utils.TargetVersion))
require.NoError(t, staticClientProxy.Restart())
require.NoError(t, staticServerProxy.Restart())
require.NoError(t, serverConnectProxyV1.Restart())
Expand Down Expand Up @@ -307,7 +307,7 @@ func TestTrafficManagement_ResolverSubsetRedirect(t *testing.T) {
assertionFn()

// Upgrade cluster, restart sidecars then begin service traffic validation
require.NoError(t, cluster.StandardUpgrade(t, context.Background(), utils.TargetVersion))
require.NoError(t, cluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), utils.TargetVersion))
require.NoError(t, staticClientProxy.Restart())
require.NoError(t, staticServerProxy.Restart())
require.NoErrorf(t, server2ConnectProxy.Restart(), "%s", server2ConnectProxy.GetName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ func TestPeering_ControlPlaneMGW(t *testing.T) {
"upstream_cx_total", 1)

// Upgrade the accepting cluster and assert peering is still ACTIVE
require.NoError(t, acceptingCluster.StandardUpgrade(t, context.Background(), utils.TargetVersion))
require.NoError(t, acceptingCluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), utils.TargetVersion))
libassert.PeeringStatus(t, acceptingClient, libtopology.AcceptingPeerName, api.PeeringStateActive)
libassert.PeeringStatus(t, dialingClient, libtopology.DialingPeerName, api.PeeringStateActive)

require.NoError(t, dialingCluster.StandardUpgrade(t, context.Background(), utils.TargetVersion))
require.NoError(t, dialingCluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), utils.TargetVersion))
libassert.PeeringStatus(t, acceptingClient, libtopology.AcceptingPeerName, api.PeeringStateActive)
libassert.PeeringStatus(t, dialingClient, libtopology.DialingPeerName, api.PeeringStateActive)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ func peeringUpgrade(t *testing.T, accepting, dialing *libtopology.BuiltCluster,
_, staticClientPort := dialing.Container.GetAddr()

// Upgrade the accepting cluster and assert peering is still ACTIVE
require.NoError(t, accepting.Cluster.StandardUpgrade(t, context.Background(), targetVersion))
require.NoError(t, accepting.Cluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), targetVersion))
libassert.PeeringStatus(t, acceptingClient, libtopology.AcceptingPeerName, api.PeeringStateActive)
libassert.PeeringStatus(t, dialingClient, libtopology.DialingPeerName, api.PeeringStateActive)

require.NoError(t, dialing.Cluster.StandardUpgrade(t, context.Background(), targetVersion))
require.NoError(t, dialing.Cluster.StandardUpgrade(t, context.Background(), utils.GetTargetImageName(), targetVersion))
libassert.PeeringStatus(t, acceptingClient, libtopology.AcceptingPeerName, api.PeeringStateActive)
libassert.PeeringStatus(t, dialingClient, libtopology.DialingPeerName, api.PeeringStateActive)

Expand Down

0 comments on commit bbc2b3a

Please sign in to comment.