Skip to content

Commit

Permalink
Fix incorrect exit codes and split doppelganger tests on CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmygchen committed May 31, 2024
1 parent 5aa0b56 commit 8f35e7f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 15 deletions.
53 changes: 41 additions & 12 deletions .github/workflows/local-testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
steps:
- uses: actions/checkout@v4

# TODO: Add to self-hosted runner image
- name: Install dependencies
run: |
sudo add-apt-repository ppa:rmescandon/yq
Expand Down Expand Up @@ -77,20 +76,17 @@ jobs:
- name: Upload logs artifact
uses: actions/upload-artifact@v4
with:
name: local-testnet-logs
name: logs-local-testnet
path: |
scripts/local_testnet/logs
retention-days: 3

doppelganger-protection-test:
doppelganger-protection-success-test:
needs: dockerfile-ubuntu
runs-on: ubuntu-22.04
# FIXME kurtosis crashes pretty badly on self hosted runner
# runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "CI", "small"]') || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4

# TODO: Add to self-hosted runner image
- name: Install dependencies
run: |
sudo add-apt-repository ppa:rmescandon/yq
Expand All @@ -108,24 +104,56 @@ jobs:
- name: Load Docker image
run: docker load -i lighthouse-docker.tar

- name: Run the doppelganger protection failure test script
- name: Run the doppelganger protection success test script
run: |
./doppelganger_protection.sh failure
./doppelganger_protection.sh success
working-directory: scripts/tests

- name: Run the doppelganger protection success test script
- name: Upload logs artifact
uses: actions/upload-artifact@v4
with:
name: logs-doppelganger-protection-success
path: |
scripts/local_testnet/logs
retention-days: 3

doppelganger-protection-failure-test:
needs: dockerfile-ubuntu
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
./doppelganger_protection.sh success
sudo add-apt-repository ppa:rmescandon/yq
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install -y kurtosis-cli yq
kurtosis analytics disable
- name: Download Docker image artifact
uses: actions/download-artifact@v4
with:
name: lighthouse-docker
path: .

- name: Load Docker image
run: docker load -i lighthouse-docker.tar

- name: Run the doppelganger protection failure test script
run: |
./doppelganger_protection.sh failure
working-directory: scripts/tests

- name: Upload logs artifact
uses: actions/upload-artifact@v4
with:
name: local-testnet-logs
name: logs-local-testnet
path: |
scripts/local_testnet/logs
retention-days: 3


# This job succeeds ONLY IF all others succeed. It is used by the merge queue to determine whether
# a PR is safe to merge. New jobs should be added here.
local-testnet-success:
Expand All @@ -134,7 +162,8 @@ jobs:
needs: [
'dockerfile-ubuntu',
'run-local-testnet',
'doppelganger-protection-test'
'doppelganger-protection-success-test',
'doppelganger-protection-failure-test',
]
steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 5 additions & 3 deletions scripts/tests/doppelganger_protection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,16 @@ if [[ "$BEHAVIOR" == "failure" ]]; then
--enable-doppelganger-protection \
--suggested-fee-recipient 0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990

# Check if doppelganger VC has stopped and exited. Exit code 1 means the check timed out and VC is still running.
check_exit_cmd="until [ \$(get_service_status $service_name) != 'RUNNING' ]; do sleep 1; done"
doppelganger_exit=$(run_command_without_exit "timeout $(( $SECONDS_PER_SLOT * 32 * 2 )) bash -c \"$check_exit_cmd\"")

if [[ $doppelganger_exit -eq 1 ]]; then
echo "Test passed: doppelganger found and VC process stopped successfully."
exit_and_dump_logs 0
else
echo "Test failed: expected doppelganger but VC is still running. Check the logs for details."
exit_and_dump_logs 1
else
echo "Test passed: doppelganger found and VC process stopped successfully."
exit_and_dump_logs 0
fi

fi
Expand Down Expand Up @@ -144,6 +145,7 @@ if [[ "$BEHAVIOR" == "success" ]]; then
for val in 0x*; do
[[ -e $val ]] || continue
is_attester=$(run_command_without_exit "curl -s $bn2_2_local_url/lighthouse/validator_inclusion/3/$val | jq | grep -q '"is_previous_epoch_target_attester": false'")
echo $is_attester
if [[ $is_attester -eq 0 ]]; then
echo "$val did not attest in epoch 2."
else
Expand Down

0 comments on commit 8f35e7f

Please sign in to comment.