-
Notifications
You must be signed in to change notification settings - Fork 4
Add integration test suite #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
james-toussaint
merged 20 commits into
develop
from
feature/add-protocol-integration-test
Oct 30, 2024
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3672b1b
Add protocol integration test
james-toussaint a096630
Add jenkinsfile for itest
james-toussaint bf6b8a2
Up stack before itest
james-toussaint f130385
Login to registry
james-toussaint 8e8c25c
Increase graphnode healthcheck retries
james-toussaint 147f3bf
Build graphclient in itest
james-toussaint c28d57d
Use apollo client in itest
james-toussaint 253e965
Use testcontainers for itest
james-toussaint 67ece5f
Close chain port 8546 which is not bound after 60s
james-toussaint d862eb8
Wait for graphnode to ingest a few blocks before querying it
james-toussaint ea137fe
Set compose startup time to 2min
james-toussaint 9ce4aa9
Pull chain before itest
james-toussaint e290803
Set compose startup time to 3min
james-toussaint 852f818
Run itest with mocha
james-toussaint 86d9cd9
Increase mocha timeout
james-toussaint b2d1e8f
Remove react dependency
james-toussaint 55e7101
Always docker logout
james-toussaint be41ef5
Update changelog
james-toussaint 47f83b6
Removed exposed ports which already mapped externally
james-toussaint d8ef02f
Move npm install to lower layer
james-toussaint File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ build | |
generated | ||
yarn.lock | ||
test/.bin | ||
subgraph.yaml | ||
subgraph.test.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extension": ["ts"], | ||
"spec": "itest/**/*.ts", | ||
"require": ["ts-node/register"], | ||
"timeout": 600000 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
node('docker') { | ||
stage('Clone') { | ||
cleanWs() | ||
checkoutInfo = checkout(scm) | ||
echo "git checkout: ${checkoutInfo}" | ||
} | ||
stage('Pull images') { | ||
withCredentials([ | ||
usernamePassword(credentialsId: 'docker-regis', | ||
usernameVariable: 'username', passwordVariable: 'password') | ||
]) { | ||
def registry = 'docker-regis.iex.ec' | ||
try { | ||
sh "echo -n '${password}' | docker login --username '${username}' --password-stdin ${registry}" | ||
sh 'cd docker/test/ && docker compose pull chain' | ||
} finally { | ||
sh "docker logout ${registry}" | ||
} | ||
} | ||
} | ||
docker.image('node:22-alpine') | ||
.inside('-v /var/run/docker.sock:/var/run/docker.sock --network=host --user=root') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DamienMure FYI 2 |
||
stage('Init') { | ||
sh 'apk add docker docker-compose' // TODO: Use already built image for a faster job execution | ||
sh 'npm ci' | ||
} | ||
stage('Integration tests') { | ||
sh 'npm run itest' | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM node:22 | ||
WORKDIR /iexec-poco-subgraph | ||
COPY package*.json . | ||
RUN npm ci | ||
COPY schema.graphql . | ||
COPY subgraph.template.yaml . | ||
COPY networks.json . | ||
COPY src src | ||
ENTRYPOINT [ "npm", "run", "deploy:all" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
DATA=/home/tmp/graph-test | ||
DB_USER=graphnode | ||
DB_PASSWORD=somerandompasswordthatishardtoguess | ||
DB_NAME=graphnode | ||
DB_NAME=graphnode-db | ||
NETWORK_NAME=test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,63 @@ | ||
version: "3" | ||
|
||
networks: | ||
thegraph: | ||
blockchain: | ||
|
||
services: | ||
chain: | ||
image: "iexechub/poco-chaintest:5.3.0-token-parity" | ||
image: docker-regis.iex.ec/poco-chain:1.0.0-poco-v5.5.0-voucher-v1.0.0-nethermind | ||
restart: unless-stopped | ||
networks: | ||
- blockchain | ||
expose: | ||
- 8545 | ||
- 8546 | ||
ports: | ||
- 8545:8545 | ||
- 8546:8546 | ||
# - 8546:8546 # port (not required for integration tests) fails to open on CI | ||
|
||
ipfs: | ||
image: ipfs/go-ipfs:v0.10.0 | ||
restart: unless-stopped | ||
networks: | ||
- thegraph | ||
image: ipfs/go-ipfs:v0.22.0 | ||
ports: | ||
- 8080:8080 | ||
- 5001:5001 | ||
volumes: | ||
- ${DATA}/ipfs:/data/ipfs | ||
|
||
postgres: | ||
image: postgres:12 | ||
graphnode-postgres: | ||
image: postgres:16.4 | ||
restart: unless-stopped | ||
networks: | ||
- thegraph | ||
command: | ||
- "postgres" | ||
- "-cshared_preload_libraries=pg_stat_statements" | ||
ports: | ||
- 5432:5432 | ||
expose: | ||
- 5432 | ||
environment: | ||
POSTGRES_USER: "${DB_USER}" | ||
POSTGRES_PASSWORD: "${DB_PASSWORD}" | ||
POSTGRES_DB: "${DB_NAME}" | ||
POSTGRES_USER: ${DB_USER} | ||
POSTGRES_PASSWORD: ${DB_PASSWORD} | ||
POSTGRES_DB: ${DB_NAME} | ||
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C" | ||
|
||
graphnode: | ||
image: graphprotocol/graph-node:v0.27.0 | ||
image: graphprotocol/graph-node:v0.35.1 | ||
restart: unless-stopped | ||
networks: | ||
- blockchain | ||
- thegraph | ||
depends_on: | ||
- ipfs | ||
- postgres | ||
- chain | ||
ports: | ||
- 8000:8000 # http | ||
- 8001:8001 # ws | ||
- 8020:8020 # deploy | ||
- 8030:8030 # monitoring | ||
- 8040:8040 # prometeus | ||
- 8000:8000 # GraphQL HTTP | ||
# - 8001:8001 # GraphQL WS | ||
- 8020:8020 # admin RPC | ||
# - 8040:8040 # metrics | ||
environment: | ||
postgres_host: graphnode-postgres | ||
postgres_port: 5432 | ||
postgres_user: ${DB_USER} | ||
postgres_pass: ${DB_PASSWORD} | ||
postgres_db: ${DB_NAME} | ||
ipfs: ipfs:5001 | ||
ethereum: ${NETWORK_NAME}:http://chain:8545 | ||
healthcheck: | ||
test: netcat -w 1 0.0.0.0 8020 | ||
interval: 10s | ||
timeout: 5s | ||
retries: 10 | ||
start_period: 30s | ||
|
||
poco-subgraph-deployer: | ||
build: | ||
context: ../.. | ||
dockerfile: docker/Dockerfile | ||
environment: | ||
RUST_BACKTRACE: 1 | ||
postgres_host: postgres | ||
postgres_user: "${DB_USER}" | ||
postgres_pass: "${DB_PASSWORD}" | ||
postgres_db: "${DB_NAME}" | ||
ipfs: "ipfs:5001" | ||
ethereum: "test:http://chain:8545" | ||
GRAPH_NODE_ID: "graphnode_id" | ||
GRAPHNODE_URL: http://graphnode:8020 | ||
IPFS_URL: http://ipfs:5001 | ||
NETWORK_NAME: ${NETWORK_NAME} | ||
depends_on: | ||
graphnode: | ||
condition: service_healthy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { ApolloClient, gql, InMemoryCache } from '@apollo/client'; | ||
import { equal } from 'assert'; | ||
import { DockerComposeEnvironment, Wait } from 'testcontainers'; | ||
|
||
const SECONDS = 1000; | ||
const MINUTES = 60 * SECONDS; | ||
const APIURL = 'http://localhost:8000/subgraphs/name/test/poco'; | ||
const client = new ApolloClient({ | ||
uri: APIURL, | ||
cache: new InMemoryCache(), | ||
}); | ||
|
||
describe('Integration tests', () => { | ||
/** | ||
* Services are started only once before running all tests to get a decent test | ||
* suite duration with multiple tests. Please switch to `beforeEach` if necessary. | ||
* Shutdown of services is handled by `testcontainers` framework. | ||
*/ | ||
before(async () => { | ||
console.log('Starting services..'); | ||
const environment = new DockerComposeEnvironment('docker/test/', 'docker-compose.yml') | ||
.withStartupTimeout(3 * MINUTES) | ||
.withWaitStrategy( | ||
'poco-subgraph-deployer-1', | ||
Wait.forLogMessage( | ||
'Deployed to http://graphnode:8000/subgraphs/name/test/poco/graphql', | ||
), | ||
); | ||
await environment.up(); | ||
const secondsToWait = 5; | ||
console.log( | ||
`Waiting ${secondsToWait}s for graphnode to ingest a few blocks before querying it..`, | ||
); | ||
await new Promise((resolve) => { | ||
return setTimeout(resolve, secondsToWait * SECONDS); | ||
}); | ||
}); | ||
|
||
it('should get protocol', async () => { | ||
const result = await client.query({ | ||
query: gql(` | ||
query { | ||
protocol(id: "iExec") { | ||
id | ||
tvl | ||
} | ||
} | ||
`), | ||
}); | ||
const protocol = result.data.protocol; | ||
equal(protocol.id, 'iExec'); | ||
equal(protocol.tvl, '0.02025'); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"test": { | ||
"ERC1538": { | ||
"address": "0xc4b11f41746D3Ad8504da5B383E1aB9aa969AbC7", | ||
"startBlock": 0 | ||
}, | ||
"Core": { | ||
"address": "0xc4b11f41746D3Ad8504da5B383E1aB9aa969AbC7", | ||
"startBlock": 0 | ||
}, | ||
"AppRegistry": { | ||
"address": "0xd5Fe43e3cDD29812949dc9b368345537D7B73001", | ||
"startBlock": 0 | ||
}, | ||
"DatasetRegistry": { | ||
"address": "0xf3bd0602fA481230271c5396f146e5695D3750A6", | ||
"startBlock": 0 | ||
}, | ||
"WorkerpoolRegistry": { | ||
"address": "0x6Cb57fA761812c34645C945cA89AAe3602D42eD3", | ||
"startBlock": 0 | ||
} | ||
}, | ||
"bellecour": { | ||
"ERC1538": { | ||
"address": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f", | ||
"startBlock": 4543300 | ||
}, | ||
"Core": { | ||
"address": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f", | ||
"startBlock": 4543300 | ||
}, | ||
"AppRegistry": { | ||
"address": "0xB1C52075b276f87b1834919167312221d50c9D16", | ||
"startBlock": 4543300 | ||
}, | ||
"DatasetRegistry": { | ||
"address": "0x799DAa22654128d0C64d5b79eac9283008158730", | ||
"startBlock": 4543300 | ||
}, | ||
"WorkerpoolRegistry": { | ||
"address": "0xC76A18c78B7e530A165c5683CB1aB134E21938B4", | ||
"startBlock": 4543300 | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DamienMure FYI 1