mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
Fixed int-test code
This commit is contained in:
parent
15e3f7518f
commit
61aaf55e31
6 changed files with 42 additions and 38 deletions
|
@ -29,12 +29,12 @@ import (
|
|||
|
||||
// RocksDBEncryptionSpec holds rocksdb encryption at rest specific configuration settings
|
||||
type RocksDBEncryptionSpec struct {
|
||||
XKeySecretName *string `json:"keySecretName,omitempty"`
|
||||
KeySecretName *string `json:"keySecretName,omitempty"`
|
||||
}
|
||||
|
||||
// GetKeySecretName returns the value of keySecretName.
|
||||
func (s RocksDBEncryptionSpec) GetKeySecretName() string {
|
||||
return util.StringOrDefault(s.XKeySecretName)
|
||||
return util.StringOrDefault(s.KeySecretName)
|
||||
}
|
||||
|
||||
// IsEncrypted returns true when an encryption key secret name is provided,
|
||||
|
@ -69,8 +69,8 @@ func (s *RocksDBSpec) SetDefaults() {
|
|||
|
||||
// SetDefaultsFrom fills unspecified fields with a value from given source spec.
|
||||
func (s *RocksDBSpec) SetDefaultsFrom(source RocksDBSpec) {
|
||||
if s.Encryption.XKeySecretName == nil {
|
||||
s.Encryption.XKeySecretName = util.NewStringOrNil(source.Encryption.XKeySecretName)
|
||||
if s.Encryption.KeySecretName == nil {
|
||||
s.Encryption.KeySecretName = util.NewStringOrNil(source.Encryption.KeySecretName)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ func (s RocksDBSpec) ResetImmutableFields(fieldPrefix string, target *RocksDBSpe
|
|||
var resetFields []string
|
||||
if s.IsEncrypted() != target.IsEncrypted() {
|
||||
// Note: You can change the name, but not from empty to non-empty (or reverse).
|
||||
target.Encryption.XKeySecretName = util.NewStringOrNil(s.Encryption.XKeySecretName)
|
||||
target.Encryption.KeySecretName = util.NewStringOrNil(s.Encryption.KeySecretName)
|
||||
resetFields = append(resetFields, fieldPrefix+".encryption.keySecretName")
|
||||
}
|
||||
return resetFields
|
||||
|
|
|
@ -403,8 +403,8 @@ func (in *MonitoringSpec) DeepCopy() *MonitoringSpec {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *RocksDBEncryptionSpec) DeepCopyInto(out *RocksDBEncryptionSpec) {
|
||||
*out = *in
|
||||
if in.XKeySecretName != nil {
|
||||
in, out := &in.XKeySecretName, &out.XKeySecretName
|
||||
if in.KeySecretName != nil {
|
||||
in, out := &in.KeySecretName, &out.KeySecretName
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
|
||||
"github.com/arangodb/kube-arangodb/pkg/client"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/arangod"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
)
|
||||
|
@ -24,7 +25,7 @@ func TestAuthenticationSingleDefaultSecret(t *testing.T) {
|
|||
|
||||
// Prepare deployment config
|
||||
depl := newDeployment("test-auth-sng-def-" + uniuri.NewLen(4))
|
||||
depl.Spec.Mode = api.DeploymentModeSingle
|
||||
depl.Spec.Mode = api.NewMode(api.DeploymentModeSingle)
|
||||
depl.Spec.SetDefaults(depl.GetName())
|
||||
|
||||
// Create deployment
|
||||
|
@ -39,7 +40,7 @@ func TestAuthenticationSingleDefaultSecret(t *testing.T) {
|
|||
}
|
||||
|
||||
// Secret must now exist
|
||||
if _, err := waitUntilSecret(kubecli, depl.Spec.Authentication.JWTSecretName, ns, nil, time.Second); err != nil {
|
||||
if _, err := waitUntilSecret(kubecli, depl.Spec.Authentication.GetJWTSecretName(), ns, nil, time.Second); err != nil {
|
||||
t.Fatalf("JWT secret '%s' not found: %v", depl.Spec.Authentication.JWTSecretName, err)
|
||||
}
|
||||
|
||||
|
@ -56,7 +57,7 @@ func TestAuthenticationSingleDefaultSecret(t *testing.T) {
|
|||
removeDeployment(c, depl.GetName(), ns)
|
||||
|
||||
// Secret must no longer exist
|
||||
if err := waitUntilSecretNotFound(kubecli, depl.Spec.Authentication.JWTSecretName, ns, time.Minute); err != nil {
|
||||
if err := waitUntilSecretNotFound(kubecli, depl.Spec.Authentication.GetJWTSecretName(), ns, time.Minute); err != nil {
|
||||
t.Fatalf("JWT secret '%s' still found: %v", depl.Spec.Authentication.JWTSecretName, err)
|
||||
}
|
||||
}
|
||||
|
@ -71,12 +72,12 @@ func TestAuthenticationSingleCustomSecret(t *testing.T) {
|
|||
|
||||
// Prepare deployment config
|
||||
depl := newDeployment("test-auth-sng-cst-" + uniuri.NewLen(4))
|
||||
depl.Spec.Mode = api.DeploymentModeSingle
|
||||
depl.Spec.Authentication.JWTSecretName = strings.ToLower(uniuri.New())
|
||||
depl.Spec.Mode = api.NewMode(api.DeploymentModeSingle)
|
||||
depl.Spec.Authentication.JWTSecretName = util.NewString(strings.ToLower(uniuri.New()))
|
||||
depl.Spec.SetDefaults(depl.GetName())
|
||||
|
||||
// Create secret
|
||||
if err := k8sutil.CreateJWTSecret(kubecli.CoreV1(), depl.Spec.Authentication.JWTSecretName, ns, "foo", nil); err != nil {
|
||||
if err := k8sutil.CreateJWTSecret(kubecli.CoreV1(), depl.Spec.Authentication.GetJWTSecretName(), ns, "foo", nil); err != nil {
|
||||
t.Fatalf("Create JWT secret failed: %v", err)
|
||||
}
|
||||
|
||||
|
@ -104,12 +105,12 @@ func TestAuthenticationSingleCustomSecret(t *testing.T) {
|
|||
removeDeployment(c, depl.GetName(), ns)
|
||||
|
||||
// Secret must still exist
|
||||
if _, err := waitUntilSecret(kubecli, depl.Spec.Authentication.JWTSecretName, ns, nil, time.Second); err != nil {
|
||||
if _, err := waitUntilSecret(kubecli, depl.Spec.Authentication.GetJWTSecretName(), ns, nil, time.Second); err != nil {
|
||||
t.Fatalf("JWT secret '%s' not found: %v", depl.Spec.Authentication.JWTSecretName, err)
|
||||
}
|
||||
|
||||
// Cleanup secret
|
||||
removeSecret(kubecli, depl.Spec.Authentication.JWTSecretName, ns)
|
||||
removeSecret(kubecli, depl.Spec.Authentication.GetJWTSecretName(), ns)
|
||||
}
|
||||
|
||||
// TestAuthenticationNoneSingle creating a single server
|
||||
|
@ -122,8 +123,8 @@ func TestAuthenticationNoneSingle(t *testing.T) {
|
|||
|
||||
// Prepare deployment config
|
||||
depl := newDeployment("test-auth-none-sng-" + uniuri.NewLen(4))
|
||||
depl.Spec.Mode = api.DeploymentModeSingle
|
||||
depl.Spec.Authentication.JWTSecretName = api.JWTSecretNameDisabled
|
||||
depl.Spec.Mode = api.NewMode(api.DeploymentModeSingle)
|
||||
depl.Spec.Authentication.JWTSecretName = util.NewString(api.JWTSecretNameDisabled)
|
||||
depl.Spec.SetDefaults(depl.GetName())
|
||||
|
||||
// Create deployment
|
||||
|
@ -160,7 +161,7 @@ func TestAuthenticationClusterDefaultSecret(t *testing.T) {
|
|||
|
||||
// Prepare deployment config
|
||||
depl := newDeployment("test-auth-cls-def-" + uniuri.NewLen(4))
|
||||
depl.Spec.Mode = api.DeploymentModeCluster
|
||||
depl.Spec.Mode = api.NewMode(api.DeploymentModeCluster)
|
||||
depl.Spec.SetDefaults(depl.GetName())
|
||||
|
||||
// Create deployment
|
||||
|
@ -175,7 +176,7 @@ func TestAuthenticationClusterDefaultSecret(t *testing.T) {
|
|||
}
|
||||
|
||||
// Secret must now exist
|
||||
if _, err := waitUntilSecret(kubecli, depl.Spec.Authentication.JWTSecretName, ns, nil, time.Second); err != nil {
|
||||
if _, err := waitUntilSecret(kubecli, depl.Spec.Authentication.GetJWTSecretName(), ns, nil, time.Second); err != nil {
|
||||
t.Fatalf("JWT secret '%s' not found: %v", depl.Spec.Authentication.JWTSecretName, err)
|
||||
}
|
||||
|
||||
|
@ -192,7 +193,7 @@ func TestAuthenticationClusterDefaultSecret(t *testing.T) {
|
|||
removeDeployment(c, depl.GetName(), ns)
|
||||
|
||||
// Secret must no longer exist
|
||||
if err := waitUntilSecretNotFound(kubecli, depl.Spec.Authentication.JWTSecretName, ns, time.Minute); err != nil {
|
||||
if err := waitUntilSecretNotFound(kubecli, depl.Spec.Authentication.GetJWTSecretName(), ns, time.Minute); err != nil {
|
||||
t.Fatalf("JWT secret '%s' still found: %v", depl.Spec.Authentication.JWTSecretName, err)
|
||||
}
|
||||
}
|
||||
|
@ -207,12 +208,12 @@ func TestAuthenticationClusterCustomSecret(t *testing.T) {
|
|||
|
||||
// Prepare deployment config
|
||||
depl := newDeployment("test-auth-cls-cst-" + uniuri.NewLen(4))
|
||||
depl.Spec.Mode = api.DeploymentModeCluster
|
||||
depl.Spec.Authentication.JWTSecretName = strings.ToLower(uniuri.New())
|
||||
depl.Spec.Mode = api.NewMode(api.DeploymentModeCluster)
|
||||
depl.Spec.Authentication.JWTSecretName = util.NewString(strings.ToLower(uniuri.New()))
|
||||
depl.Spec.SetDefaults(depl.GetName())
|
||||
|
||||
// Create secret
|
||||
if err := k8sutil.CreateJWTSecret(kubecli.CoreV1(), depl.Spec.Authentication.JWTSecretName, ns, "foo", nil); err != nil {
|
||||
if err := k8sutil.CreateJWTSecret(kubecli.CoreV1(), depl.Spec.Authentication.GetJWTSecretName(), ns, "foo", nil); err != nil {
|
||||
t.Fatalf("Create JWT secret failed: %v", err)
|
||||
}
|
||||
|
||||
|
@ -240,12 +241,12 @@ func TestAuthenticationClusterCustomSecret(t *testing.T) {
|
|||
removeDeployment(c, depl.GetName(), ns)
|
||||
|
||||
// Secret must still exist
|
||||
if _, err := waitUntilSecret(kubecli, depl.Spec.Authentication.JWTSecretName, ns, nil, time.Second); err != nil {
|
||||
if _, err := waitUntilSecret(kubecli, depl.Spec.Authentication.GetJWTSecretName(), ns, nil, time.Second); err != nil {
|
||||
t.Fatalf("JWT secret '%s' not found: %v", depl.Spec.Authentication.JWTSecretName, err)
|
||||
}
|
||||
|
||||
// Cleanup secret
|
||||
removeSecret(kubecli, depl.Spec.Authentication.JWTSecretName, ns)
|
||||
removeSecret(kubecli, depl.Spec.Authentication.GetJWTSecretName(), ns)
|
||||
}
|
||||
|
||||
// TestAuthenticationNoneCluster creating a cluster
|
||||
|
@ -258,8 +259,8 @@ func TestAuthenticationNoneCluster(t *testing.T) {
|
|||
|
||||
// Prepare deployment config
|
||||
depl := newDeployment("test-auth-none-cls-" + uniuri.NewLen(4))
|
||||
depl.Spec.Mode = api.DeploymentModeCluster
|
||||
depl.Spec.Authentication.JWTSecretName = api.JWTSecretNameDisabled
|
||||
depl.Spec.Mode = api.NewMode(api.DeploymentModeCluster)
|
||||
depl.Spec.Authentication.JWTSecretName = util.NewString(api.JWTSecretNameDisabled)
|
||||
depl.Spec.SetDefaults(depl.GetName())
|
||||
|
||||
// Create deployment
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
|
||||
"github.com/arangodb/kube-arangodb/pkg/client"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
)
|
||||
|
||||
|
@ -24,15 +25,15 @@ func TestRocksDBEncryptionSingle(t *testing.T) {
|
|||
|
||||
// Prepare deployment config
|
||||
depl := newDeployment("test-rocksdb-enc-sng-" + uniuri.NewLen(4))
|
||||
depl.Spec.Mode = api.DeploymentModeSingle
|
||||
depl.Spec.Image = image
|
||||
depl.Spec.StorageEngine = api.StorageEngineRocksDB
|
||||
depl.Spec.RocksDB.Encryption.KeySecretName = strings.ToLower(uniuri.New())
|
||||
depl.Spec.Mode = api.NewMode(api.DeploymentModeSingle)
|
||||
depl.Spec.Image = util.NewString(image)
|
||||
depl.Spec.StorageEngine = api.NewStorageEngine(api.StorageEngineRocksDB)
|
||||
depl.Spec.RocksDB.Encryption.KeySecretName = util.NewString(strings.ToLower(uniuri.New()))
|
||||
|
||||
// Create encryption key secret
|
||||
key := make([]byte, 32)
|
||||
rand.Read(key)
|
||||
if err := k8sutil.CreateEncryptionKeySecret(kubecli.CoreV1(), depl.Spec.RocksDB.Encryption.KeySecretName, ns, key); err != nil {
|
||||
if err := k8sutil.CreateEncryptionKeySecret(kubecli.CoreV1(), depl.Spec.RocksDB.Encryption.GetKeySecretName(), ns, key); err != nil {
|
||||
t.Fatalf("Create encryption key secret failed: %v", err)
|
||||
}
|
||||
|
||||
|
@ -59,5 +60,5 @@ func TestRocksDBEncryptionSingle(t *testing.T) {
|
|||
|
||||
// Cleanup
|
||||
removeDeployment(c, depl.GetName(), ns)
|
||||
removeSecret(kubecli, depl.Spec.RocksDB.Encryption.KeySecretName, ns)
|
||||
removeSecret(kubecli, depl.Spec.RocksDB.Encryption.GetKeySecretName(), ns)
|
||||
}
|
||||
|
|
|
@ -3,12 +3,14 @@ package tests
|
|||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/dchest/uniuri"
|
||||
|
||||
driver "github.com/arangodb/go-driver"
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
|
||||
"github.com/arangodb/kube-arangodb/pkg/client"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
)
|
||||
|
||||
// TestScaleCluster tests scaling up/down the number of DBServers & coordinators
|
||||
|
@ -21,8 +23,8 @@ func TestScaleClusterNonTLS(t *testing.T) {
|
|||
|
||||
// Prepare deployment config
|
||||
depl := newDeployment("test-scale-non-tls" + uniuri.NewLen(4))
|
||||
depl.Spec.Mode = api.DeploymentModeCluster
|
||||
depl.Spec.TLS = api.TLSSpec{"None", nil, 50}
|
||||
depl.Spec.Mode = api.NewMode(api.DeploymentModeCluster)
|
||||
depl.Spec.TLS = api.TLSSpec{util.NewString("None"), nil, util.NewDuration(time.Second * 50)}
|
||||
depl.Spec.SetDefaults(depl.GetName()) // this must be last
|
||||
|
||||
// Create deployment
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestSimpleSingle(t *testing.T) {
|
|||
|
||||
// Prepare deployment config
|
||||
depl := newDeployment("test-sng-" + uniuri.NewLen(4))
|
||||
depl.Spec.Mode = api.DeploymentModeSingle
|
||||
depl.Spec.Mode = api.NewMode(api.DeploymentModeSingle)
|
||||
|
||||
// Create deployment
|
||||
_, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl)
|
||||
|
@ -62,7 +62,7 @@ func TestSimpleResilientSingle(t *testing.T) {
|
|||
|
||||
// Prepare deployment config
|
||||
depl := newDeployment("test-rs-" + uniuri.NewLen(4))
|
||||
depl.Spec.Mode = api.DeploymentModeResilientSingle
|
||||
depl.Spec.Mode = api.NewMode(api.DeploymentModeResilientSingle)
|
||||
|
||||
// Create deployment
|
||||
_, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl)
|
||||
|
@ -103,7 +103,7 @@ func TestSimpleCluster(t *testing.T) {
|
|||
|
||||
// Prepare deployment config
|
||||
depl := newDeployment("test-cls-" + uniuri.NewLen(4))
|
||||
depl.Spec.Mode = api.DeploymentModeCluster
|
||||
depl.Spec.Mode = api.NewMode(api.DeploymentModeCluster)
|
||||
|
||||
// Create deployment
|
||||
_, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl)
|
||||
|
|
Loading…
Reference in a new issue