Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x](backport #2649) azure: add integration tests cases #2652

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Oct 31, 2024

Summary of your changes

adds test cases for: project, cloud-run service, iam role, bucket and firewall

remaining test cases:

  • org: we don't have a suitable org account for CI tests yet
  • gke cluster: going to figure out costs before enabling this
  • cloud function: API not enabled for our account, need to discuss this.

Related Issues


for future reference - script to quickly run gcp integration tests locally
#!/bin/bash

echo 'Start ES'
docker run -d \
    --name es2 \
    -e "discovery.type=single-node" \
    -e "xpack.security.enabled=false" \
    -e "xpack.security.http.ssl.enabled=false" \
    -p 9200:9200 \
    docker.elastic.co/elasticsearch/elasticsearch:8.15.0

sleep 10

export ES_HOST=http://localhost:9200
export ES_USERNAME=elastic
export ES_PASSWORD=changeme
export GCP_PROJECT_ID=elastic-security-test
export GCP_CREDENTIALS_JSON=STRINGIFIED_JSON_DATA
export GCP_ACCOUNT_TYPE=single-account

echo 'Start cloudbeat'
./cloudbeat -c deploy/asset-inventory/cloudbeat-gcp-asset-inventory.yml -d '*' &

URL="http://localhost:9200/.ds-logs-cloud_asset_inventory.asset_inventory-*/_search?size=0"
HEADER="Content-Type: application/json"

MAX_RETRIES=1000

for ((i = 1; i <= MAX_RETRIES; i++)); do
    result=$(curl -s -X GET "$URL" -H "$HEADER" | jq '.hits.total.value')

    if [ "$result" -gt 0 ]; then
        echo "Result is greater than 0: $result"
        break
    fi

    echo "Result is 0, retrying in 1 second... ($i/$MAX_RETRIES)"
    sleep 1
done


if [ "$i" -gt "$MAX_RETRIES" ]; then
    echo "Max retries reached. Result is still 0."
else
    export USE_K8S=false
    export ES_HOST=localhost
    export ES_PORT=9200
    export ES_USER=elastic
    export ES_PASSWORD=changeme
    export ES_SSL=false
    export ES_PROTOCOL=http

    cd tests
    poetry run pytest -k "asset_inventory_gcp" --alluredir=./allure/results/ --clean-alluredir

fi

docker stop es2
docker rm es2
pkill -f cloudbeat

This is an automatic backport of pull request #2649 done by [Mergify](https://mergify.com).

@mergify mergify bot added the backport label Oct 31, 2024
@mergify mergify bot requested a review from a team as a code owner October 31, 2024 11:42
@mergify mergify bot assigned orouz Oct 31, 2024
Copy link
Author

mergify bot commented Nov 4, 2024

This pull request has not been merged yet. Could you please review and merge it @orouz? 🙏

@romulets romulets enabled auto-merge (squash) November 5, 2024 13:53
@romulets romulets merged commit d81d4f7 into 8.x Nov 5, 2024
11 checks passed
@romulets romulets deleted the mergify/bp/8.x/pr-2649 branch November 5, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants