Skip to content

Commit

Permalink
Merge branch 'merge/e2e_test/relay_x_relayer_cli' into e2e_test/relay…
Browse files Browse the repository at this point in the history
…-update

* merge/e2e_test/relay_x_relayer_cli:
  [LocalNet] Run Relayer and AppGateServer (#179)
  [Relay] E2E Relay Gaps (#177)
  More tiny comment updates
  Added a couple more comments
  Update some comments and TODOs
  Update the names and references to queryNode/sequencerNode/fullNode etc
  Update pkg/relayer/cmd/cmd.go
  [Test] Updating `relay.feature` to run curl command to enable E2E Relay Test (#178)
  Updated comments for post 177+179 work for okdas
  Update OpenAPI spec
  Update .gitignore
  chore: update comment
  chore: move shared dependency setup logic to shared pkg
  chore: cleanup flags and dependencies for appgateserver cmd
  [Supplier] chore: improve supplier not found error message (#183)
  [CI] Integrate E2E tests with GitHub CI (#152)
  • Loading branch information
bryanchriswhite committed Nov 16, 2023
2 parents 98a1854 + 09de036 commit 0498318
Show file tree
Hide file tree
Showing 25 changed files with 447 additions and 137 deletions.
14 changes: 7 additions & 7 deletions .github/label-actions.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# When `devnet-e2e-test` is added, also assign `devnet` to the PR.
devnet-e2e-test:
# When `devnet-test-e2e` is added, also assign `devnet` to the PR.
devnet-test-e2e:
prs:
comment: The CI will now also run the e2e tests on devnet, which increases the time it takes to complete all CI checks.
label:
- devnet
- push-image

# When `devnet-e2e-test` is removed, also delete `devnet` from the PR.
-devnet-e2e-test:
# When `devnet-test-e2e` is removed, also delete `devnet` from the PR.
-devnet-test-e2e:
prs:
unlabel:
- devnet
Expand All @@ -18,11 +18,11 @@ devnet:
label:
- push-image

# When `devnet` is removed, also delete `devnet-e2e-test` from the PR.
# When `devnet` is removed, also delete `devnet-test-e2e` from the PR.
-devnet:
prs:
unlabel:
- devnet-e2e-test
- devnet-test-e2e

# Let the developer know that they need to push another commit after attaching the label to PR.
push-image:
Expand All @@ -34,4 +34,4 @@ push-image:
prs:
unlabel:
- devnet
- devnet-e2e-test
- devnet-test-e2e
45 changes: 45 additions & 0 deletions .github/workflows-helpers/run-e2e-test-job-template.yaml
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
55 changes: 55 additions & 0 deletions .github/workflows-helpers/run-e2e-test.sh
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}
59 changes: 41 additions & 18 deletions .github/workflows/go.yml → .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Ignite build & test
name: Main build

on:
push:
branches: ["main"]
pull_request:

concurrency:
group: ${{ github.head_ref || github.ref_name }}
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

jobs:
build:
build-push-container:
runs-on: ubuntu-latest
steps:
- name: install ignite
Expand All @@ -29,26 +26,17 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
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: Build
run: ignite chain build -v --debug --skip-proto

- name: Test
run: make go_test

- name: Set up Docker Buildx
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image'))
uses: docker/setup-buildx-action@v3
Expand All @@ -61,7 +49,7 @@ jobs:
DOCKER_METADATA_PR_HEAD_SHA: "true"
with:
images: |
ghcr.io/pokt-network/pocketd
ghcr.io/pokt-network/poktrolld
tags: |
type=ref,event=branch
type=ref,event=pr
Expand All @@ -76,11 +64,13 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Copy binary to inside of the Docker context
- name: Copy binaries to inside of the Docker context
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image'))
run: |
mkdir -p ./bin # Make sure the bin directory exists
cp $(which ignite) ./bin # Copy ignite binary to the repo's bin directory
cp $(go env GOPATH)/bin/poktrolld ./bin # Copy the binary to the repo's bin directory
ls -la ./bin
- name: Build and push Docker image
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image'))
Expand All @@ -95,3 +85,36 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .

run-e2e-tests:
needs: build-push-container
if: contains(github.event.pull_request.labels.*.name, 'devnet-test-e2e')
runs-on: ubuntu-latest
env:
GKE_CLUSTER: protocol-us-central1
GKE_ZONE: us-central1
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
.github
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GKE_PROTOCOL_US_CENTRAL }}'

- uses: google-github-actions/get-gke-credentials@v1
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}
project_id: ${{ secrets.GKE_PROTOCOL_PROJECT }}

- name: Run E2E test job
env:
IMAGE_TAG: sha-${{ github.event.pull_request.head.sha || github.sha }}
NAMESPACE: devnet-issue-${{ github.event.number }}
JOB_NAME: e2e-test-${{ github.event.pull_request.head.sha || github.sha }}
POCKET_NODE: tcp://devnet-issue-${{ github.event.number }}-sequencer:36657
run: bash .github/workflows-helpers/run-e2e-test.sh
4 changes: 4 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
pull_request:
branches: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

jobs:
# Makes sure that comments like TODO_IN_THIS_PR or TODO_IN_THIS_COMMIT block merging to main
# More info: https://github.com/pokt-network/action-fail-on-found
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/run-tests.yml
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
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ localnet/*/config/*.json
!localnet/poktrolld/config/client.toml
!localnet/poktrolld/config/config.toml


# Macos
.DS_Store
**/.DS_Store
Expand Down Expand Up @@ -63,12 +62,11 @@ localnet_config.yaml
release

# SMT KVStore files
# TODO_TECHDEBT(#126, @red-0ne): Rename `smt` to `smt_stores` and make it configurable so it can be stored anywhere on this
smt

# Do not allow a multi-moduled projected
go.work.sum

# TODO_IN_THIS_COMMIT: Why did we start generating .dot files?
# TODO_TECHDEBT: It seems that .dot files come and go so we need to figure out the root cause: https://github.com/pokt-network/poktroll/pull/177/files#r1392521547
# **/*.dot


7 changes: 5 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM golang:1.20 as base
RUN apt update && \
apt-get install -y \
ca-certificates \
curl jq make
curl jq make vim less

# enable faster module downloading.
ENV GOPROXY https://proxy.golang.org
Expand All @@ -15,9 +15,12 @@ COPY . /poktroll

WORKDIR /poktroll

RUN mv /poktroll/bin/poktrolld /usr/bin/poktrolld
RUN mv /poktroll/bin/ignite /usr/bin/ && mv /poktroll/bin/poktrolld /usr/bin/

# TODO_TECHDEBT(@okdas): Ports are not documented as they will soon be changed with a document to follow
EXPOSE 8545
EXPOSE 8546
EXPOSE 8547
EXPOSE 8548

ENTRYPOINT ["ignite"]
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ app_list: ## List all the staked applications
app_stake: ## Stake tokens for the application specified (must specify the APP and SERVICES env vars)
poktrolld --home=$(POKTROLLD_HOME) tx application stake-application 1000upokt $(SERVICES) --keyring-backend test --from $(APP) --node $(POCKET_NODE)

# TODO_IMPROVE(#180): Make sure genesis-staked actors are available via AccountKeeper
.PHONY: app1_stake
app1_stake: ## Stake app1 (also staked in genesis)
APP=app1 SERVICES=anvil,svc1,svc2 make app_stake
Expand Down Expand Up @@ -362,22 +363,22 @@ supplier_list: ## List all the staked supplier
supplier_stake: ## Stake tokens for the supplier specified (must specify the APP env var)
poktrolld --home=$(POKTROLLD_HOME) tx supplier stake-supplier 1000upokt "$(SERVICES)" --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE)

# TODO_IMPROVE(#180): Make sure genesis-staked actors are available via AccountKeeper
.PHONY: supplier1_stake
supplier1_stake: ## Stake supplier1 (also staked in genesis)
# TODO_TECHDEBT(#179): once `relayminer` service is added to tilt, this hostname should point to that service.
# TODO_UPNEXT(@okdas): once `relayminer` service is added to tilt, this hostname should point to that service.
# I.e.: replace `localhost` with `relayminer` (or whatever the service's hostname is).
# TODO_IMPROVE(#180): Make sure genesis-staked actors are available via AccountKeeper
SUPPLIER=supplier1 SERVICES="anvil;http://localhost:8545,svc1;http://localhost:8081" make supplier_stake

.PHONY: supplier2_stake
supplier2_stake: ## Stake supplier2
# TODO_TECHDEBT(#179): once `relayminer` service is added to tilt, this hostname should point to that service.
# TODO_UPNEXT(@okdas): once `relayminer` service is added to tilt, this hostname should point to that service.
# I.e.: replace `localhost` with `relayminer` (or whatever the service's hostname is).
SUPPLIER=supplier2 SERVICES="anvil;http://localhost:8545,svc2;http://localhost:8082" make supplier_stake

.PHONY: supplier3_stake
supplier3_stake: ## Stake supplier3
# TODO_TECHDEBT(#179): once `relayminer` service is added to tilt, this hostname should point to that service.
# TODO_UPNEXT(@okdas): once `relayminer` service is added to tilt, this hostname should point to that service.
# I.e.: replace `localhost` with `relayminer` (or whatever the service's hostname is).
SUPPLIER=supplier3 SERVICES="anvil;http://localhost:8545,svc3;http://localhost:8083" make supplier_stake

Expand Down
Loading

0 comments on commit 0498318

Please sign in to comment.