diff --git a/.github/workflows/master.yaml b/.github/workflows/master.yaml index d070463..636f621 100644 --- a/.github/workflows/master.yaml +++ b/.github/workflows/master.yaml @@ -16,13 +16,13 @@ jobs: - uses: actions/checkout@v2 - uses: azure/setup-helm@v1 with: - version: "3.3.4" + version: "3.19.0" - name: helm lint run: | jq --version ./test/linter/test.sh - name: start k8s with k3d - uses: AbsaOSS/k3d-action@v1.4.0 + uses: AbsaOSS/k3d-action@v2.4.0 with: cluster-name: "opal" use-default-registry: false diff --git a/templates/deployment-client.yaml b/templates/deployment-client.yaml index 2129e30..5c620c3 100644 --- a/templates/deployment-client.yaml +++ b/templates/deployment-client.yaml @@ -66,7 +66,7 @@ spec: - name: OPAL_SERVER_URL value: {{ printf "http://%s:%v" (include "opal.serverName" .) .Values.server.port | quote }} {{- end}} - {{- if not (or (.Values.server.dataConfigSources.external_source_url) (.Values.server.dataConfigSources.config) (hasKey .Values.client.extraEnv "OPAL_DATA_UPDATER_ENABLED") ) }} + {{- if not (or (.Values.server.dataConfigSources.external_source_url) (and .Values.server.dataConfigSources.config .Values.server.dataConfigSources.config.entries) (hasKey .Values.client.extraEnv "OPAL_DATA_UPDATER_ENABLED") ) }} - name: OPAL_DATA_UPDATER_ENABLED value: "False" {{- end }} diff --git a/templates/deployment-server.yaml b/templates/deployment-server.yaml index 0ad9e6b..f731688 100644 --- a/templates/deployment-server.yaml +++ b/templates/deployment-server.yaml @@ -124,7 +124,7 @@ spec: {{- end }} - name: UVICORN_NUM_WORKERS value: {{ .Values.server.uvicornWorkers | quote }} - {{- if or .Values.server.dataConfigSources.config .Values.server.dataConfigSources.external_source_url }} + {{- if or .Values.server.dataConfigSources.external_source_url (and .Values.server.dataConfigSources.config .Values.server.dataConfigSources.config.entries) }} - name: OPAL_DATA_CONFIG_SOURCES value: {{ .Values.server.dataConfigSources | toRawJson | squote }} {{- end}} diff --git a/test/e2e/deploy.sh b/test/e2e/deploy.sh index b173503..353e6f6 100755 --- a/test/e2e/deploy.sh +++ b/test/e2e/deploy.sh @@ -13,4 +13,4 @@ else --set server.policyRepoUrl='//opt/e2e/policy-repo.git' fi -kubectl logs -n opal service/myopal-server git-init +kubectl logs -n opal service/myopal-opal-server git-init diff --git a/test/e2e/k3d.yaml b/test/e2e/k3d.yaml index f055a3f..4e6513c 100644 --- a/test/e2e/k3d.yaml +++ b/test/e2e/k3d.yaml @@ -1,11 +1,20 @@ -apiVersion: k3d.io/v1alpha2 +apiVersion: k3d.io/v1alpha4 kind: Simple -name: k3d -image: rancher/k3s:v1.18.18-k3s1 +metadata: + name: k3d +image: rancher/k3s:v1.28.8-k3s1 options: k3d: wait: true disableLoadbalancer: true k3s: - extraServerArgs: - - "--disable=metrics-server,servicelb,traefik" + extraArgs: + - arg: --disable=metrics-server + nodeFilters: + - server:* + - arg: --disable=servicelb + nodeFilters: + - server:* + - arg: --disable=traefik + nodeFilters: + - server:* diff --git a/test/e2e/test.sh b/test/e2e/test.sh index d57a797..cfc2413 100755 --- a/test/e2e/test.sh +++ b/test/e2e/test.sh @@ -5,15 +5,28 @@ set -e helm test -n opal --logs myopal -DATA_URL='http://localhost:8181/v1/data' +DATA_URL="http://myopal-opal-client:8181/v1/data" -[ $(kubectl exec -n opal service/myopal-client -- curl -s ${DATA_URL}/users) != "{}" ] +# Check that users data is present initially +RESULT=$(kubectl run -n opal curl-test --image=curlimages/curl:latest --rm -i --restart=Never -- curl -s ${DATA_URL}/users 2>&1 | grep -v "pod.*deleted") +echo "Initial users: $RESULT" +echo "$RESULT" | grep -q '"result"' + +# Run the update script if [ -z $MSYSTEM ]; then - kubectl exec -n opal service/myopal-server -- /opt/e2e/policy-repo-data/upd.sh + kubectl exec -n opal service/myopal-opal-server -- /opt/e2e/policy-repo-data/upd.sh else - kubectl exec -n opal service/myopal-server -- //opt/e2e/policy-repo-data/upd.sh + kubectl exec -n opal service/myopal-opal-server -- //opt/e2e/policy-repo-data/upd.sh fi sleep 7 -[ $(kubectl exec -n opal service/myopal-client -- curl -s ${DATA_URL}/users) == "{}" ] -[ $(kubectl exec -n opal service/myopal-client -- curl -s ${DATA_URL}/losers) != "{}" ] + +# Check that users data is empty after update (OPA returns {} when data is empty) +RESULT=$(kubectl run -n opal curl-test --image=curlimages/curl:latest --rm -i --restart=Never -- curl -s ${DATA_URL}/users 2>&1 | grep -v "pod.*deleted") +echo "After update users: $RESULT" +[ "$RESULT" == '{}' ] + +# Check that losers data is present +RESULT=$(kubectl run -n opal curl-test --image=curlimages/curl:latest --rm -i --restart=Never -- curl -s ${DATA_URL}/losers 2>&1 | grep -v "pod.*deleted") +echo "Losers data: $RESULT" +echo "$RESULT" | grep -q '"result"'