Skip to content

Commit

Permalink
Move test initialization to SetupTest
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas Palma <[email protected]>
  • Loading branch information
rubenvp8510 committed Oct 22, 2020
1 parent bbdbed6 commit ef5d183
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
3 changes: 2 additions & 1 deletion pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
26 changes: 14 additions & 12 deletions test/e2e/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit ef5d183

Please sign in to comment.