Skip to content

Commit 2c7cc12

Browse files
committed
test(berkeley): Add stability test
- Checks that previous daily deployment is stable - Checks that block height is the same as in berkeleynet - Adds badges Re: #97
1 parent b2cacb0 commit 2c7cc12

File tree

4 files changed

+98
-3
lines changed

4 files changed

+98
-3
lines changed

.github/workflows/daily.yaml

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,31 @@ on:
33
workflow_dispatch: {}
44
schedule:
55
- cron: "0 5 * * *"
6-
6+
push:
7+
branches: [ "test/*daily*" ]
78

89
jobs:
910
bootstrap-berkeley:
1011
runs-on: ubuntu-latest
12+
13+
env:
14+
CLUSTER_ADDR: 1.k8.openmina.com
15+
OPENMINA_NODE_PORT: 31001
16+
OPENMINA_SELECTOR: app.kubernetes.io/instance=${{ github.job }},app.kubernetes.io/name=openmina
17+
PROXY: https://proxy.berkeley.minaexplorer.com/
18+
BEST_CHAIN_QUERY: |
19+
query MyQuery {
20+
bestChain(maxLength: 1) {
21+
protocolState {
22+
consensusState {
23+
blockHeight
24+
}
25+
}
26+
}
27+
}
28+
BEST_CHAIN_HEIGHT_FILTER: .data.bestChain[0].protocolState.consensusState.blockHeight
29+
30+
1131
steps:
1232
- name: Git checkout
1333
uses: actions/checkout@v3
@@ -18,6 +38,74 @@ jobs:
1838
method: kubeconfig
1939
kubeconfig: ${{ secrets.K8S_CONFIG }}
2040

41+
- name: Get Openmina pod status
42+
run: |
43+
openmina_pod=$(kubectl get pod --selector="$OPENMINA_SELECTOR" -o json | jq -r '.items | sort_by(.metadata.creationTimestamp) | .[-1] // halt | .metadata.name')
44+
openmina_status=$(kubectl get pod --selector="$OPENMINA_SELECTOR" -o json | jq -c '.items | sort_by(.metadata.creationTimestamp) | .[-1] // halt | .status')
45+
echo "::group::Openmina status"
46+
echo $openmina_status | jq .
47+
echo "::endgroup::"
48+
echo "OPENMINA_POD=$openmina_pod" >> "$GITHUB_ENV"
49+
echo "OPENMINA_STATUS=$openmina_status" >> "$GITHUB_ENV"
50+
51+
- name: Check Sync state
52+
if: ${{ env.OPENMINA_STATUS != '' }}
53+
env:
54+
GET_READY_STATUS: '.conditions[] | select(.status == "True" and .type == "Ready")'
55+
GET_RESTARTS_COUNT: '.containerStatuses[] | select(.name == "openmina") | .restartCount'
56+
run: |
57+
if [ -z "$(echo $OPENMINA_STATUS | jq "$GET_READY_STATUS")" ]; then
58+
echo "::error::Openmina pod is not ready"
59+
exit 1
60+
else
61+
restarts_count="$(echo $OPENMINA_STATUS | jq "$GET_RESTARTS_COUNT")"
62+
if [ "$restarts_count" -gt 0 ]; then
63+
echo "::error::Openmina container restart count is ${restarts_count}"
64+
exit 1
65+
fi
66+
fi
67+
68+
- name: Get network height
69+
if: ${{ env.OPENMINA_POD != '' }}
70+
run: |
71+
net_height="$(echo $BEST_CHAIN_QUERY | echo "{\"query\": \"$(cat)\"}" | curl -s $PROXY -d @- -H 'content-type: application/json' | jq -r "$BEST_CHAIN_HEIGHT_FILTER")"
72+
echo "::debug::Network block height: $net_height"
73+
echo "NET_HEIGHT=$net_height" >> "$GITHUB_ENV"
74+
75+
- name: Check Openmina height
76+
if: ${{ env.OPENMINA_POD != '' }}
77+
run: |
78+
for n in $(seq 10); do
79+
OPENMINA_HEIGHT=$(kubectl exec $OPENMINA_POD -- curl -s localhost:3000/stats/sync | jq '.[0].blocks[0].height')
80+
echo "::debug::Openmina block height $OPENMINA_HEIGHT"
81+
if [ "$NET_HEIGHT" -eq "$OPENMINA_HEIGHT" ]; then
82+
exit
83+
fi
84+
sleep 1
85+
done
86+
echo "::error::Openmina is at $OPENMINA_HEIGHT that is behind main network $NET_HEIGHT"
87+
2188
- name: Bootstrap Openmina node
2289
run: |
23-
helm upgrade --install ${{ github.job }} helm/openmina --wait --timeout=10m --set=podAnnotations.timestamp="$(date)"
90+
helm upgrade --install ${{ github.job }} helm/openmina --wait --timeout=10m --set=service.type=NodePort --set=service.nodePort=$OPENMINA_NODE_PORT --set=podAnnotations.timestamp="$(date)"
91+
echo "::notice::Openmina node is deployed and bootstrapped. It is available at http://$CLUSTER_ADDR:$OPENMINA_NODE_PORT"
92+
openmina_pod=$(kubectl get pod --selector="$OPENMINA_SELECTOR" -o json | jq -r '.items | sort_by(.metadata.creationTimestamp) | .[-1] // halt | .metadata.name')
93+
echo "OPENMINA_POD=$openmina_pod" >> "$GITHUB_ENV"
94+
95+
- name: Get network height
96+
run: |
97+
net_height="$(echo $BEST_CHAIN_QUERY | echo "{\"query\": \"$(cat)\"}" | curl -s $PROXY -d @- -H 'content-type: application/json' | jq -r "$BEST_CHAIN_HEIGHT_FILTER")"
98+
echo "::debug::Network block height: $NET_HEIGHT"
99+
echo "NET_HEIGHT=$net_height" >> "$GITHUB_ENV"
100+
101+
- name: Check Openmina height
102+
run: |
103+
for n in $(seq 10); do
104+
OPENMINA_HEIGHT=$(kubectl exec $OPENMINA_POD -- curl -s localhost:3000/stats/sync | jq '.[0].blocks[0].height')
105+
echo "::debug::Openmina block height $OPENMINA_HEIGHT"
106+
if [ "$NET_HEIGHT" -eq "$OPENMINA_HEIGHT" ]; then
107+
exit
108+
fi
109+
sleep 1
110+
done
111+
echo "::error::Openmina is at $OPENMINA_HEIGHT that is behind main network $NET_HEIGHT"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
# The Open Mina Node
33

4+
[![Openmina Daily](https://github.com/openmina/openmina/actions/workflows/daily.yaml/badge.svg)](https://github.com/openmina/openmina/actions/workflows/daily.yaml)
5+
46
The Open Mina Node is a Mina node written completely in Rust and capable of verifying blocks of transactions, producing blocks and generating SNARKs.
57

68
In the design of the Open Mina node, we are utilizing much of the same logic as in the Mina Web Node. The key difference is that unlike the Web Node, which is an in-browser node with limited resources, the Open Mina node is able to perform resource-intensive tasks such as SNARK proof generation.

helm/openmina/templates/service.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@ spec:
1111
targetPort: http
1212
protocol: TCP
1313
name: http
14+
{{- if (eq .Values.service.type "NodePort")}}
15+
{{- with .Values.service.nodePort }}
16+
nodePort: {{ . }}
17+
{{- end }}
18+
{{- end }}
1419
selector:
1520
{{- include "openmina.selectorLabels" . | nindent 4 }}

testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
- [ ] Network split
1515
- [ ] Long-running network (cluster)
16-
- [ ] Berkeley testnet (?)
16+
- [x] Berkeley testnet: [![Openmina Daily](https://github.com/openmina/openmina/actions/workflows/daily.yaml/badge.svg)](https://github.com/openmina/openmina/actions/workflows/daily.yaml)
1717

1818
### Various bootstrap scenarios
1919

0 commit comments

Comments
 (0)