Skip to content
This repository was archived by the owner on Jan 19, 2024. It is now read-only.

Commit 1645ba2

Browse files
authored
Exercise session-handling created (#6)
* Exercise session-handling created * verification script for session-handling tutorial
1 parent c1e53d3 commit 1645ba2

File tree

5 files changed

+101
-0
lines changed

5 files changed

+101
-0
lines changed

session-handling/.scripts/verify.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
EXIT_CODE=0
4+
minikube_ip=$(minikube ip)
5+
if [ $? -ne 0 ]; then
6+
kubernetes_ip="localhost"
7+
else
8+
kubernetes_ip=${minikube_ip}
9+
fi
10+
11+
.scripts/common_verifications.sh
12+
if [ "$?" -ne "0" ]; then
13+
EXIT_CODE=1
14+
fi
15+
16+
STATUSCODE=$(curl -k -s -o /dev/null -w "%{http_code}" https://${kubernetes_ip}/)
17+
if [ "${STATUSCODE}" = "200" ]
18+
then
19+
echo "OK: Microgateway returned status code 200"
20+
else
21+
echo "NOK: Microgateway did not return status code: ${STATUSCODE}"
22+
EXIT_CODE=1
23+
fi
24+
25+
REQUEST_COUNT=$(kubectl logs -l app=microgateway -c microgateway --tail=-1 | grep -c "WR-SG-SUMMARY")
26+
if [ "${REQUEST_COUNT}" -eq "1" ]
27+
then
28+
echo "OK: Microgateway received 1 request: ${REQUEST_COUNT}"
29+
else
30+
echo "NOK: Microgateway did not receive 1 request: ${REQUEST_COUNT}"
31+
EXIT_CODE=1
32+
fi
33+
REQUESTS_WO_SESSION=$(kubectl logs -l app=microgateway -c microgateway --tail=-1 | grep WR-SG-SUMMARY | grep -c '"sess_id":"<n/a>"')
34+
if [ "${REQUESTS_WO_SESSION}" -eq "0" ]
35+
then
36+
echo "OK: Microgateway received no request w/o session: ${REQUESTS_WO_SESSION}"
37+
else
38+
echo "NOK: Microgateway received requests w/o session: ${REQUESTS_WO_SESSION}"
39+
EXIT_CODE=1
40+
fi
41+
42+
exit $EXIT_CODE
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
apps:
3+
- virtual_host:
4+
name: echo
5+
hostname: echo.virtinc.local
6+
mappings:
7+
- name: echoserver
8+
operational_mode: integration
9+
backend:
10+
name: echoserver
11+
hosts:
12+
- protocol: http
13+
name: echoserver
14+
port: 8080
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
5+
bases:
6+
- ../solution
7+
8+
configMapGenerator:
9+
- name: microgateway-config
10+
behavior: replace
11+
files:
12+
- config/config.yaml
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
session:
3+
redis_hosts: [redis-master]
4+
5+
apps:
6+
- virtual_host:
7+
name: echo
8+
hostname: echo.virtinc.local
9+
mappings:
10+
- name: echoserver
11+
session_handling: enforce_session
12+
operational_mode: integration
13+
backend:
14+
name: echoserver
15+
hosts:
16+
- protocol: http
17+
name: echoserver
18+
port: 8080
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
5+
bases:
6+
- ../../.templates/ingress
7+
- ../../.templates/microgateway
8+
- ../../.templates/echoserver
9+
- ../../.templates/redis
10+
11+
configMapGenerator:
12+
- name: microgateway-config
13+
behavior: replace
14+
files:
15+
- config/config.yaml

0 commit comments

Comments
 (0)