From c5612c43e3ddf6327bb3252727628db1c496ea3c Mon Sep 17 00:00:00 2001 From: Pete Savage Date: Fri, 10 Jun 2022 09:40:37 +0100 Subject: [PATCH] Fixed logging type --- .../test-log-app-interface/00-install.yaml | 8 +++ .../test-log-app-interface/01-assert.yaml | 13 ++++ .../kuttl/test-log-app-interface/01-pods.yaml | 66 +++++++++++++++++++ .../02-json-asserts.yaml | 10 +++ .../test-log-app-interface/03-delete.yaml | 13 ++++ .../kuttl/test-log-none/00-install.yaml | 8 +++ .../kuttl/test-log-none/01-assert.yaml | 13 ++++ .../kuttl/test-log-none/01-pods.yaml | 66 +++++++++++++++++++ .../kuttl/test-log-none/02-json-asserts.yaml | 9 +++ .../kuttl/test-log-none/03-delete.yaml | 13 ++++ .../providers/logging/appinterface.go | 1 + 11 files changed, 220 insertions(+) create mode 100644 bundle/tests/scorecard/kuttl/test-log-app-interface/00-install.yaml create mode 100644 bundle/tests/scorecard/kuttl/test-log-app-interface/01-assert.yaml create mode 100644 bundle/tests/scorecard/kuttl/test-log-app-interface/01-pods.yaml create mode 100644 bundle/tests/scorecard/kuttl/test-log-app-interface/02-json-asserts.yaml create mode 100644 bundle/tests/scorecard/kuttl/test-log-app-interface/03-delete.yaml create mode 100644 bundle/tests/scorecard/kuttl/test-log-none/00-install.yaml create mode 100644 bundle/tests/scorecard/kuttl/test-log-none/01-assert.yaml create mode 100644 bundle/tests/scorecard/kuttl/test-log-none/01-pods.yaml create mode 100644 bundle/tests/scorecard/kuttl/test-log-none/02-json-asserts.yaml create mode 100644 bundle/tests/scorecard/kuttl/test-log-none/03-delete.yaml diff --git a/bundle/tests/scorecard/kuttl/test-log-app-interface/00-install.yaml b/bundle/tests/scorecard/kuttl/test-log-app-interface/00-install.yaml new file mode 100644 index 000000000..60ce77a7d --- /dev/null +++ b/bundle/tests/scorecard/kuttl/test-log-app-interface/00-install.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: test-log-app-interface +spec: + finalizers: + - kubernetes diff --git a/bundle/tests/scorecard/kuttl/test-log-app-interface/01-assert.yaml b/bundle/tests/scorecard/kuttl/test-log-app-interface/01-assert.yaml new file mode 100644 index 000000000..6b444e956 --- /dev/null +++ b/bundle/tests/scorecard/kuttl/test-log-app-interface/01-assert.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + name: puptoo + namespace: test-log-app-interface + labels: + app: puptoo + ownerReferences: + - apiVersion: cloud.redhat.com/v1alpha1 + kind: ClowdApp + name: puptoo +type: Opaque diff --git a/bundle/tests/scorecard/kuttl/test-log-app-interface/01-pods.yaml b/bundle/tests/scorecard/kuttl/test-log-app-interface/01-pods.yaml new file mode 100644 index 000000000..47938da5a --- /dev/null +++ b/bundle/tests/scorecard/kuttl/test-log-app-interface/01-pods.yaml @@ -0,0 +1,66 @@ +--- +apiVersion: cloud.redhat.com/v1alpha1 +kind: ClowdEnvironment +metadata: + name: test-log-app-interface +spec: + targetNamespace: test-log-app-interface + providers: + web: + port: 8000 + mode: operator + metrics: + port: 9000 + mode: operator + path: "/metrics" + kafka: + mode: none + db: + mode: none + logging: + mode: app-interface + objectStore: + mode: none + inMemoryDb: + mode: none + resourceDefaults: + limits: + cpu: 400m + memory: 1024Mi + requests: + cpu: 30m + memory: 512Mi +--- +apiVersion: cloud.redhat.com/v1alpha1 +kind: ClowdApp +metadata: + name: puptoo + namespace: test-log-app-interface +spec: + envName: test-log-app-interface + deployments: + - name: processor + podSpec: + image: quay.io/psav/clowder-hello + env: + - name: ENV_VAR_1 + value: env_var_1 + - name: ENV_VAR_2 + value: env_var_2 + webServices: + public: + enabled: true + private: + enabled: true +--- +apiVersion: v1 +data: + aws_access_key_id: YXdzX2FjY2Vzc19rZXk= + aws_region: dXMtZWFzdA== + aws_secret_access_key: YXdzX3NlY3JldF9rZXk= + log_group_name: dGVzdC1hcHAtaW50ZXJmYWNlLXMz +kind: Secret +metadata: + name: cloudwatch + namespace: test-log-app-interface +type: Opaque diff --git a/bundle/tests/scorecard/kuttl/test-log-app-interface/02-json-asserts.yaml b/bundle/tests/scorecard/kuttl/test-log-app-interface/02-json-asserts.yaml new file mode 100644 index 000000000..ab6c673ee --- /dev/null +++ b/bundle/tests/scorecard/kuttl/test-log-app-interface/02-json-asserts.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +- script: sleep 5 +- script: kubectl get secret --namespace=test-log-app-interface puptoo -o json > /tmp/test-log-app-interface +- script: jq -r '.data["cdappconfig.json"]' < /tmp/test-log-app-interface | base64 -d > /tmp/test-log-app-interface-json + +- script: jq -r '.logging.type == "cloudwatch"' -e < /tmp/test-log-app-interface-json +- script: jq -r '.logging.type == "us-east"' -e < /tmp/test-log-app-interface-json diff --git a/bundle/tests/scorecard/kuttl/test-log-app-interface/03-delete.yaml b/bundle/tests/scorecard/kuttl/test-log-app-interface/03-delete.yaml new file mode 100644 index 000000000..e8d8b66dd --- /dev/null +++ b/bundle/tests/scorecard/kuttl/test-log-app-interface/03-delete.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +delete: +- apiVersion: v1 + kind: Namespace + name: test-log-app-interface +- apiVersion: cloud.redhat.com/v1alpha1 + kind: ClowdEnvironment + name: test-log-app-interface +- apiVersion: v1 + kind: Namespace + name: test-log-app-interface-secret diff --git a/bundle/tests/scorecard/kuttl/test-log-none/00-install.yaml b/bundle/tests/scorecard/kuttl/test-log-none/00-install.yaml new file mode 100644 index 000000000..4be740f06 --- /dev/null +++ b/bundle/tests/scorecard/kuttl/test-log-none/00-install.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: test-log-none +spec: + finalizers: + - kubernetes diff --git a/bundle/tests/scorecard/kuttl/test-log-none/01-assert.yaml b/bundle/tests/scorecard/kuttl/test-log-none/01-assert.yaml new file mode 100644 index 000000000..c07b6f1e6 --- /dev/null +++ b/bundle/tests/scorecard/kuttl/test-log-none/01-assert.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + name: puptoo + namespace: test-log-none + labels: + app: puptoo + ownerReferences: + - apiVersion: cloud.redhat.com/v1alpha1 + kind: ClowdApp + name: puptoo +type: Opaque diff --git a/bundle/tests/scorecard/kuttl/test-log-none/01-pods.yaml b/bundle/tests/scorecard/kuttl/test-log-none/01-pods.yaml new file mode 100644 index 000000000..c40998b41 --- /dev/null +++ b/bundle/tests/scorecard/kuttl/test-log-none/01-pods.yaml @@ -0,0 +1,66 @@ +--- +apiVersion: cloud.redhat.com/v1alpha1 +kind: ClowdEnvironment +metadata: + name: test-log-none +spec: + targetNamespace: test-log-none + providers: + web: + port: 8000 + mode: operator + metrics: + port: 9000 + mode: operator + path: "/metrics" + kafka: + mode: none + db: + mode: none + logging: + mode: none + objectStore: + mode: none + inMemoryDb: + mode: none + resourceDefaults: + limits: + cpu: 400m + memory: 1024Mi + requests: + cpu: 30m + memory: 512Mi +--- +apiVersion: cloud.redhat.com/v1alpha1 +kind: ClowdApp +metadata: + name: puptoo + namespace: test-log-none +spec: + envName: test-log-none + deployments: + - name: processor + podSpec: + image: quay.io/psav/clowder-hello + env: + - name: ENV_VAR_1 + value: env_var_1 + - name: ENV_VAR_2 + value: env_var_2 + webServices: + public: + enabled: true + private: + enabled: true +--- +apiVersion: v1 +data: + aws_access_key_id: YXdzX2FjY2Vzc19rZXk= + aws_region: dXMtZWFzdA== + aws_secret_access_key: YXdzX3NlY3JldF9rZXk= + log_group_name: dGVzdC1hcHAtaW50ZXJmYWNlLXMz +kind: Secret +metadata: + name: cloudwatch + namespace: test-log-none +type: Opaque diff --git a/bundle/tests/scorecard/kuttl/test-log-none/02-json-asserts.yaml b/bundle/tests/scorecard/kuttl/test-log-none/02-json-asserts.yaml new file mode 100644 index 000000000..51c1827a0 --- /dev/null +++ b/bundle/tests/scorecard/kuttl/test-log-none/02-json-asserts.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +- script: sleep 5 +- script: kubectl get secret --namespace=test-log-none puptoo -o json > /tmp/test-log-none +- script: jq -r '.data["cdappconfig.json"]' < /tmp/test-log-none | base64 -d > /tmp/test-log-none-json + +- script: jq -r '.logging.type == "null"' -e < /tmp/test-log-none-json diff --git a/bundle/tests/scorecard/kuttl/test-log-none/03-delete.yaml b/bundle/tests/scorecard/kuttl/test-log-none/03-delete.yaml new file mode 100644 index 000000000..567d49329 --- /dev/null +++ b/bundle/tests/scorecard/kuttl/test-log-none/03-delete.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +delete: +- apiVersion: v1 + kind: Namespace + name: test-log-none +- apiVersion: cloud.redhat.com/v1alpha1 + kind: ClowdEnvironment + name: test-log-none +- apiVersion: v1 + kind: Namespace + name: test-log-none-secret diff --git a/controllers/cloud.redhat.com/providers/logging/appinterface.go b/controllers/cloud.redhat.com/providers/logging/appinterface.go index 6d271443f..b6c79ed63 100644 --- a/controllers/cloud.redhat.com/providers/logging/appinterface.go +++ b/controllers/cloud.redhat.com/providers/logging/appinterface.go @@ -47,6 +47,7 @@ func setCloudwatchSecret(ns string, p *providers.Provider, c *config.LoggingConf Region: string(secret.Data["aws_region"]), LogGroup: string(secret.Data["log_group_name"]), } + c.Type = "cloudwatch" return nil }