mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
Add test which checks if version has been changed (#466)
* Add test which checks if version has been changed * Compare version using ArangoVersion type
This commit is contained in:
parent
9b9862619c
commit
19cbd8dc5f
1 changed files with 65 additions and 0 deletions
65
tests/version_test.go
Normal file
65
tests/version_test.go
Normal file
|
@ -0,0 +1,65 @@
|
|||
package tests
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
|
||||
"github.com/arangodb/kube-arangodb/pkg/client"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/arangod"
|
||||
"github.com/dchest/uniuri"
|
||||
)
|
||||
|
||||
func TestIsVersionSet(t *testing.T) {
|
||||
longOrSkip(t)
|
||||
c := client.MustNewInCluster()
|
||||
kubecli := mustNewKubeClient(t)
|
||||
ns := getNamespace(t)
|
||||
|
||||
expectedVersion := driver.Version("3.3.17")
|
||||
// Prepare deployment config
|
||||
depl := newDeployment("test-auth-sng-def-" + uniuri.NewLen(4))
|
||||
depl.Spec.Mode = api.NewMode(api.DeploymentModeSingle)
|
||||
depl.Spec.SetDefaults(depl.GetName())
|
||||
depl.Spec.Image = util.NewString("arangodb/arangodb:" + string(expectedVersion))
|
||||
// Create deployment
|
||||
apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl)
|
||||
if err != nil {
|
||||
t.Fatalf("Create deployment failed: %v", err)
|
||||
}
|
||||
defer deferedCleanupDeployment(c, depl.GetName(), ns)
|
||||
// Wait for deployment to be ready
|
||||
depl, err = waitUntilDeployment(c, depl.GetName(), ns, deploymentIsReady())
|
||||
if err != nil {
|
||||
t.Fatalf("Deployment not running in time: %v", err)
|
||||
}
|
||||
|
||||
single := depl.Status.Members.Single
|
||||
if single == nil || len(single) == 0 {
|
||||
t.Fatalf("single member is empty")
|
||||
}
|
||||
|
||||
if single[0].ArangoVersion.CompareTo(expectedVersion) != 0 {
|
||||
t.Fatalf("version %s has not been set for the single member status", expectedVersion)
|
||||
}
|
||||
|
||||
// Create a database client
|
||||
ctx := arangod.WithRequireAuthentication(context.Background())
|
||||
client := mustNewArangodDatabaseClient(ctx, kubecli, apiObject, t, nil)
|
||||
|
||||
// Wait for single server available with a valid database version
|
||||
err = waitUntilVersionUp(client, func(version driver.VersionInfo) error {
|
||||
if version.Version.CompareTo(expectedVersion) != 0 {
|
||||
t.Fatalf("database version %s is not equal expected version %s", version.Version, version)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Single server not running returning version in time: %v", err)
|
||||
}
|
||||
|
||||
//Cleanup
|
||||
removeDeployment(c, depl.GetName(), ns)
|
||||
}
|
Loading…
Reference in a new issue