-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Integrate E2E tests with GitHub CI (#152)
* add more debug output * Empty commit * symlink to pocketd for now * rename pocketd * --wip-- [skip ci] * removing pocketd completely * also remove comment * rename repo * test the permissions * test permissions * set project_id: ${{ secrets.GKE_PROTOCOL_PROJECT }} * maybe that will help * test perms * try that * test job * try ls * add checkout * separate the jobs * ignite is needed for tests * avoid collision on name * backoffLimit 0 * wait for pod * change envs * add wait for sequencer before running a test * fix jq * fail fast * move to a script * try this * image sha to image tag * dont use make targets then * troubleshoot * pre-populate the variable * add debug output * install more stuff into the container * try this * cleanup * devnet-test-e2e label everywhere * add env * Update .github/workflows-helpers/run-e2e-test.sh Co-authored-by: Daniel Olshansky <[email protected]> * Update .github/workflows/run-tests.yml Co-authored-by: Daniel Olshansky <[email protected]> * requested changes --------- Co-authored-by: Daniel Olshansky <[email protected]>
- Loading branch information
Showing
9 changed files
with
208 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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 | ||
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters