Commit 88807f03 authored by Kelvin Fichter's avatar Kelvin Fichter

feat(itests): add basic healthcheck tests

Adds a single simple test to confirm that the healthcheck metrics server
is running. If the server is not running then the healthcheck server
likely did not start correctly and there might be an issue in the docker
container.
parent 032731b5
---
'@eth-optimism/integration-tests': patch
---
Add integration test for healthcheck server
...@@ -154,6 +154,7 @@ jobs: ...@@ -154,6 +154,7 @@ jobs:
--env L2_GAS_PRICE=onchain \ --env L2_GAS_PRICE=onchain \
--env RUN_DEBUG_TRACE_TESTS=false \ --env RUN_DEBUG_TRACE_TESTS=false \
--env RUN_REPLICA_TESTS=false \ --env RUN_REPLICA_TESTS=false \
--env RUN_HEALTHCHECK_TESTS=false \
--env RUN_STRESS_TESTS=false \ --env RUN_STRESS_TESTS=false \
--env OVMCONTEXT_SPEC_NUM_TXS=1 \ --env OVMCONTEXT_SPEC_NUM_TXS=1 \
--env DTL_ENQUEUE_CONFIRMATIONS=12 \ --env DTL_ENQUEUE_CONFIRMATIONS=12 \
...@@ -252,7 +253,7 @@ workflows: ...@@ -252,7 +253,7 @@ workflows:
- develop - develop
jobs: jobs:
- build-dtl: - build-dtl:
context: context:
- optimism - optimism
- slack - slack
<<: *slack-nightly-build-fail-post-step <<: *slack-nightly-build-fail-post-step
...@@ -331,4 +332,4 @@ workflows: ...@@ -331,4 +332,4 @@ workflows:
} }
] ]
} }
event: always event: always
\ No newline at end of file
...@@ -50,7 +50,7 @@ jobs: ...@@ -50,7 +50,7 @@ jobs:
working-directory: ./ops working-directory: ./ops
run: | run: |
./scripts/stats.sh & ./scripts/stats.sh &
docker-compose -f docker-compose.yml up -d docker-compose -f docker-compose.yml up -d --scale replica-healthcheck=1
- name: Wait for the Sequencer node - name: Wait for the Sequencer node
working-directory: ./ops working-directory: ./ops
......
...@@ -10,8 +10,9 @@ OVMCONTEXT_SPEC_NUM_TXS=1 ...@@ -10,8 +10,9 @@ OVMCONTEXT_SPEC_NUM_TXS=1
RUN_WITHDRAWAL_TESTS=false RUN_WITHDRAWAL_TESTS=false
RUN_DEBUG_TRACE_TESTS=false RUN_DEBUG_TRACE_TESTS=false
RUN_REPLICA_TESTS=false RUN_REPLICA_TESTS=false
RUN_HEALTHCHECK_TESTS=false
RUN_STRESS_TESTS=false RUN_STRESS_TESTS=false
# Can be configured up or down as necessary # Can be configured up or down as necessary
MOCHA_TIMEOUT=300000 MOCHA_TIMEOUT=300000
# Set to true to make Mocha stop after the first failed test. # Set to true to make Mocha stop after the first failed test.
MOCHA_BAIL=false MOCHA_BAIL=false
\ No newline at end of file
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
"hardhat-gas-reporter": "^1.0.4", "hardhat-gas-reporter": "^1.0.4",
"lint-staged": "11.0.0", "lint-staged": "11.0.0",
"mocha": "^8.4.0", "mocha": "^8.4.0",
"node-fetch": "^2.6.7",
"prom-client": "^14.0.1", "prom-client": "^14.0.1",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.3.5", "typescript": "^4.3.5",
......
import fetch from 'node-fetch'
import { expect } from './shared/setup'
import { envConfig } from './shared/utils'
describe('Healthcheck Tests', () => {
before(async function () {
if (!envConfig.RUN_HEALTHCHECK_TESTS) {
this.skip()
}
})
// Super simple test, is the metric server up?
it('should have metrics exposed', async () => {
const response = await fetch(envConfig.HEALTHCHECK_URL)
expect(response.status).to.equal(200)
})
})
...@@ -56,6 +56,8 @@ const procEnv = cleanEnv(process.env, { ...@@ -56,6 +56,8 @@ const procEnv = cleanEnv(process.env, {
VERIFIER_URL: str({ default: 'http://localhost:8547' }), VERIFIER_URL: str({ default: 'http://localhost:8547' }),
HEALTHCHECK_URL: str({ default: 'http://localhost:7300/metrics' }),
PRIVATE_KEY: str({ PRIVATE_KEY: str({
default: default:
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
...@@ -78,6 +80,9 @@ const procEnv = cleanEnv(process.env, { ...@@ -78,6 +80,9 @@ const procEnv = cleanEnv(process.env, {
RUN_REPLICA_TESTS: bool({ RUN_REPLICA_TESTS: bool({
default: true, default: true,
}), }),
RUN_HEALTHCHECK_TESTS: bool({
default: true,
}),
RUN_DEBUG_TRACE_TESTS: bool({ RUN_DEBUG_TRACE_TESTS: bool({
default: true, default: true,
}), }),
......
...@@ -202,7 +202,7 @@ services: ...@@ -202,7 +202,7 @@ services:
- l2geth - l2geth
- replica - replica
deploy: deploy:
replicas: 1 replicas: 0
build: build:
context: .. context: ..
dockerfile: ./ops/docker/Dockerfile.packages dockerfile: ./ops/docker/Dockerfile.packages
...@@ -226,6 +226,7 @@ services: ...@@ -226,6 +226,7 @@ services:
environment: environment:
L1_URL: http://l1_chain:8545 L1_URL: http://l1_chain:8545
L2_URL: http://l2geth:8545 L2_URL: http://l2geth:8545
HEALTHCHECK_URL: http://replica-healthcheck:7300/metrics
REPLICA_URL: http://replica:8545 REPLICA_URL: http://replica:8545
VERIFIER_URL: http://verifier:8545 VERIFIER_URL: http://verifier:8545
URL: http://deployer:8081/addresses.json URL: http://deployer:8081/addresses.json
......
...@@ -11520,7 +11520,7 @@ node-fetch@2.6.1: ...@@ -11520,7 +11520,7 @@ node-fetch@2.6.1:
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
node-fetch@^2.6.0, node-fetch@^2.6.1: node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7:
version "2.6.7" version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment