-
Notifications
You must be signed in to change notification settings - Fork 73
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
Conversation
0d536b2
to
05f8536
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments
tests/test_util.go
Outdated
func arangoDeploymentHealthy(t *testing.T, deployment *api.ArangoDeployment, k8sClient kubernetes.Interface) { | ||
// Create a database client | ||
ctx := context.Background() | ||
DBClient := mustNewArangodDatabaseClient(ctx, k8sClient, deployment, t) |
There was a problem hiding this comment.
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.
tests/test_util.go
Outdated
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment.
tests/test_util.go
Outdated
@@ -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) { |
There was a problem hiding this comment.
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
tests/test_util.go
Outdated
@@ -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) { |
There was a problem hiding this comment.
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.
tests/upgrade_test.go
Outdated
"github.com/arangodb/kube-arangodb/pkg/util" | ||
) | ||
|
||
// TODO - environments (provided from outside) |
There was a problem hiding this comment.
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.
tests/upgrade_test.go
Outdated
t.Fatalf("Deployment not running in time: %v", err) | ||
} | ||
|
||
arangoDeploymentHealthy(t, deployment, k8sClient) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment please
tests/upgrade_test.go
Outdated
arangoDeploymentHealthy(t, deployment, k8sClient) | ||
|
||
ctx := context.Background() | ||
DBClient := mustNewArangodDatabaseClient(ctx, k8sClient, deployment, t) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
8f46730
to
6fa02ea
Compare
and change signature to match other helper functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments
tests/test_util.go
Outdated
@@ -231,9 +236,30 @@ func waitUntilVersionUp(cli driver.Client, allowNoLeaderResponse ...bool) error | |||
return maskAny(noLeaderErr) | |||
} | |||
|
|||
if predicate != nil { |
There was a problem hiding this comment.
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.
tests/test_util.go
Outdated
} | ||
|
||
// creates predicate to be used in waitUntilVersionUp | ||
func createEqualVersionsPredicateFromString(version_string string) func(driver.VersionInfo) error { |
There was a problem hiding this comment.
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
tests/test_util.go
Outdated
return nil | ||
} | ||
|
||
// creates predicate to be used in waitUntilVersionUp | ||
func createEqualVersionsPredicate(info driver.VersionInfo) func(driver.VersionInfo) error { |
There was a problem hiding this comment.
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.
tests/test_util.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
tests/test_util.go
Outdated
singles := members.Single | ||
agents := members.Agents | ||
|
||
if len(singles) != 2 || len(agents) != 3 { |
There was a problem hiding this comment.
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.
tests/test_util.go
Outdated
} | ||
} | ||
|
||
if goodResults < 1 || noLeaderResults > 1 { |
There was a problem hiding this comment.
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.
tests/upgrade_test.go
Outdated
deploymentClient := kubeArangoClient.MustNewInCluster() | ||
|
||
// Prepare deployment config | ||
deploymentName := "test-upgrade-" + string(mode) + "-" + string(engine) |
There was a problem hiding this comment.
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)
tests/test_util.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
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*"]
There was a problem hiding this 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
No description provided.