From c9708d4bcbc14bbacf19a948603c3b8b947f7806 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Wed, 20 Nov 2024 12:38:47 +0100 Subject: [PATCH] e2e limits_file_watcher_on_docker Signed-off-by: Eguzki Astiz Lezaun --- .github/workflows/e2e.yaml | 49 ++++++++++++++++++- .../docker-compose-limitador-memory.yaml | 5 +- output-limits.json | 1 + 3 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 output-limits.json diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 0daa08b5..a00cd5e7 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -67,7 +67,7 @@ jobs: command: | ip=$(kubectl get nodes -lkubernetes.io/hostname!=kind-control-plane -ojsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}') port=$(kubectl get service limitador -o jsonpath='{.spec.ports[?(@.name=="http")].nodePort}') - curl -s "http://${ip}:${port}/limits/test" | tee output-limits.json + curl -s "http://${ip}:${port}/limits/test" | tee output-limits.json jq --exit-status '.[] | select(.max_value == 1000)' output-limits.json - name: Update limit in the configmap run: | @@ -87,5 +87,50 @@ jobs: command: | ip=$(kubectl get nodes -lkubernetes.io/hostname!=kind-control-plane -ojsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}') port=$(kubectl get service limitador -o jsonpath='{.spec.ports[?(@.name=="http")].nodePort}') - curl -s "http://${ip}:${port}/limits/test" | tee output-limits-new.json + curl -s "http://${ip}:${port}/limits/test" | tee output-limits-new.json jq --exit-status '.[] | select(.max_value == 2000)' output-limits-new.json + limits_file_watcher_on_docker: + name: Limits File Watcher in docker environment + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Run docker compose + run: | + docker compose -f ./limitador-server/sandbox/docker-compose-limitador-memory.yaml up -d + - name: Wait for limitador availability + uses: nick-fields/retry@v2 + with: + timeout_seconds: 10 + max_attempts: 10 + command: | + curl --fail -s "http://127.0.0.1:18080/status" + - name: Read limits from HTTP endpoint + uses: nick-fields/retry@v2 + with: + timeout_seconds: 10 + max_attempts: 10 + command: | + curl -s "http://127.0.0.1:18080/limits/test_namespace" | tee output-limits.json + NUM_LIMITS=$(jq --exit-status 'length' output-limits.json) && test ${NUM_LIMITS} -eq 3 + - name: Update limits + run: | + cat <> ./limitador-server/sandbox/limits.yaml + - namespace: other_namespace + max_value: 1 + seconds: 10 + conditions: + - "a == '1'" + variables: [] + EOF + - name: Read new limits from HTTP endpoint + uses: nick-fields/retry@v2 + with: + timeout_seconds: 10 + max_attempts: 10 + retry_wait_seconds: 30 + command: | + curl -s "http://127.0.0.1:18080/limits/other_namespace" | tee other-limits.json + NUM_LIMITS=$(jq --exit-status 'length' other-limits.json) && test ${NUM_LIMITS} -eq 1 diff --git a/limitador-server/sandbox/docker-compose-limitador-memory.yaml b/limitador-server/sandbox/docker-compose-limitador-memory.yaml index 133d7ffa..76288fc4 100644 --- a/limitador-server/sandbox/docker-compose-limitador-memory.yaml +++ b/limitador-server/sandbox/docker-compose-limitador-memory.yaml @@ -1,5 +1,4 @@ --- -version: '3.8' services: limitador: image: ${LIMITADOR_IMAGE:-limitador-testing} @@ -27,4 +26,6 @@ services: - "18080:8080" - "18081:8081" volumes: - - ./limits.yaml:/opt/kuadrant/limits/limits.yaml + # the entire path needs to be mounted + # or inotify events are not triggered for updates on the mounted file + - ./:/opt/kuadrant/limits diff --git a/output-limits.json b/output-limits.json new file mode 100644 index 00000000..33507e06 --- /dev/null +++ b/output-limits.json @@ -0,0 +1 @@ +[{"id":null,"namespace":"test_namespace","max_value":50000,"seconds":10,"name":null,"conditions":["req.method == \"GET\"","req.path == \"/json\""],"variables":[]},{"id":null,"namespace":"test_namespace","max_value":5,"seconds":60,"name":null,"conditions":["req.method == \"POST\"","req.path != \"/json\""],"variables":[]},{"id":null,"namespace":"test_namespace","max_value":10,"seconds":60,"name":null,"conditions":["req.method == \"GET\"","req.path != \"/json\""],"variables":[]}] \ No newline at end of file