diff --git a/apis/vshn/v1/dbaas_vshn_mariadb.go b/apis/vshn/v1/dbaas_vshn_mariadb.go index 489cb27c5..32c6df20a 100644 --- a/apis/vshn/v1/dbaas_vshn_mariadb.go +++ b/apis/vshn/v1/dbaas_vshn_mariadb.go @@ -95,10 +95,6 @@ type VSHNMariaDBServiceSpec struct { // +kubebuilder:default="standalone" // +kubebuilder:validation:Enum=replication;standalone - - // Mode configures the mode of MariaDB. - // Valid values are "replication" and "standalone". - Mode string `json:"mode,omitempty"` } // VSHNMariaDBTLSSpec contains settings to control tls traffic of a service. diff --git a/crds/vshn.appcat.vshn.io_vshnmariadbs.yaml b/crds/vshn.appcat.vshn.io_vshnmariadbs.yaml index 1745e3f55..537ae1844 100644 --- a/crds/vshn.appcat.vshn.io_vshnmariadbs.yaml +++ b/crds/vshn.appcat.vshn.io_vshnmariadbs.yaml @@ -102,13 +102,6 @@ spec: mariadbSettings: description: MariadbSettings contains additional MariaDB settings. type: string - mode: - default: standalone - description: Mode configures the mode of MariaDB. Valid values are "replication" and "standalone". - enum: - - replication - - standalone - type: string serviceLevel: default: besteffort description: ServiceLevel defines the service level of this service. Either Best Effort or Guaranteed Availability is allowed. diff --git a/crds/vshn.appcat.vshn.io_xvshnmariadbs.yaml b/crds/vshn.appcat.vshn.io_xvshnmariadbs.yaml index 83815cf29..8d5ee291b 100644 --- a/crds/vshn.appcat.vshn.io_xvshnmariadbs.yaml +++ b/crds/vshn.appcat.vshn.io_xvshnmariadbs.yaml @@ -157,14 +157,6 @@ spec: mariadbSettings: description: MariadbSettings contains additional MariaDB settings. type: string - mode: - default: standalone - description: Mode configures the mode of MariaDB. Valid values - are "replication" and "standalone". - enum: - - replication - - standalone - type: string serviceLevel: default: besteffort description: ServiceLevel defines the service level of this diff --git a/pkg/comp-functions/functions/vshnmariadb/mariadb_deploy_test.go b/pkg/comp-functions/functions/vshnmariadb/mariadb_deploy_test.go new file mode 100644 index 000000000..594e460cf --- /dev/null +++ b/pkg/comp-functions/functions/vshnmariadb/mariadb_deploy_test.go @@ -0,0 +1,52 @@ +package vshnmariadb + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + xhelmbeta1 "github.com/vshn/appcat/v4/apis/helm/release/v1beta1" + vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1" + "github.com/vshn/appcat/v4/pkg/comp-functions/functions/commontest" + "github.com/vshn/appcat/v4/pkg/comp-functions/runtime" + corev1 "k8s.io/api/core/v1" +) + +func TestMariadbDeploy(t *testing.T) { + + svc, comp := getMariadbComp(t) + + ctx := context.TODO() + + rootUser := "root" + rootPassword := "mariadb123" + mariadbHost := "mariadb-gc9x4.vshn-mariadb-mariadb-gc9x4.svc.cluster.local" + mariadbPort := "3306" + mariadbUrl := "mysql://mariadb-gc9x4.vshn-mariadb-mariadb-gc9x4.svc.cluster.local:3306" + + assert.Nil(t, DeployMariadb(ctx, svc)) + + ns := &corev1.Namespace{} + assert.NoError(t, svc.GetObservedKubeObject(ns, comp.Name+"-ns")) + + r := &xhelmbeta1.Release{} + assert.NoError(t, svc.GetObservedComposedResource(r, comp.Name+"-release")) + + cd := svc.GetConnectionDetails() + assert.Equal(t, mariadbHost, string(cd["MARIADB_HOST"])) + assert.Equal(t, mariadbPort, string(cd["MARIADB_PORT"])) + assert.Equal(t, mariadbUrl, string(cd["MARIADB_URL"])) + assert.Equal(t, rootUser, string(cd["MARIADB_USER"])) + assert.Equal(t, rootPassword, string(cd["MARIADB_PASSWORD"])) + +} + +func getMariadbComp(t *testing.T) (*runtime.ServiceRuntime, *vshnv1.VSHNMariaDB) { + svc := commontest.LoadRuntimeFromFile(t, "vshnmariadb/deploy/01_default.yaml") + + comp := &vshnv1.VSHNMariaDB{} + err := svc.GetObservedComposite(comp) + assert.NoError(t, err) + + return svc, comp +} diff --git a/test/functions/vshnmariadb/deploy/01_default.yaml b/test/functions/vshnmariadb/deploy/01_default.yaml new file mode 100644 index 000000000..f3a119bdc --- /dev/null +++ b/test/functions/vshnmariadb/deploy/01_default.yaml @@ -0,0 +1,90 @@ +desired: {} +input: + apiVersion: v1 + data: + defaultPlan: standard-1 + mariadbChartRepo: https://charts.bitnami.com/bitnami + mariadbChartVersion: 10.1.3 + plans: '{"standard-1": {"size": {"cpu": "250m", "disk": "16Gi", "enabled": true, + "memory": "1Gi"}}}' + providerEnabled: "true" + kind: ConfigMap + metadata: + annotations: {} + labels: + name: xfn-config + name: xfn-config +observed: + composite: + resource: + apiVersion: vshn.appcat.vshn.io/v1 + kind: XVSHNMariaDB + metadata: + annotations: null + creationTimestamp: "2023-03-21T16:52:31Z" + finalizers: + - composite.apiextensions.crossplane.io + generateName: mariadb- + generation: 13 + labels: + appuio.io/organization: vshn + crossplane.io/claim-name: mariadb + crossplane.io/claim-namespace: unit-test + crossplane.io/composite: mariadb-gc9x4 + name: mariadb-gc9x4 + spec: + claimRef: + apiVersion: vshn.appcat.vshn.io/v1 + kind: VSHNMariaDB + name: mariadb + namespace: unit-test + compositionRef: + name: vshnmariadb.vshn.appcat.vshn.io + compositionRevisionRef: + name: vshnmariadb.vshn.appcat.vshn.io-ce52f13 + compositionUpdatePolicy: Automatic + resources: + mariadb-gc9x4-ns: + resource: + apiVersion: v1 + kind: Object + metadata: + name: vshn-mariadb-mariadb-gc9x4 + spec: + forProvider: + manifest: + apiVersion: v1 + kind: Namespace + metadata: + name: vshn-mariadb-mariadb-gc9x4 + status: + atProvider: + manifest: + apiVersion: v1 + kind: Namespace + metadata: + name: vshn-mariadb-mariadb-gc9x4 + mariadb-gc9x4-release: + connection_details: + MARIADB_USER: cm9vdA== #root + MARIADB_PASSWORD: bWFyaWFkYjEyMw== #mariadb123 + resource: + apiVersion: helm.crossplane.io/v1beta1 + kind: Release + spec: + forProvider: + chart: + name: mariadb-galera + repository: https://charts.bitnami.com/bitnami + values: + fullnameOverride: mariadb + persistence: + size: 50Gi + replicasCount: 1 + resources: + limits: + cpu: 1 + memory: 1Gi + requests: + cpu: 1 + memory: 1Gi