tebakaja commited on
Commit
5067be6
1 Parent(s): 99b253c

feat: Add Unit Testing and Integration Testing Configuration

Browse files
.github/workflows/{proxy_deployments.yaml → proxy_deployment.yaml} RENAMED
@@ -7,11 +7,29 @@ on:
7
  tags:
8
  - '*'
9
 
10
- jobs:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  tebakaja_proxy_space-0:
12
  name: Proxy-0 Deployment
13
  runs-on: ubuntu-latest
14
- environment: Production
15
 
16
  env:
17
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
@@ -49,10 +67,12 @@ jobs:
49
  run: |
50
  git push https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main --force
51
 
 
 
52
  tebakaja_proxy_space-1:
53
  name: Proxy-1 Deployment
54
  runs-on: ubuntu-latest
55
- environment: Production
56
 
57
  env:
58
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
@@ -91,10 +111,11 @@ jobs:
91
  git push https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main --force
92
 
93
 
 
94
  tebakaja_proxy_space-2:
95
  name: Proxy-2 Deployment
96
  runs-on: ubuntu-latest
97
- environment: Production
98
 
99
  env:
100
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
@@ -131,3 +152,29 @@ jobs:
131
  - name: Push to Hugging Face
132
  run: |
133
  git push https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main --force
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  tags:
8
  - '*'
9
 
10
+ jobs:
11
+ # Unit Testing
12
+ unit_testing:
13
+ name: Integration Testing
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: Set global directory
18
+ run: git config --global --add safe.directory /github/workspace
19
+
20
+ - uses: actions/checkout@v3
21
+ with:
22
+ persist-credentials: false
23
+ fetch-depth: 1
24
+
25
+ - name: unit testing
26
+ run: echo "testing"
27
+
28
+ # TebakAja Proxy-0
29
  tebakaja_proxy_space-0:
30
  name: Proxy-0 Deployment
31
  runs-on: ubuntu-latest
32
+ needs: unit_testing
33
 
34
  env:
35
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
 
67
  run: |
68
  git push https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main --force
69
 
70
+
71
+ # TebakAja Proxy-1
72
  tebakaja_proxy_space-1:
73
  name: Proxy-1 Deployment
74
  runs-on: ubuntu-latest
75
+ needs: unit_testing
76
 
77
  env:
78
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
 
111
  git push https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main --force
112
 
113
 
114
+ # TebakAja Proxy-2
115
  tebakaja_proxy_space-2:
116
  name: Proxy-2 Deployment
117
  runs-on: ubuntu-latest
118
+ needs: unit_testing
119
 
120
  env:
121
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
 
152
  - name: Push to Hugging Face
153
  run: |
154
  git push https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main --force
155
+
156
+
157
+ # Integration Testing
158
+ integration_testing:
159
+ name: Integration Testing
160
+ runs-on: ubuntu-latest
161
+ environment: Production
162
+
163
+ needs:
164
+ - tebakaja_proxy_space-0
165
+ - tebakaja_proxy_space-1
166
+ - tebakaja_proxy_space-2
167
+
168
+ steps:
169
+ - name: Set global directory
170
+ run: git config --global --add safe.directory /github/workspace
171
+
172
+ - uses: actions/checkout@v3
173
+ with:
174
+ persist-credentials: false
175
+ fetch-depth: 1
176
+
177
+ - name: Testing Proxy Endpoints
178
+ run: |
179
+ sleep 20
180
+ chmod +x endpoints_test.sh && ./endpoints_test.sh
endpoints_test.sh CHANGED
@@ -3,6 +3,7 @@ PROD_ENDPOINT_0="https://qywok-tebakaja-proxy-space-0.hf.space"
3
  PROD_ENDPOINT_1="https://qywok-tebakaja-proxy-space-1.hf.space"
4
  PROD_ENDPOINT_2="https://qywok-tebakaja-proxy-space-2.hf.space"
5
 
 
6
  check_status() {
7
  if [ $1 -eq 200 ]; then
8
  echo "[ Success ] $2 (latency: $3 ms)"
@@ -11,7 +12,7 @@ check_status() {
11
  fi
12
  }
13
 
14
- # GET Request
15
  make_get_request() {
16
  START_TIME=$(date +%s%3N)
17
  RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X GET $1)
@@ -20,7 +21,7 @@ make_get_request() {
20
  check_status $RESPONSE $2 $DURATION
21
  }
22
 
23
- # POST Request
24
  make_post_request() {
25
  START_TIME=$(date +%s%3N)
26
  RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X POST $1 \
@@ -31,6 +32,7 @@ make_post_request() {
31
  check_status $RESPONSE $3 $DURATION
32
  }
33
 
 
34
  echo "-------- [ Proxy 0 ] --------"
35
  make_get_request "$PROD_ENDPOINT_0/stock/lists" "stock-list-prod-0"
36
  make_post_request "$PROD_ENDPOINT_0/stock/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "stock-prediction-prod-0"
@@ -40,6 +42,7 @@ make_get_request "$PROD_ENDPOINT_0/national-currency/lists" "natcurr-list-prod-0
40
  make_post_request "$PROD_ENDPOINT_0/national-currency/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "natcurr-prediction-prod-0"
41
  echo " "
42
 
 
43
  echo "-------- [ Proxy 1 ] --------"
44
  make_get_request "$PROD_ENDPOINT_1/stock/lists" "stock-list-prod-1"
45
  make_post_request "$PROD_ENDPOINT_1/stock/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "stock-prediction-prod-1"
@@ -49,6 +52,7 @@ make_get_request "$PROD_ENDPOINT_1/national-currency/lists" "natcurr-list-prod-1
49
  make_post_request "$PROD_ENDPOINT_1/national-currency/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "natcurr-prediction-prod-1"
50
  echo " "
51
 
 
52
  echo "-------- [ Proxy 2 ] --------"
53
  make_get_request "$PROD_ENDPOINT_2/stock/lists" "stock-list-prod-2"
54
  make_post_request "$PROD_ENDPOINT_2/stock/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "stock-prediction-prod-2"
 
3
  PROD_ENDPOINT_1="https://qywok-tebakaja-proxy-space-1.hf.space"
4
  PROD_ENDPOINT_2="https://qywok-tebakaja-proxy-space-2.hf.space"
5
 
6
+
7
  check_status() {
8
  if [ $1 -eq 200 ]; then
9
  echo "[ Success ] $2 (latency: $3 ms)"
 
12
  fi
13
  }
14
 
15
+
16
  make_get_request() {
17
  START_TIME=$(date +%s%3N)
18
  RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X GET $1)
 
21
  check_status $RESPONSE $2 $DURATION
22
  }
23
 
24
+
25
  make_post_request() {
26
  START_TIME=$(date +%s%3N)
27
  RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X POST $1 \
 
32
  check_status $RESPONSE $3 $DURATION
33
  }
34
 
35
+
36
  echo "-------- [ Proxy 0 ] --------"
37
  make_get_request "$PROD_ENDPOINT_0/stock/lists" "stock-list-prod-0"
38
  make_post_request "$PROD_ENDPOINT_0/stock/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "stock-prediction-prod-0"
 
42
  make_post_request "$PROD_ENDPOINT_0/national-currency/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "natcurr-prediction-prod-0"
43
  echo " "
44
 
45
+
46
  echo "-------- [ Proxy 1 ] --------"
47
  make_get_request "$PROD_ENDPOINT_1/stock/lists" "stock-list-prod-1"
48
  make_post_request "$PROD_ENDPOINT_1/stock/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "stock-prediction-prod-1"
 
52
  make_post_request "$PROD_ENDPOINT_1/national-currency/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "natcurr-prediction-prod-1"
53
  echo " "
54
 
55
+
56
  echo "-------- [ Proxy 2 ] --------"
57
  make_get_request "$PROD_ENDPOINT_2/stock/lists" "stock-list-prod-2"
58
  make_post_request "$PROD_ENDPOINT_2/stock/prediction" "{\"days\": 7, \"currency\": \"BTC-USD\"}" "stock-prediction-prod-2"