-
Notifications
You must be signed in to change notification settings - Fork 73
Feature/add tests for immutable cluster parameters #59
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
Merged
ewoutp
merged 15 commits into
master
from
feature/add-tests-for-immutable-cluster-parameters
Mar 27, 2018
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
be15ced
i made my first test. lol!
kvahed 43ccac6
Merge branch 'master' of https://github.com/arangodb/k8s-operator int…
kvahed b5ab27b
Added first immutable test
kvahed fa9066c
Merge branch 'master' of https://github.com/arangodb/k8s-operator int…
kvahed 64aa14a
Added first immutable test
kvahed 501eb3e
Added first immutable test
kvahed 3b6e84e
removed crap at end of file
kvahed f0eecb8
Merge branch 'master' of https://github.com/arangodb/k8s-operator int…
kvahed 1674082
rocksdb key name and mode parameters added
kvahed e11b921
Merge branch 'master' into feature/add-tests-for-immutable-cluster-pa…
ewoutp 39daf3e
Updated to master
ewoutp 4f9178b
Added fileheader
ewoutp 74536a6
Various fixes
ewoutp 7078ce8
Merge branch 'master' into feature/add-tests-for-immutable-cluster-pa…
ewoutp e2488ef
Excluded secrets
ewoutp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// | ||
// DISCLAIMER | ||
// | ||
// Copyright 2018 ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
// | ||
// Author Kaveh Vahedipour | ||
// Author Ewout Prangsma | ||
// | ||
|
||
package tests | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
"github.com/dchest/uniuri" | ||
|
||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" | ||
"github.com/arangodb/kube-arangodb/pkg/client" | ||
) | ||
|
||
// TestImmutableFields tests that several immutable fields in the deployment | ||
// spec are reverted to their original value. | ||
func TestImmutableFields(t *testing.T) { | ||
longOrSkip(t) | ||
c := client.MustNewInCluster() | ||
kubecli := mustNewKubeClient(t) | ||
ns := getNamespace(t) | ||
revertTimeout := time.Second * 30 | ||
|
||
// Prepare deployment config | ||
depl := newDeployment("test-ise-" + uniuri.NewLen(4)) | ||
depl.Spec.Mode = api.NewMode(api.DeploymentModeSingle) | ||
depl.Spec.SetDefaults(depl.GetName()) | ||
|
||
// Create deployment | ||
apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) | ||
if err != nil { | ||
t.Fatalf("Create deployment failed: %v", err) | ||
} | ||
|
||
// Wait for deployment to be ready | ||
if _, err := waitUntilDeployment(c, depl.GetName(), ns, deploymentHasState(api.DeploymentStateRunning)); err != nil { | ||
t.Fatalf("Deployment not running in time: %v", err) | ||
} | ||
|
||
// Create a database client | ||
ctx := context.Background() | ||
client := mustNewArangodDatabaseClient(ctx, kubecli, apiObject, t) | ||
|
||
// Wait for single server to be completely ready | ||
if err := waitUntilVersionUp(client); err != nil { | ||
t.Fatalf("Single server not up in time: %v", err) | ||
} | ||
|
||
// Try to reset storageEngine =============================================== | ||
if _, err := updateDeployment(c, depl.GetName(), ns, | ||
func(spec *api.DeploymentSpec) { | ||
spec.StorageEngine = api.NewStorageEngine(api.StorageEngineMMFiles) | ||
}); err != nil { | ||
t.Fatalf("Failed to update the StorageEngine setting: %v", err) | ||
} | ||
|
||
// Wait for StorageEngine parameter to be back to RocksDB | ||
if _, err := waitUntilDeployment(c, depl.GetName(), ns, | ||
func(depl *api.ArangoDeployment) error { | ||
if api.StorageEngineOrDefault(depl.Spec.StorageEngine) == api.StorageEngineRocksDB { | ||
return nil | ||
} | ||
return fmt.Errorf("StorageEngine not back to %s", api.StorageEngineRocksDB) | ||
}, revertTimeout); err != nil { | ||
t.Errorf("StorageEngine parameter is immutable: %v", err) | ||
} | ||
|
||
/* | ||
Secrets are a special case that we'll deal with later | ||
// Try to reset the RocksDB encryption key ================================== | ||
if _, err := updateDeployment(c, depl.GetName(), ns, | ||
func(spec *api.DeploymentSpec) { | ||
spec.RocksDB.Encryption.KeySecretName = util.NewString("foobarbaz") | ||
}); err != nil { | ||
t.Fatalf("Failed to update the RocksDB encryption key: %v", err) | ||
} | ||
|
||
// Wait for deployment mode to be set back to cluster | ||
if _, err := waitUntilDeployment(c, depl.GetName(), ns, | ||
func(depl *api.ArangoDeployment) error { | ||
if util.StringOrDefault(depl.Spec.RocksDB.Encryption.KeySecretName) == "test.encryption.keySecretName" { | ||
return nil | ||
} | ||
return fmt.Errorf("RocksDB encryption key not back to %s", "test.encryption.keySecretName") | ||
}, revertTimeout); err != nil { | ||
t.Errorf("RocksDB encryption key is mutable: %v", err) | ||
} | ||
*/ | ||
|
||
// Try to reset the deployment type ========================================== | ||
if _, err := updateDeployment(c, depl.GetName(), ns, | ||
func(spec *api.DeploymentSpec) { | ||
spec.Mode = api.NewMode(api.DeploymentModeCluster) | ||
}); err != nil { | ||
t.Fatalf("Failed to update the deployment mode: %v", err) | ||
} | ||
|
||
// Wait for deployment mode to be set back to cluster | ||
if _, err := waitUntilDeployment(c, depl.GetName(), ns, | ||
func(depl *api.ArangoDeployment) error { | ||
expected := api.DeploymentModeSingle | ||
if api.ModeOrDefault(depl.Spec.Mode) == expected { | ||
return nil | ||
} | ||
return fmt.Errorf("Deployment mode not back to %s", expected) | ||
}, revertTimeout); err != nil { | ||
t.Errorf("Deployment mode is mutable: %v", err) | ||
} | ||
|
||
// Cleanup | ||
removeDeployment(c, depl.GetName(), ns) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 file header