Skip to content

Commit c0ff695

Browse files
tomaisthorpehansott
authored andcommitted
Fix assertion on osname
1 parent cafe753 commit c0ff695

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

end2end/e2e.sh

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ cleanup() {
8282
[[ -n "$APP_PID" ]] && kill_tree "$APP_PID"
8383
[[ -n "$APP_DISABLED_PID" ]] && kill_tree "$APP_DISABLED_PID"
8484
if [[ $exit_code -ne 0 ]]; then
85+
echo ""
86+
echo "=== mock-server.log ==="
87+
cat "$LOG_DIR/mock-server.log" 2>/dev/null || true
8588
echo ""
8689
echo "=== app.log ==="
8790
cat "$LOG_DIR/app.log" 2>/dev/null || true
@@ -138,24 +141,13 @@ wait_for_tcp() {
138141
exit 1
139142
}
140143

141-
# 1. Databases
142-
echo "Starting databases..."
143-
docker compose -f "$SCRIPT_DIR/sample-apps/databases/docker-compose.yml" up -d
144-
wait_for_tcp localhost 5432 "postgres"
145-
146-
# 2. Mock server
147-
echo "Starting mock Aikido server..."
148-
poetry run python3 "$SCRIPT_DIR/end2end/server/mock_aikido_core.py" 5000 > "$LOG_DIR/mock-server.log" 2>&1 &
149-
MOCK_PID=$!
150-
wait_for_port 5000 "mock-server" "$LOG_DIR/mock-server.log" "$MOCK_PID"
151-
152144
# Extract ports from the app's Makefile
153145
APP_PORT=$(grep -m1 "^PORT\s*=" "$APP_DIR/Makefile" | awk '{print $3}')
154146
APP_PORT_DISABLED=$(grep -m1 "^PORT_DISABLED\s*=" "$APP_DIR/Makefile" | awk '{print $3}')
155147
APP_PORT="${APP_PORT:-8080}"
156148
APP_PORT_DISABLED="${APP_PORT_DISABLED:-8081}"
157149

158-
# 3. Kill any lingering processes from previous runs
150+
# 1. Kill any lingering processes from previous runs
159151
AIKIDO_SOCK=$(AIKIDO_TOKEN="AIK_secret_token" poetry run python3 -c "
160152
import os; os.environ['AIKIDO_TOKEN']='AIK_secret_token'
161153
from aikido_zen.helpers.hash_aikido_token import hash_aikido_token
@@ -165,10 +157,21 @@ print(f'{get_temp_dir()}/aikido_python_{hash_aikido_token()}.sock')
165157
if [[ -n "$AIKIDO_SOCK" ]]; then
166158
rm -f "$AIKIDO_SOCK"
167159
fi
168-
for port in "$APP_PORT" "$APP_PORT_DISABLED"; do
160+
for port in 5000 "$APP_PORT" "$APP_PORT_DISABLED"; do
169161
lsof -ti :"$port" 2>/dev/null | xargs kill -9 2>/dev/null || true
170162
done
171163

164+
# 2. Databases
165+
echo "Starting databases..."
166+
docker compose -f "$SCRIPT_DIR/sample-apps/databases/docker-compose.yml" up -d
167+
wait_for_tcp localhost 5432 "postgres"
168+
169+
# 3. Mock server
170+
echo "Starting mock Aikido server..."
171+
poetry run python3 "$SCRIPT_DIR/end2end/server/mock_aikido_core.py" 5000 > "$LOG_DIR/mock-server.log" 2>&1 &
172+
MOCK_PID=$!
173+
wait_for_port 5000 "mock-server" "$LOG_DIR/mock-server.log" "$MOCK_PID"
174+
172175
# 4. Install sample app deps
173176
echo "Installing $APP dependencies..."
174177
cd "$SCRIPT_DIR/$APP_DIR"

end2end/server/check_events_from_mock.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import platform
12
import requests
23
import json
34

@@ -16,13 +17,12 @@ def clear_events_from_mock(url):
1617
def filter_on_event_type(events, type):
1718
return [event for event in events if event["type"] == type]
1819

19-
def validate_started_event(event, stack, dry_mode=False, serverless=False, os_name=None, platform="CPython"):
20+
def validate_started_event(event, stack, dry_mode=False, serverless=False, os_name=platform.system(), platform_name="CPython"):
2021
assert event["agent"]["dryMode"] == dry_mode
2122
assert event["agent"]["library"] == "firewall-python"
2223
assert event["agent"]["nodeEnv"] == ""
23-
if os_name is not None:
24-
assert event["agent"]["os"]["name"] == os_name
25-
assert event["agent"]["platform"]["name"] == platform
24+
assert event["agent"]["os"]["name"] == os_name
25+
assert event["agent"]["platform"]["name"] == platform_name
2626
assert event["agent"]["serverless"] == serverless
2727
# # Check for packages is disabled until we start using them in core :
2828
# if stack is not None:

0 commit comments

Comments
 (0)