Skip to content

Commit

Permalink
[RelayMiner] LeanClient (#567)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Olshansky <[email protected]>
  • Loading branch information
okdas and Olshansk authored Jun 15, 2024
1 parent a656145 commit ff04565
Show file tree
Hide file tree
Showing 52 changed files with 1,384 additions and 704 deletions.
70 changes: 67 additions & 3 deletions .github/workflows-helpers/run-e2e-test-job-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,71 @@ spec:
labels:
pokt.network/purpose: e2e-tests
spec:
initContainers:
# We need to make sure the services like validator, relayminer, appgate server, etc. work before we execute
# an e2e test.
# TODO_TECHDEBT(@okdas): move the code into a separate config map (protocol-infra) and mount it.
- name: check-services
image: ruby:3.0
command: ["/bin/sh"]
args:
- "-c"
- |
set -x
# Inline Ruby script to check HTTP statuses
cat << 'EOF' > /tmp/check_services.rb
require 'net/http'
require 'uri'
def check_http_status(endpoint)
max_retries = 30
retries = 0
while retries < max_retries
puts "Checking HTTP status for the endpoint #{endpoint} (Attempt #{retries + 1}/#{max_retries})..."
uri = URI.parse("http://#{endpoint}")
response = Net::HTTP.get_response(uri)
http_status = response.code.to_i
puts "HTTP_STATUS: #{http_status}"
if http_status == 200
puts "HTTP request to #{endpoint} returned 200 OK."
return true
else
puts "HTTP request to #{endpoint} did not return 200 OK. Status code: #{http_status}. Retrying in 10 seconds..."
end
retries += 1
sleep 10
end
puts "Max retries reached for #{endpoint}. Exiting."
exit 1
end
def main
namespace = ARGV[0]
validator_endpoint = "#{namespace}-validator-poktrolld:36657"
appgate_server_endpoint = "#{namespace}-appgate-server:80"
gateway_endpoint = "#{namespace}-gateway:80"
relayminer_endpoint = "#{namespace}-relayminer:8545"
puts "Validator Endpoint: #{validator_endpoint}"
puts "Appgate Server Endpoint: #{appgate_server_endpoint}"
puts "Gateway Endpoint: #{gateway_endpoint}"
puts "Relayminer Endpoint: #{relayminer_endpoint}"
check_http_status(validator_endpoint)
check_http_status(appgate_server_endpoint)
check_http_status(gateway_endpoint)
check_http_status(relayminer_endpoint)
end
main if __FILE__ == $0
EOF
# Execute the Ruby script
ruby /tmp/check_services.rb ${NAMESPACE}
containers:
- name: e2e-tests
image: ghcr.io/pokt-network/poktrolld:${IMAGE_TAG}
Expand Down Expand Up @@ -54,9 +119,8 @@ spec:
- name: non-writable-keys-volume
secret:
secretName: keys-${IMAGE_TAG}
- configMap:
defaultMode: 420
- name: configs-volume
configMap:
name: configs-${IMAGE_TAG}
name: configs-volume
serviceAccountName: default
backoffLimit: 0
12 changes: 0 additions & 12 deletions .github/workflows-helpers/run-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ echo "Environment variables:"
echo "NAMESPACE: ${NAMESPACE}"
echo "IMAGE_TAG: ${IMAGE_TAG}"

# TODO_TECHDEBT(@okdas): also check readiness of appgate and relayminer to avoid false negatives due to race-conditions

# Check if the pod with the matching image SHA and purpose is ready or needs recreation
echo "Checking for ready validator pod with image SHA ${IMAGE_TAG} or pods needing recreation..."
while :; do
Expand Down Expand Up @@ -34,16 +32,6 @@ while :; do
fi
done

# Check we can reach the validator endpoint
echo "Checking HTTP status for the validator endpoint..."
HTTP_STATUS=$(curl -s -o /dev/null -w '%{http_code}' http://${NAMESPACE}-validator-poktrolld:36657)
if [[ "${HTTP_STATUS}" -eq 200 ]]; then
echo "HTTP request to ${NAMESPACE}-validator-poktrolld:36657 returned 200 OK."
else
echo "HTTP request to ${NAMESPACE}-validator-poktrolld:36657 did not return 200 OK. Status code: ${HTTP_STATUS}. Retrying in 10 seconds..."
sleep 10
fi

# Create a job to run the e2e tests
echo "Creating a job to run the e2e tests..."
envsubst <.github/workflows-helpers/run-e2e-test-job-template.yaml >job.yaml
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:
run: ignite chain build -v --debug --skip-proto

- name: Set up Docker Buildx
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image'))
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image')) || (contains(github.event.pull_request.labels.*.name, 'devnet-test-e2e'))
uses: docker/setup-buildx-action@v3

- name: Docker Metadata action
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image'))
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image')) || (contains(github.event.pull_request.labels.*.name, 'devnet-test-e2e'))
id: meta
uses: docker/metadata-action@v5
env:
Expand All @@ -58,23 +58,23 @@ jobs:
type=sha,format=long
- name: Login to GitHub Container Registry
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image'))
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image')) || (contains(github.event.pull_request.labels.*.name, 'devnet-test-e2e'))
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Copy binaries to inside of the Docker context
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image'))
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image')) || (contains(github.event.pull_request.labels.*.name, 'devnet-test-e2e'))
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'))
if: (github.ref == 'refs/heads/main') || (contains(github.event.pull_request.labels.*.name, 'push-image')) || (contains(github.event.pull_request.labels.*.name, 'devnet-test-e2e'))
uses: docker/build-push-action@v5
with:
push: true
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,6 @@ shannon_relayminer_config.yaml
shannon_supplier_config.yaml

gentx-*.json

# Binaries VSCode builds for debugging
cmd/poktrolld/*debug_bin*
Loading

0 comments on commit ff04565

Please sign in to comment.