@@ -27,26 +27,27 @@ import (
2727 "context"
2828 "fmt"
2929 "testing"
30+ "time"
3031
3132 "github.com/dchest/uniuri"
3233
33- driver "github.com/arangodb/go-driver"
3434 api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
3535 "github.com/arangodb/kube-arangodb/pkg/client"
3636 "github.com/arangodb/kube-arangodb/pkg/util"
3737)
3838
39- // TestImmutableStorageEngine
40- // Tests that storage engine of deployed cluster cannot be changed
41- func TestImmutableStorageEngine (t * testing.T ) {
39+ // TestImmutableFields tests that several immutable fields in the deployment
40+ // spec are reverted to their original value.
41+ func TestImmutableFields (t * testing.T ) {
4242 longOrSkip (t )
4343 c := client .MustNewInCluster ()
4444 kubecli := mustNewKubeClient (t )
4545 ns := getNamespace (t )
46+ revertTimeout := time .Second * 30
4647
4748 // Prepare deployment config
4849 depl := newDeployment ("test-ise-" + uniuri .NewLen (4 ))
49- depl .Spec .Mode = api .NewMode (api .DeploymentModeCluster )
50+ depl .Spec .Mode = api .NewMode (api .DeploymentModeSingle )
5051 depl .Spec .SetDefaults (depl .GetName ())
5152
5253 // Create deployment
@@ -64,11 +65,9 @@ func TestImmutableStorageEngine(t *testing.T) {
6465 ctx := context .Background ()
6566 client := mustNewArangodDatabaseClient (ctx , kubecli , apiObject , t )
6667
67- // Wait for cluster to be completely ready
68- if err := waitUntilClusterHealth (client , func (h driver.ClusterHealth ) error {
69- return clusterHealthEqualsSpec (h , apiObject .Spec )
70- }); err != nil {
71- t .Fatalf ("Cluster not running in expected health in time: %v" , err )
68+ // Wait for single server to be completely ready
69+ if err := waitUntilVersionUp (client ); err != nil {
70+ t .Fatalf ("Single server not up in time: %v" , err )
7271 }
7372
7473 // Try to reset storageEngine ===============================================
@@ -86,8 +85,8 @@ func TestImmutableStorageEngine(t *testing.T) {
8685 return nil
8786 }
8887 return fmt .Errorf ("StorageEngine not back to %s" , api .StorageEngineRocksDB )
89- }); err != nil {
90- t .Fatalf ("StorageEngine parameter should not be immutable: %v" , err )
88+ }, revertTimeout ); err != nil {
89+ t .Errorf ("StorageEngine parameter is immutable: %v" , err )
9190 }
9291
9392 // Try to reset the RocksDB encryption key ==================================
@@ -105,27 +104,28 @@ func TestImmutableStorageEngine(t *testing.T) {
105104 return nil
106105 }
107106 return fmt .Errorf ("RocksDB encryption key not back to %s" , "test.encryption.keySecretName" )
108- }); err != nil {
109- t .Fatalf ("RocksDB encryption key not be mutable: %v" , err )
107+ }, revertTimeout ); err != nil {
108+ t .Errorf ("RocksDB encryption key is mutable: %v" , err )
110109 }
111110
112111 // Try to reset the deployment type ==========================================
113112 if _ , err := updateDeployment (c , depl .GetName (), ns ,
114113 func (spec * api.DeploymentSpec ) {
115- spec .Mode = api .NewMode (api .DeploymentModeSingle )
114+ spec .Mode = api .NewMode (api .DeploymentModeCluster )
116115 }); err != nil {
117116 t .Fatalf ("Failed to update the deployment mode: %v" , err )
118117 }
119118
120119 // Wait for deployment mode to be set back to cluster
121120 if _ , err := waitUntilDeployment (c , depl .GetName (), ns ,
122121 func (depl * api.ArangoDeployment ) error {
123- if api .ModeOrDefault (depl .Spec .Mode ) == api .DeploymentModeCluster {
122+ expected := api .DeploymentModeSingle
123+ if api .ModeOrDefault (depl .Spec .Mode ) == expected {
124124 return nil
125125 }
126- return fmt .Errorf ("Deployment mode not back to %s" , api . DeploymentModeCluster )
127- }); err != nil {
128- t .Fatalf ("Deployment mode should not be mutable: %v" , err )
126+ return fmt .Errorf ("Deployment mode not back to %s" , expected )
127+ }, revertTimeout ); err != nil {
128+ t .Errorf ("Deployment mode is mutable: %v" , err )
129129 }
130130
131131 // Cleanup
0 commit comments