Skip to content

Commit

Permalink
Merge pull request #276 from arangodb/bug-fix/readiness-upgrade-fix
Browse files Browse the repository at this point in the history
Fixed readiness route.
  • Loading branch information
neunhoef authored Oct 26, 2018
2 parents 0c68821 + afb2bc2 commit d862e71
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
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",
Secure: spec.IsSecure(),
Authorization: authorization,
InitialDelaySeconds: 2,
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

0 comments on commit d862e71

Please sign in to comment.