1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-15 17:51:03 +00:00
kube-arangodb/tests/version_test.go

66 lines
2 KiB
Go
Raw Normal View History

package tests
import (
"context"
"testing"
"github.com/arangodb/go-driver"
2019-11-04 07:49:24 +00:00
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"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)
2020-04-06 11:20:33 +00:00
c := client.MustNewClient()
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
2019-11-04 07:49:24 +00:00
apiObject, err := c.DatabaseV1().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)
}