Skip to content

Commit

Permalink
Merge remote-tracking branch 'pokt/main' into test/proof-integration
Browse files Browse the repository at this point in the history
* pokt/main:
  [AppGateServer] feat: Use round-robin endpoint selection strategy (#443)
  [RelayMiner] feat: Make the RelayMiner wait for its corresponding Supllier to stake (#439)
  [Proof] Relay signature & Merkle proof validation (#406)
  [Redelegation] fix: EventRedelegation unmarshaling failure (#435)
  • Loading branch information
bryanchriswhite committed Mar 22, 2024
2 parents a262455 + 833e540 commit 61d83ea
Show file tree
Hide file tree
Showing 32 changed files with 282 additions and 260 deletions.
47 changes: 15 additions & 32 deletions .github/workflows-helpers/run-e2e-test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Enhanced Script for Debugging and Error Handling

# Log environment variables for debugging
echo "Environment variables:"
echo "NAMESPACE: ${NAMESPACE}"
Expand All @@ -13,34 +11,23 @@ while :; do
# Log the command
echo "Running kubectl command to get pods with matching purpose=validator:"

# Get all pods with the matching purpose
PODS_JSON=$(kubectl get pods -n "${NAMESPACE}" -l pokt.network/purpose=validator -o json)

# Log the raw output for debugging
echo "${PODS_JSON}"

# Validate JSON output
if ! echo "${PODS_JSON}" | jq empty; then
echo "Error: kubectl command did not produce valid JSON."
exit 1
fi

# 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")
READY_POD=$(kubectl get pods -n "${NAMESPACE}" -l pokt.network/purpose=validator -o json | jq -r ".items[] | select(.status.phase == \"Running\") | select(any(.spec.containers[]; .image | contains(\"${IMAGE_TAG}\"))) | .metadata.name")

# Check for non-running pods with incorrect image SHA to delete
NON_RUNNING_PODS=$(echo "${PODS_JSON}" | jq -r ".items[] | select(.status.phase != \"Running\") | .metadata.name")
INCORRECT_POD=$(echo "${NON_RUNNING_PODS}" | jq -r "select(.spec.containers[].image | contains(\"${IMAGE_TAG}\") | not) | .metadata.name")
kubectl get pods -n "${NAMESPACE}" -l pokt.network/purpose=validator -o json | jq -r ".items[] | select(.status.phase != \"Running\") | select(any(.spec.containers[]; .image | contains(\"${IMAGE_TAG}\") | not)) | .metadata.name" | while read INCORRECT_POD; do
if [[ -n "${INCORRECT_POD}" ]]; then
echo "Non-ready pod with incorrect image found: ${INCORRECT_POD}. Deleting..."
kubectl delete pod -n "${NAMESPACE}" "${INCORRECT_POD}"
echo "Pod deleted. StatefulSet will recreate the pod."
# Wait for a short duration to allow the StatefulSet to recreate the pod before checking again
sleep 10
fi
done

if [[ -n "${READY_POD}" ]]; then
echo "Ready pod found: ${READY_POD}"
break
elif [[ -n "${INCORRECT_POD}" ]]; then
echo "Non-ready pod with incorrect image found: ${INCORRECT_POD}. Deleting..."
kubectl delete pod -n ${NAMESPACE} ${INCORRECT_POD}
echo "Pod deleted. StatefulSet will recreate the pod."
# Wait for a short duration to allow the StatefulSet to recreate the pod before checking again
sleep 10
else
echo "Validator with image ${IMAGE_TAG} is not ready yet and no incorrect pods found. Will retry checking for ready or incorrect pods in 10 seconds..."
sleep 10
Expand All @@ -65,9 +52,9 @@ kubectl apply -f job.yaml
# Wait for the pod to be created and be in a running state
echo "Waiting for the e2e test 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}')
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=$(kubectl get pod "${POD_NAME}" -n "${NAMESPACE}" -o jsonpath='{.status.phase}')
[[ "${POD_STATUS}" == "Running" ]] && break
echo "Current pod status: ${POD_STATUS}. Waiting for 'Running' status..."
sleep 5
Expand All @@ -76,23 +63,19 @@ done
echo "Pod is running. Monitoring logs and status..."

# Stream the pod logs in the background
kubectl logs -f ${POD_NAME} -n ${NAMESPACE} &
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}")
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}
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}
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,14 @@ acc_initialize_pubkeys: ## Make sure the account keeper has public keys for all

.PHONY: acc_initialize_pubkeys_warn_message
acc_initialize_pubkeys_warn_message: ## Print a warning message about the need to run `make acc_initialize_pubkeys`
@printf "!!!!!!!!! YOU MUST RUN THE FOLLOWING COMMAND ONCE FOR E2E TESTS TO WORK AFTER THE NETWORK HAS STARTED !!!!!!!!!\n"\
"\t\tmake acc_initialize_pubkeys\n"
@echo "+----------------------------------------------------------------------------------+"
@echo "| |"
@echo "| IMPORTANT: Please run the following command once to initialize E2E tests |"
@echo "| after the network has started: |"
@echo "| make acc_initialize_pubkeys |"
@echo "| |"
@echo "+----------------------------------------------------------------------------------+"


##############
### Claims ###
Expand Down
95 changes: 49 additions & 46 deletions api/poktroll/service/relay.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/tests/tokenomics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: Tokenomics Namespaces
And an account exists for "supplier1"
And an account exists for "app1"
When the supplier "supplier1" has serviced a session with "20" relays for service "svc1" for application "app1"
And the user should wait for "5" seconds
# And the user should wait for "5" seconds
# TODO_UPNEXT(@Olshansk, #359): Expand on the two expectations below after integrating the tokenomics module
# into the supplier module.
# Then the account balance of "supplier1" should be "1000" uPOKT "more" than before
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,4 @@ require (
)

// replace github.com/cosmos/cosmos-sdk => github.com/rollkit/cosmos-sdk v0.50.1-rollkit-v0.11.19-no-fraud-proofs
replace github.com/pokt-network/smt => github.com/pokt-network/smt v0.9.3-0.20240321060129-e3dbbbd9f97d
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -978,8 +978,8 @@ github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDj
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pokt-network/smt v0.9.2 h1:h/GnFm1F6mNBbF1hopr+9+y7nr173SU55NX7NxTVU0Y=
github.com/pokt-network/smt v0.9.2/go.mod h1:S4Ho4OPkK2v2vUCHNtA49XDjqUC/OFYpBbynRVYmxvA=
github.com/pokt-network/smt v0.9.3-0.20240321060129-e3dbbbd9f97d h1:6x7LiRWV+mHugWbJlGaYSWESEV+by8hGIbXb3/bWXOg=
github.com/pokt-network/smt v0.9.3-0.20240321060129-e3dbbbd9f97d/go.mod h1:S4Ho4OPkK2v2vUCHNtA49XDjqUC/OFYpBbynRVYmxvA=
github.com/pokt-network/smt/kvstore/badger v0.0.0-20240109205447-868237978c0b h1:TjfgV3vgW0zW47Br/OgUXD4M8iyR74EYanbFfN4ed8o=
github.com/pokt-network/smt/kvstore/badger v0.0.0-20240109205447-868237978c0b/go.mod h1:GbzcG5ebj8twKmBL1VzdPM4NS44okwYXBfQaVXT+6yU=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
Expand Down
Loading

0 comments on commit 61d83ea

Please sign in to comment.