-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CI] Integrate E2E tests with GitHub CI #152
Changes from all commits
c458279
c933eb2
1f2d44d
341c7c5
0fff5bd
8ff6e3d
0ebb318
d356a84
9874e6a
0ab073b
2937c5f
38fff23
0e2f159
2c2faa7
216652b
e7a14c7
b3c8860
7f78a1c
8b3eaf5
45844a2
af01e2a
4f4b208
74e7cb5
a9f7223
e773092
aa7ae7b
91057ae
f719c88
81eb71d
11100ba
cbc2f79
a7dd1f3
349d822
037b3a9
4424f56
191b0d4
57419d1
c29a74b
1885c4c
763f4ff
2e4355e
dc4ce63
726a96c
f486920
65305ff
ad816cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: ${JOB_NAME} | ||
namespace: ${NAMESPACE} | ||
spec: | ||
ttlSecondsAfterFinished: 120 | ||
template: | ||
spec: | ||
containers: | ||
- name: e2e-tests | ||
image: ghcr.io/pokt-network/poktrolld:${IMAGE_TAG} | ||
command: ["/bin/sh"] | ||
args: ["-c", "poktrolld q gateway list-gateway --node=$POCKET_NODE && poktrolld q application list-application --node=$POCKET_NODE && poktrolld q supplier list-supplier --node=$POCKET_NODE && go test -v ./e2e/tests/... -tags=e2e"] | ||
env: | ||
- name: AUTH_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
key: auth_token | ||
name: celestia-secret | ||
- name: POCKET_NODE | ||
value: tcp://${NAMESPACE}-sequencer:36657 | ||
- name: E2E_DEBUG_OUTPUT | ||
value: "false" # Flip to true to see the command and result of the execution | ||
- name: POKTROLLD_HOME | ||
value: /root/.pocket | ||
- name: CELESTIA_HOSTNAME | ||
value: celestia-rollkit | ||
volumeMounts: | ||
- mountPath: /root/.pocket/keyring-test/ | ||
name: keys-volume | ||
- mountPath: /root/.pocket/config/ | ||
name: configs-volume | ||
restartPolicy: Never | ||
volumes: | ||
- configMap: | ||
defaultMode: 420 | ||
name: poktrolld-keys | ||
name: keys-volume | ||
- configMap: | ||
defaultMode: 420 | ||
name: poktrolld-configs | ||
name: configs-volume | ||
serviceAccountName: default | ||
backoffLimit: 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Check if the pod with the matching image SHA and purpose is ready | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a blocker but just a question. Is the plan to keep this bash script as is? I know you've used things like argoCD and other DAG like workflow builders, so was just surprised to have a simple bash script like it today. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Olshansk, if this will cause issues, we'll switch. Even with Argo Workflows with DAG, we are going to need some bash scripting. I'm not a fan of them, but we don't have the permissions/connectivity restraints we used to have on previous infrastructure so it seemed as an OK solution. |
||
echo "Checking for ready sequencer pod with image SHA ${IMAGE_TAG}..." | ||
while : ; do | ||
# Get all pods with the matching purpose | ||
PODS_JSON=$(kubectl get pods -n ${NAMESPACE} -l pokt.network/purpose=sequencer -o json) | ||
|
||
# Check if any pods are running and have the correct image SHA | ||
READY_POD=$(echo $PODS_JSON | jq -r ".items[] | select(.status.phase == \"Running\") | select(.spec.containers[].image | contains(\"${IMAGE_TAG}\")) | .metadata.name") | ||
|
||
if [[ -n "${READY_POD}" ]]; then | ||
echo "Ready pod found: ${READY_POD}" | ||
break | ||
else | ||
echo "Sequencer with with an image ${IMAGE_TAG} is not ready yet. Will retry in 10 seconds..." | ||
sleep 10 | ||
fi | ||
done | ||
|
||
# Create a job to run the e2e tests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great comments throughout! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks @openai |
||
envsubst < .github/workflows-helpers/run-e2e-test-job-template.yaml > job.yaml | ||
kubectl apply -f job.yaml | ||
|
||
# Wait for the pod to be created and be in a running state | ||
echo "Waiting for the pod to be in the running state..." | ||
while : ; do | ||
POD_NAME=$(kubectl get pods -n ${NAMESPACE} --selector=job-name=${JOB_NAME} -o jsonpath='{.items[*].metadata.name}') | ||
[[ -z "${POD_NAME}" ]] && echo "Waiting for pod to be scheduled..." && sleep 5 && continue | ||
POD_STATUS=$(kubectl get pod ${POD_NAME} -n ${NAMESPACE} -o jsonpath='{.status.phase}') | ||
[[ "${POD_STATUS}" == "Running" ]] && break | ||
echo "Current pod status: ${POD_STATUS}" | ||
sleep 5 | ||
done | ||
|
||
echo "Pod is running. Monitoring logs and status..." | ||
# Stream the pod logs in the background | ||
kubectl logs -f ${POD_NAME} -n ${NAMESPACE} & | ||
|
||
# Monitor pod status in a loop | ||
while : ; do | ||
CURRENT_STATUS=$(kubectl get pod ${POD_NAME} -n ${NAMESPACE} -o jsonpath="{.status.containerStatuses[0].state}") | ||
if echo $CURRENT_STATUS | grep -q 'terminated'; then | ||
EXIT_CODE=$(echo $CURRENT_STATUS | jq '.terminated.exitCode') | ||
if [[ "$EXIT_CODE" != "0" ]]; then | ||
echo "Container terminated with exit code ${EXIT_CODE}" | ||
kubectl delete job ${JOB_NAME} -n ${NAMESPACE} | ||
exit 1 | ||
fi | ||
break | ||
fi | ||
sleep 5 | ||
done | ||
|
||
# If the loop exits without failure, the job succeeded | ||
echo "Job completed successfully" | ||
kubectl delete job ${JOB_NAME} -n ${NAMESPACE} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Run tests | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
GKE_CLUSTER: protocol-us-central1 | ||
GKE_ZONE: us-central1 | ||
|
||
jobs: | ||
go-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: install ignite | ||
# If this step fails due to ignite.com failing, see #116 for a temporary workaround | ||
run: | | ||
curl https://get.ignite.com/cli! | bash | ||
ignite version | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: "0" # Per https://github.com/ignite/cli/issues/1674#issuecomment-1144619147 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.20.10" | ||
|
||
- name: Install CI dependencies | ||
run: make install_ci_deps | ||
|
||
- name: Generate protobufs | ||
run: make proto_regen | ||
|
||
- name: Generate mocks | ||
run: make go_mockgen | ||
|
||
- name: Run golangci-lint | ||
run: make go_lint | ||
|
||
- name: Test | ||
run: make go_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.