Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add upgrade tests #76

Merged
merged 18 commits into from
Mar 28, 2018
Merged

add upgrade tests #76

merged 18 commits into from
Mar 28, 2018

Conversation

ObiWahn
Copy link
Contributor

@ObiWahn ObiWahn commented Mar 26, 2018

No description provided.

@ObiWahn ObiWahn added the 9 WIP label Mar 26, 2018
@ObiWahn ObiWahn force-pushed the tests/upgrade branch 6 times, most recently from 0d536b2 to 05f8536 Compare March 26, 2018 10:28
@ewoutp ewoutp self-requested a review March 26, 2018 12:32
Copy link
Contributor

@ewoutp ewoutp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

func arangoDeploymentHealthy(t *testing.T, deployment *api.ArangoDeployment, k8sClient kubernetes.Interface) {
// Create a database client
ctx := context.Background()
DBClient := mustNewArangodDatabaseClient(ctx, k8sClient, deployment, t)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to keep the dbclient as an argument passed to this function.

@@ -297,3 +297,69 @@ func removeSecret(cli kubernetes.Interface, secretName, ns string) error {
}
return nil
}

func arangoDeploymentHealthy(t *testing.T, deployment *api.ArangoDeployment, k8sClient kubernetes.Interface) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment.

@@ -297,3 +297,69 @@ func removeSecret(cli kubernetes.Interface, secretName, ns string) error {
}
return nil
}

func arangoDeploymentHealthy(t *testing.T, deployment *api.ArangoDeployment, k8sClient kubernetes.Interface) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name is now clean to me.
Suggest to rename to waitUntilArangoDeploymentHealthy

@@ -297,3 +297,69 @@ func removeSecret(cli kubernetes.Interface, secretName, ns string) error {
}
return nil
}

func arangoDeploymentHealthy(t *testing.T, deployment *api.ArangoDeployment, k8sClient kubernetes.Interface) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be in line with other waitUntil... functions, this function must return an error in case something is wrong.
You can (read should) then remove the t *testing.T argument.

"github.com/arangodb/kube-arangodb/pkg/util"
)

// TODO - environments (provided from outside)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. What is there TODO?

Perhaps you can replace this by a comment, saying that the kubernetes deployment environments are controlled outside the tests and are therefor not a variable in these tests.

t.Fatalf("Deployment not running in time: %v", err)
}

arangoDeploymentHealthy(t, deployment, k8sClient)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment please

arangoDeploymentHealthy(t, deployment, k8sClient)

ctx := context.Background()
DBClient := mustNewArangodDatabaseClient(ctx, k8sClient, deployment, t)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this test must be done on all servers.
The current implementation of the test can succeed even f not all servers are actually upgraded.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you put this test in an op := func() error {... with a Retry: "Wait until all versions are correct"
Reason: It could be that the change of image is saved, the cluster is still healthy and the version check test
starts before any upgrading has actually taken place.

@ObiWahn ObiWahn force-pushed the tests/upgrade branch 2 times, most recently from 8f46730 to 6fa02ea Compare March 26, 2018 13:02
Copy link
Contributor

@ewoutp ewoutp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

@@ -231,9 +236,30 @@ func waitUntilVersionUp(cli driver.Client, allowNoLeaderResponse ...bool) error
return maskAny(noLeaderErr)
}

if predicate != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the predicate call inside the op function.
I expect the function to wait until the version response is valid, including any predicate I may pass in.

}

// creates predicate to be used in waitUntilVersionUp
func createEqualVersionsPredicateFromString(version_string string) func(driver.VersionInfo) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid underscores in names in go.
Use camelCasing

return nil
}

// creates predicate to be used in waitUntilVersionUp
func createEqualVersionsPredicate(info driver.VersionInfo) func(driver.VersionInfo) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect this function to have a version driver.Version argument, since that is the only thing you're comparing.
Will automatically make createEqualVersionsPredicateFromString obsolete.

@@ -297,3 +323,72 @@ func removeSecret(cli kubernetes.Interface, secretName, ns string) error {
}
return nil
}

func waitUntilArangoDeploymentHealthy(deployment *api.ArangoDeployment, DBClient driver.Client, k8sClient kubernetes.Interface, versionString ...string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment describing what the function does.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace versionString ...string with requiredVersion driver.Version.
If that is a non-empty string, create the predicate.

Reason: I think we may want to add other checks in the future and you can only have 1 optional argument.

singles := members.Single
agents := members.Agents

if len(singles) != 2 || len(agents) != 3 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't like these constants.
Check against a spec.

}
}

if goodResults < 1 || noLeaderResults > 1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't like the last 1 constant. Check against a spec.

deploymentClient := kubeArangoClient.MustNewInCluster()

// Prepare deployment config
deploymentName := "test-upgrade-" + string(mode) + "-" + string(engine)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a bit complicated.

deploymentName := strings.Replace(fmt.Sprintf("test-upgrade-%s-%s-%sto%s", mode, engine, fromVersion, toVersion), ".", "-", -1)

@@ -297,3 +310,72 @@ func removeSecret(cli kubernetes.Interface, secretName, ns string) error {
}
return nil
}

func waitUntilArangoDeploymentHealthy(deployment *api.ArangoDeployment, DBClient driver.Client, k8sClient kubernetes.Interface, versionString string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs a comment

[ci LONG=1]
[ci TESTOPTIONS="-test.run TestUpgrade*"]
@ObiWahn ObiWahn requested a review from neunhoef March 28, 2018 07:15
Copy link
Contributor

@ewoutp ewoutp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please merge it

@ObiWahn ObiWahn merged commit e5905ba into master Mar 28, 2018
@ObiWahn ObiWahn deleted the tests/upgrade branch March 28, 2018 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants