From 9c977e6d1da0645a4e9d7409c48cf82b4da24a7b Mon Sep 17 00:00:00 2001 From: Ruben Vargas Palma Date: Tue, 20 Oct 2020 09:13:16 -0500 Subject: [PATCH] Move test initialization to SetupTest Signed-off-by: Ruben Vargas Palma --- pkg/upgrade/upgrade.go | 3 ++- test/e2e/upgrade_test.go | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/pkg/upgrade/upgrade.go b/pkg/upgrade/upgrade.go index 72ea1ac9b4..db4caf9379 100644 --- a/pkg/upgrade/upgrade.go +++ b/pkg/upgrade/upgrade.go @@ -74,7 +74,8 @@ func ManagedInstances(ctx context.Context, c client.Client, reader client.Reader log.WithFields(log.Fields{ "instance": jaeger.Name, "namespace": jaeger.Namespace, - }).WithError(err).Error("failed update status of the upgraded instance") + "version": version, + }).WithError(err).Error("failed to update status the upgraded instance") tracing.HandleError(err, span) } } else { diff --git a/test/e2e/upgrade_test.go b/test/e2e/upgrade_test.go index 9613d0046b..b8827a98ef 100644 --- a/test/e2e/upgrade_test.go +++ b/test/e2e/upgrade_test.go @@ -34,26 +34,28 @@ func TestOperatorUpgrade(t *testing.T) { func (suite *OperatorUpgradeTestSuite) SetupTest() { t = suite.T() -} - -func (suite *OperatorUpgradeTestSuite) TestUpgrade() { - upgradeTestVersion := os.Getenv(envUpgradeVersionKey) - versionRegexp := regexp.MustCompile(`^[\d]+\.[\d]+\.[\d]+`) - - require.Regexp(t, versionRegexp, upgradeTestVersion, - "Invalid upgrade version, need to specify a version to upgrade in format X.Y.Z") - - ctx, err := prepare(t) + var err error + ctx, err = prepare(t) if err != nil { ctx.Cleanup() require.FailNow(t, "Failed in prepare") } - defer ctx.Cleanup() addToFrameworkSchemeForSmokeTests(t) if err := simplest(t, framework.Global, ctx); err != nil { t.Fatal(err) } fw = framework.Global +} + +func (suite *OperatorUpgradeTestSuite) TearDownSuite() { + handleSuiteTearDown() +} + +func (suite *OperatorUpgradeTestSuite) TestUpgrade() { + upgradeTestVersion := os.Getenv(envUpgradeVersionKey) + versionRegexp := regexp.MustCompile(`^[\d]+\.[\d]+\.[\d]+`) + require.Regexp(t, versionRegexp, upgradeTestVersion, + "Invalid upgrade version, need to specify a version to upgrade in format X.Y.Z") createdJaeger := &v1.Jaeger{} key := types.NamespacedName{Name: "my-jaeger", Namespace: ctx.GetID()} fw.Client.Get(context.Background(), key, createdJaeger) @@ -64,7 +66,7 @@ func (suite *OperatorUpgradeTestSuite) TestUpgrade() { deployment.Spec.Template.Spec.Containers[0].Image = image t.Logf("Attempting to upgrade to version %s...", upgradeTestVersion) fw.Client.Update(context.Background(), deployment) - err = wait.Poll(retryInterval, timeout, func() (done bool, err error) { + err := wait.Poll(retryInterval, timeout, func() (done bool, err error) { updatedJaeger := &v1.Jaeger{} key := types.NamespacedName{Name: "my-jaeger", Namespace: ctx.GetID()} if err := fw.Client.Get(context.Background(), key, updatedJaeger); err != nil {