Skip to content

Commit

Permalink
use shell file
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantanjunming committed Nov 18, 2024
1 parent f7ba628 commit 7c00449
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/otel-integration-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,9 @@ jobs:
- name: Get and set Kind Host Endpoint
shell: bash
run: |
docker network inspect kind
if [[ "$(uname)" == "Darwin" ]]; then
HOSTENDPOINT="host.docker.internal"
else
set +e # Disable exit on error temporarily
HOSTENDPOINT=$(docker network inspect kind | grep -A 5 '"Config": \[' | grep '"Gateway":' | grep -Eo '"Gateway": "[0-9.]+"' | grep -Eo '[0-9.]+')
set -e # Re-enable exit on error
if [[ -z "$HOSTENDPOINT" ]]; then
echo "Failed to find host endpoint via docker network inspect"
fi
fi
# Set the HOSTENDPOINT environment variable for GitHub Actions
echo "HOSTENDPOINT=$HOSTENDPOINT" >> $GITHUB_ENV
echo "HOSTENDPOINT is set to $HOSTENDPOINT"
cd ./otel-integration/k8s-helm/e2e-test/testcommon
chmod +x ./get_host_endpoint.sh
./get_host_endpoint.sh
- name: Setup Secret
run: kubectl create secret generic coralogix-keys --from-literal=PRIVATE_KEY=123
- name: Install chart & telemetrygen for testing
Expand All @@ -58,7 +47,6 @@ jobs:
-f ./values.yaml \
-f ./e2e-test/testdata/values-e2e-test.yaml
kubectl wait --all --for=condition=ready --timeout=300s pod -l component=agent-collector
- name: Run E2E test
env:
HOSTENDPOINT: ${{ env.HOSTENDPOINT }}
Expand Down
23 changes: 23 additions & 0 deletions otel-integration/k8s-helm/e2e-test/testcommon/get_host_endpoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

function get_host_endpoint() {
if [[ "$(uname)" == "Darwin" ]]; then
HOSTENDPOINT="host.docker.internal"
else
# Use jq to parse the JSON and extract the IPv4 Gateway
HOSTENDPOINT=$(docker network inspect kind \
| jq -r '.[0].IPAM.Config[] | select(.Gateway != null) | select(.Gateway | test("^[0-9]+\.")) | .Gateway' \
| head -n 1)

if [[ -z "$HOSTENDPOINT" ]]; then
echo "Failed to find host endpoint via docker network inspect"
exit 1
fi
fi

# Export HOSTENDPOINT for GitHub Actions
echo "HOSTENDPOINT=$HOSTENDPOINT" >> $GITHUB_ENV
echo "HOSTENDPOINT is set to $HOSTENDPOINT"
}

get_host_endpoint

0 comments on commit 7c00449

Please sign in to comment.