Skip to content

Commit

Permalink
[CI/Infra] Fix DevNet e2e tests post-migration with validators (#398)
Browse files Browse the repository at this point in the history
Co-authored-by: Bryan White <[email protected]>
Co-authored-by: Redouane Lakrache <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
  • Loading branch information
4 people authored Mar 6, 2024
1 parent e878248 commit 8bf9eaf
Show file tree
Hide file tree
Showing 46 changed files with 21,740 additions and 11,344 deletions.
17 changes: 5 additions & 12 deletions .github/workflows-helpers/run-e2e-test-job-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,14 @@ spec:
make acc_initialize_pubkeys && \
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: SEQUENCER_RPC_ENDPOINT
value: ${NAMESPACE}-sequencer:36657
value: tcp://${NAMESPACE}-validator-poktrolld:36657
- name: VALIDATOR_RPC_ENDPOINT
value: ${NAMESPACE}-validator-poktrolld: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
- name: APPGATE_SERVER_URL
value: http://${NAMESPACE}-appgate-server:80
volumeMounts:
Expand All @@ -47,9 +40,9 @@ spec:
name: configs-volume
restartPolicy: Never
volumes:
- configMap:
- secret:
defaultMode: 420
name: keys-${IMAGE_TAG}
secretName: keys-${IMAGE_TAG}
name: keys-volume
- configMap:
defaultMode: 420
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows-helpers/run-e2e-test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# 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
echo "Checking for ready sequencer pod with image SHA ${IMAGE_TAG}..."
echo "Checking for ready validator 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)
PODS_JSON=$(kubectl get pods -n ${NAMESPACE} -l pokt.network/purpose=validator -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")
Expand All @@ -13,17 +13,17 @@ while :; do
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..."
echo "Validator with with an image ${IMAGE_TAG} is not ready yet. Will retry in 10 seconds..."
sleep 10
fi
done

# Check we can reach the sequencer endpoint
HTTP_STATUS=$(curl -s -o /dev/null -w '%{http_code}' http://${NAMESPACE}-sequencer:36657)
# Check we can reach 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 devnet-issue-198-sequencer returned 200 OK."
echo "HTTP request to ${NAMESPACE}-validator-poktrolld:36657 returned 200 OK."
else
echo "HTTP request to devnet-issue-198-sequencer did not return 200 OK. Status code: ${HTTP_STATUS}. Retrying in 10 seconds..."
echo "HTTP request to ${NAMESPACE}-validator-poktrolld:36657 did not return 200 OK. Status code: ${HTTP_STATUS}. Retrying in 10 seconds..."
sleep 10
fi

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ jobs:
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
POCKET_NODE: tcp://devnet-issue-${{ github.event.number }}-validator-poktrolld:36657
run: bash .github/workflows-helpers/run-e2e-test.sh
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ summary.html
# Quickstart helpers
shannon_appgate_config.yaml
shannon_app_config.yaml

gentx-*.json
22 changes: 6 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

SHELL = /bin/sh
POKTROLLD_HOME ?= ./localnet/poktrolld
POCKET_NODE ?= tcp://127.0.0.1:36657 # The pocket rollup node (full node and sequencer in the localnet context)
POCKET_NODE ?= tcp://127.0.0.1:36657 # The pocket node (validator in the localnet context)
APPGATE_SERVER ?= http://localhost:42069
POCKET_ADDR_PREFIX = pokt
CHAIN_ID = poktroll
Expand Down Expand Up @@ -229,7 +229,7 @@ docker_wipe: check_docker warn_destructive prompt_user ## [WARNING] Remove all t
########################

.PHONY: localnet_up
localnet_up: proto_regen localnet_regenesis## Starts localnet
localnet_up: proto_regen localnet_regenesis ## Starts localnet
tilt up

.PHONY: localnet_down
Expand All @@ -239,22 +239,12 @@ localnet_down: ## Delete resources created by localnet
.PHONY: localnet_regenesis
localnet_regenesis: check_yq acc_initialize_pubkeys_warn_message ## Regenerate the localnet genesis file
# NOTE: intentionally not using --home <dir> flag to avoid overwriting the test keyring
# TODO_TECHDEBT: Currently the stake => power calculation is constant; however, cosmos-sdk
# intends to make this parameterizable in the future.
@echo "Initializing chain..."
@set -e ;\
ignite chain init --skip-proto ;\
mkdir -p $(POKTROLLD_HOME)/config/ ;\
cp -r ${HOME}/.poktroll/keyring-test $(POKTROLLD_HOME) ;\
cp ${HOME}/.poktroll/config/*_key.json $(POKTROLLD_HOME)/config/ ;\
ADDRESS=$$(jq -r '.address' $(POKTROLLD_HOME)/config/priv_validator_key.json) ;\
PUB_KEY=$$(jq -r '.pub_key' $(POKTROLLD_HOME)/config/priv_validator_key.json) ;\
POWER=$$(yq -r ".validators[0].bonded" ./config.yml | sed 's,000000upokt,,') ;\
NAME=$$(yq -r ".validators[0].name" ./config.yml) ;\
echo "Regenerating genesis file with new validator..." ;\
jq --argjson pubKey "$$PUB_KEY" '.consensus["validators"]=[{"address": "'$$ADDRESS'", "pub_key": $$pubKey, "power": "'$$POWER'", "name": "'$$NAME'"}]' ${HOME}/.poktroll/config/genesis.json > temp.json ;\
mv temp.json ${HOME}/.poktroll/config/genesis.json ;\
cp ${HOME}/.poktroll/config/genesis.json $(POKTROLLD_HOME)/config/ ;\
cp -r ${HOME}/.poktroll/config/ $(POKTROLLD_HOME)/config/ ;\

.PHONY: send_relay
send_relay:
Expand Down Expand Up @@ -291,15 +281,15 @@ test_e2e: acc_initialize_pubkeys_warn_message ## Run all E2E tests

.PHONY: go_test_verbose
go_test_verbose: check_go_version ## Run all go tests verbosely
go test -v -race -tags test ./...
go test -count=1 -v -race -tags test ./...

.PHONY: go_test
go_test: check_go_version ## Run all go tests showing detailed output only on failures
go test -race -tags test ./...
go test -count=1 -race -tags test ./...

.PHONY: go_test_integration
go_test_integration: check_go_version ## Run all go tests, including integration
go test -v -race -tags test,integration ./...
go test -count=1 -v -race -tags test,integration ./...

.PHONY: itest
itest: check_go_version ## Run tests iteratively (see usage for more)
Expand Down
135 changes: 58 additions & 77 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
load("ext://restart_process", "docker_build_with_restart")
load("ext://helm_resource", "helm_resource", "helm_repo")
load("ext://configmap", "configmap_create")

# A list of directories where changes trigger a hot-reload of the sequencer
# A list of directories where changes trigger a hot-reload of the validator
hot_reload_dirs = ["app", "cmd", "tools", "x", "pkg"]

# Create a localnet config file from defaults, and if a default configuration doesn't exist, populate it with default values
localnet_config_path = "localnet_config.yaml"
localnet_config_defaults = {
"sequencer": {"cleanupBeforeEachStart": True},
"validator": {"cleanupBeforeEachStart": True},
"relayminers": {"count": 1},
"gateways": {"count": 1},
"appgateservers": {"count": 1},
Expand All @@ -34,40 +35,24 @@ if localnet_config["helm_chart_local_repo"]["enabled"]:
print("Using local helm chart repo " + helm_chart_local_repo)
chart_prefix = helm_chart_local_repo + "/charts/"


# Import files into Kubernetes ConfigMap
def read_files_from_directory(directory):
files = listdir(directory)
config_map_data = {}
for filepath in files:
content = str(read_file(filepath)).strip()
filename = os.path.basename(filepath)
config_map_data[filename] = content
return config_map_data


def generate_config_map_yaml(name, data):
config_map_object = {
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": {"name": name},
"data": data,
}
return encode_yaml(config_map_object)


# Import keyring/keybase files into Kubernetes ConfigMap
k8s_yaml(
generate_config_map_yaml(
"poktrolld-keys", read_files_from_directory("localnet/poktrolld/keyring-test/")
)
) # poktrolld/keys
configmap_create(
"poktrolld-keys", from_file=listdir("localnet/poktrolld/keyring-test/")
)
# Import configuration files into Kubernetes ConfigMap
k8s_yaml(
generate_config_map_yaml(
"poktrolld-configs", read_files_from_directory("localnet/poktrolld/config/")
)
) # poktrolld/configs
configmap_create(
"poktrolld-configs", from_file=listdir("localnet/poktrolld/config/"), watch=True
)
# TODO(@okdas): Import validator keys when we switch to `poktrolld` helm chart
# by uncommenting the following lines:
# load("ext://secret", "secret_create_generic")
# secret_create_generic(
# "poktrolld-validator-keys",
# from_file=[
# "localnet/poktrolld/config/node_key.json",
# "localnet/poktrolld/config/priv_validator_key.json",
# ],
# )

# Hot reload protobuf changes
local_resource(
Expand Down Expand Up @@ -108,20 +93,21 @@ WORKDIR /
live_update=[sync("bin/poktrolld", "/usr/local/bin/poktrolld")],
)

# Run celestia and anvil nodes
# Run data nodes & validators
k8s_yaml(
["localnet/kubernetes/celestia-rollkit.yaml", "localnet/kubernetes/anvil.yaml", "localnet/kubernetes/sequencer-volume.yaml"]
["localnet/kubernetes/anvil.yaml", "localnet/kubernetes/validator-volume.yaml"]
)

# Run pocket-specific nodes (sequencer, relayminers, etc...)
# Run pocket-specific nodes (validator, relayminers, etc...)
helm_resource(
"sequencer",
chart_prefix + "poktroll-sequencer",
"validator",
chart_prefix + "poktroll-validator",
flags=[
"--values=./localnet/kubernetes/values-common.yaml",
"--values=./localnet/kubernetes/values-sequencer.yaml",
"--set=persistence.cleanupBeforeEachStart=" + str(localnet_config["sequencer"]["cleanupBeforeEachStart"]),
],
"--values=./localnet/kubernetes/values-validator.yaml",
"--set=persistence.cleanupBeforeEachStart="
+ str(localnet_config["validator"]["cleanupBeforeEachStart"]),
],
image_deps=["poktrolld"],
image_keys=[("image.repository", "image.tag")],
)
Expand All @@ -136,50 +122,45 @@ helm_resource(
image_deps=["poktrolld"],
image_keys=[("image.repository", "image.tag")],
)
helm_resource(
"appgateservers",
chart_prefix + "appgate-server",
flags=[
"--values=./localnet/kubernetes/values-common.yaml",
"--values=./localnet/kubernetes/values-appgateserver.yaml",
"--set=replicaCount=" + str(localnet_config["appgateservers"]["count"]),
],
image_deps=["poktrolld"],
image_keys=[("image.repository", "image.tag")],
)
if localnet_config["appgateservers"]["count"] > 0:
helm_resource(
"appgateservers",
chart_prefix + "appgate-server",
flags=[
"--values=./localnet/kubernetes/values-common.yaml",
"--values=./localnet/kubernetes/values-appgateserver.yaml",
"--set=replicaCount=" + str(localnet_config["appgateservers"]["count"]),
],
image_deps=["poktrolld"],
image_keys=[("image.repository", "image.tag")],
)

# Configure tilt resources (tilt labels and port forwards) for all of the nodes above
k8s_resource(
"celestia-rollkit",
labels=["blockchains"],
port_forwards=["26657", "26658", "26659"],
)
k8s_resource(
"sequencer",
labels=["blockchains"],
resource_deps=["celestia-rollkit"],
"validator",
labels=["pocket_network"],
port_forwards=["36657", "36658", "40004"],
)
k8s_resource(
"relayminers",
labels=["blockchains"],
resource_deps=["sequencer"],
labels=["supplier_nodes"],
resource_deps=["validator"],
port_forwards=[
"8545",
"40005",
# Run `curl localhost:9094` to see the current snapshot of relayminer metrics.
"9094:9090"
"9094:9090",
],
)
k8s_resource(
"appgateservers",
labels=["blockchains"],
resource_deps=["sequencer"],
port_forwards=[
"42069",
"40006",
# Run `curl localhost:9093` to see the current snapshot of appgateserver metrics.
"9093:9090"
],
)
k8s_resource("anvil", labels=["blockchains"], port_forwards=["8547"])
if localnet_config["appgateservers"]["count"] > 0:
k8s_resource(
"appgateservers",
labels=["supplier_nodes"],
resource_deps=["validator"],
port_forwards=[
"42069",
"40006",
# Run `curl localhost:9093` to see the current snapshot of appgateserver metrics.
"9093:9090",
],
)
k8s_resource("anvil", labels=["data_nodes"], port_forwards=["8547"])
11 changes: 8 additions & 3 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ accounts:
mnemonic: "crumble shrimp south strategy speed kick green topic stool seminar track stand rhythm almost bubble pet knock steel pull flag weekend country major blade"
coins:
- 69000000000000000000042upokt
- name: sequencer1
- name: validator1
mnemonic: "creek path rule retire evolve vehicle bargain champion roof whisper prize endorse unknown anchor fashion energy club sauce elder parent cotton old affair visa"
coins:
- 900000000000000upokt
Expand Down Expand Up @@ -63,10 +63,15 @@ client:
openapi:
path: docs/static/openapi.yml
validators:
- name: sequencer1
- name: validator1
bonded: 900000000upokt
config:
moniker: "sequencer1"
moniker: "validator1"
consensus:
timeout_commit: "1s"
timeout_propose: "1s"
client:
chain-id: poktroll

# We can persist arbitrary genesis values via 1 to 1 mapping to genesis.json
genesis:
Expand Down
Loading

0 comments on commit 8bf9eaf

Please sign in to comment.