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

Fixed readiness route. #276

Merged
merged 4 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/deployment/resources/pod_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func (r *Resources) createReadinessProbe(spec api.DeploymentSpec, group api.Serv
}
}
probeCfg := &k8sutil.HTTPProbeConfig{
LocalPath: "/_api/version",
LocalPath: "/_admin/server/availability",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Make this more robust and choose route depending on version.

Secure: spec.IsSecure(),
Authorization: authorization,
InitialDelaySeconds: 2,
Expand Down
3 changes: 3 additions & 0 deletions tests/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ func newDeployment(name string) *api.ArangoDeployment {
ObjectMeta: metav1.ObjectMeta{
Name: strings.ToLower(name),
},
Spec: api.DeploymentSpec{
ImagePullPolicy: util.NewPullPolicy(v1.PullAlways),
},
}

// set default image to the value given in env
Expand Down
45 changes: 27 additions & 18 deletions tests/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ import (
"strings"
"testing"

"github.com/dchest/uniuri"

api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
kubeArangoClient "github.com/arangodb/kube-arangodb/pkg/client"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/dchest/uniuri"
)

func TestUpgradeClusterRocksDB33pto34p(t *testing.T) {
upgradeSubTest(t, api.DeploymentModeCluster, api.StorageEngineRocksDB, "arangodb/arangodb-preview:3.3", "arangodb/arangodb-preview:3.4")
}

// test upgrade single server mmfiles 3.2 -> 3.3
func TestUpgradeSingleMMFiles32to33(t *testing.T) {
upgradeSubTest(t, api.DeploymentModeSingle, api.StorageEngineMMFiles, "3.2.16", "3.3.13")
upgradeSubTest(t, api.DeploymentModeSingle, api.StorageEngineMMFiles, "arangodb/arangodb:3.2.16", "arangodb/arangodb:3.3.13")
}

// // test upgrade single server rocksdb 3.3 -> 3.4
Expand Down Expand Up @@ -64,34 +67,34 @@ func TestUpgradeClusterRocksDB32to33(t *testing.T) {
// upgradeSubTest(t, api.DeploymentModeCluster, api.StorageEngineRocksDB, "3.3.13", "3.4.0")
// }

// test downgrade single server mmfiles 3.3.13 -> 3.3.12
func TestDowngradeSingleMMFiles333to332(t *testing.T) {
upgradeSubTest(t, api.DeploymentModeSingle, api.StorageEngineMMFiles, "3.3.13", "3.3.12")
// test downgrade single server mmfiles 3.3.17 -> 3.3.16
func TestDowngradeSingleMMFiles3317to3316(t *testing.T) {
upgradeSubTest(t, api.DeploymentModeSingle, api.StorageEngineMMFiles, "arangodb/arangodb:3.3.16", "arangodb/arangodb:3.3.17")
}

// test downgrade ActiveFailover server rocksdb 3.3.13 -> 3.3.12
func TestDowngradeActiveFailoverRocksDB333to332(t *testing.T) {
upgradeSubTest(t, api.DeploymentModeActiveFailover, api.StorageEngineRocksDB, "3.3.13", "3.3.12")
// test downgrade ActiveFailover server rocksdb 3.3.17 -> 3.3.16
func TestDowngradeActiveFailoverRocksDB3317to3316(t *testing.T) {
upgradeSubTest(t, api.DeploymentModeActiveFailover, api.StorageEngineRocksDB, "arangodb/arangodb:3.3.16", "arangodb/arangodb:3.3.17")
}

// test downgrade cluster rocksdb 3.3.13 -> 3.3.12
func TestDowngradeClusterRocksDB332to332(t *testing.T) {
upgradeSubTest(t, api.DeploymentModeCluster, api.StorageEngineRocksDB, "3.3.13", "3.3.12")
// test downgrade cluster rocksdb 3.3.17 -> 3.3.16
func TestDowngradeClusterRocksDB3317to3316(t *testing.T) {
upgradeSubTest(t, api.DeploymentModeCluster, api.StorageEngineRocksDB, "arangodb/arangodb:3.3.16", "arangodb/arangodb:3.3.17")
}

func upgradeSubTest(t *testing.T, mode api.DeploymentMode, engine api.StorageEngine, fromVersion, toVersion string) error {
func upgradeSubTest(t *testing.T, mode api.DeploymentMode, engine api.StorageEngine, fromImage, toImage string) error {
// check environment
longOrSkip(t)

ns := getNamespace(t)
kubecli := mustNewKubeClient(t)
c := kubeArangoClient.MustNewInCluster()

depl := newDeployment(strings.Replace(fmt.Sprintf("tu-%s-%s-%st%s-%s", mode[:2], engine[:2], fromVersion, toVersion, uniuri.NewLen(4)), ".", "", -1))
depl := newDeployment(strings.Replace(fmt.Sprintf("tu-%s-%s-%s", mode[:2], engine[:2], uniuri.NewLen(4)), ".", "", -1))
depl.Spec.Mode = api.NewMode(mode)
depl.Spec.StorageEngine = api.NewStorageEngine(engine)
depl.Spec.TLS = api.TLSSpec{} // should auto-generate cert
depl.Spec.Image = util.NewString("arangodb/arangodb:" + fromVersion)
depl.Spec.Image = util.NewString(fromImage)
depl.Spec.SetDefaults(depl.GetName()) // this must be last

// Create deployment
Expand All @@ -118,19 +121,25 @@ func upgradeSubTest(t *testing.T, mode api.DeploymentMode, engine api.StorageEng
// Try to change image version
deployment, err = updateDeployment(c, depl.GetName(), ns,
func(spec *api.DeploymentSpec) {
spec.Image = util.NewString("arangodb/arangodb:" + toVersion)
spec.Image = util.NewString(toImage)
})
if err != nil {
t.Fatalf("Failed to upgrade the Image from version : " + fromVersion + " to version: " + toVersion)
t.Fatalf("Failed to upgrade the Image from version : " + fromImage + " to version: " + toImage)
} else {
t.Log("Updated deployment")
}

deployment, err = waitUntilDeployment(c, depl.GetName(), ns, deploymentIsReady())
if err != nil {
t.Fatalf("Deployment not running in time: %v", err)
} else {
t.Log("Deployment running")
}

if err := waitUntilArangoDeploymentHealthy(deployment, DBClient, kubecli, toVersion); err != nil {
if err := waitUntilArangoDeploymentHealthy(deployment, DBClient, kubecli, toImage); err != nil {
t.Fatalf("Deployment not healthy in time: %v", err)
} else {
t.Log("Deployment healthy")
}

// Cleanup
Expand Down