-
Notifications
You must be signed in to change notification settings - Fork 126
121 lines (104 loc) · 3.63 KB
/
events-e2e.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: E2E Events
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
jobs:
e2e-events:
runs-on: ubuntu-latest
defaults:
run:
working-directory: .
environment: Development
env:
DJANGO_SETTINGS_MODULE: "lotus.settings"
PYTHONPATH: "."
SECRET_KEY: "${{ secrets.SECRET_KEY }}"
STRIPE_LIVE_SECRET_KEY: "${{ secrets.STRIPE_LIVE_SECRET_KEY }}"
STRIPE_TEST_SECRET_KEY: "${{ secrets.STRIPE_TEST_SECRET_KEY }}"
DEBUG: False
PYTHONDONTWRITEBYTECODE: 1
SELF_HOSTED: "${{ secrets.SELF_HOSTED }}"
DOCKERIZED: True
POSTGRES_USER: lotus
POSTGRES_PASSWORD: lotus
POSTGRES_DB: lotus
KAFKA_URL: redpanda:29092
steps:
- uses: actions/checkout@v3
- name: start-all
run: |
sh -c "./scripts/dev.sh --no-webhooks --no-beat &"
- name: Wait for API to be ready
run: |
sleep 480s
for i in {1..200}; do
if curl -s -f http://localhost:8000/api/healthcheck/; then
export STARTUP_SUCCEEDED=true
break
else
export STARTUP_SUCCEEDED=false
fi
sleep 5s
done
if [[ "${STARTUP_SUCCEEDED}" == "true" ]]; then
echo "Startup succeeded"
else
echo "Startup failed"
exit 1
fi
- name: Install jq
run: sudo apt-get install -y jq
- name: get-api-key
run: |
OUTPUTS=$(docker-compose -f docker-compose.dev.yaml exec -T backend python manage.py postman_ci_outputs)
KEY=$(echo "$OUTPUTS" | grep "KEY=" | cut -d= -f2)
ENV_JSON=$(jq -n \
--arg key "$KEY" \
'{KEY: $key}')
echo "$ENV_JSON" > environment.json
echo "LOTUS_API_KEY=$KEY" >> $GITHUB_ENV
- name: track-events
run: |
response=$(curl -sw "\n%{http_code}" --location --request POST 'http://localhost:7998/api/track/' \
--header "X-API-KEY: $LOTUS_API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"batch":[
{
"customer_id": "rto",
"event_name":"boaaaby",
"idempotency_id": "16b6aa05-790c-42fc-bbdc-a41afa0f9d2e",
"properties":{
"shard_id": "2",
"shard_type": "professional",
"change": 5
},
"time_created":"'$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")'"
}
]
}')
response_body=$(echo "$response" | head -n -1)
status_code=$(echo "$response" | tail -n 1)
echo "Response body: $response_body"
echo "Status code: $status_code"
- name: verify event
run: |
sleep 10s
response=$(curl -sw "\n%{http_code}" --location --request POST 'http://localhost:8000/api/verify_idems_received/' \
--header "X-API-KEY: $LOTUS_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"idempotency_ids": ["16b6aa05-790c-42fc-bbdc-a41afa0f9d2e"]
}')
response_body=$(echo "$response" | head -n -1)
status_code=$(echo "$response" | tail -n 1)
echo "Response body: $response_body"
echo "Status code: $status_code"
if echo "${response}" | jq -e '.ids_not_found | index("16b6aa05-790c-42fc-bbdc-a41afa0f9d2e")' &> /dev/null; then
echo "Idempotency ID was not found"
exit 1
fi