Skip to content

Commit 3a84f2e

Browse files
Web3 Philosopherblasrodriobsessed-cake
authored
Adds integration testing infra (#90)
* wip * fix dockerfile * adds para_id to config.yml * adds para_id to config.yml * this docker image requires a super computer to run lol. froze my m1 max, 64GB * oof * use a lighter image * don't ignore rococo-local.json * import changes from PR #86 Signed-off-by: Blas Rodriguez Irizar <[email protected]> * updated branch name o n hyperspace-docker-image action * wait for docker to launch * add hyperspace Makefile Signed-off-by: Blas Rodriguez Irizar <[email protected]> * wait for polkadot launch in test action * add this branch to trigger the action * Update CI config * Update CI config * Add a step to install docker-compose * update workflow for test * get paritytech/ci-linux:production back * try with custom image * source bashrc * add bash shell * rm shell and don't assume PATH works * Install docker Signed-off-by: Blas Rodriguez Irizar <[email protected]> * trying to add shell again * actions not happy with shell at all * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Add hyperspace/Dockerfile * Update CI config * Update CI config * Update CI config * Remove hyperspace/Dockerfile * Remove hyperspace/Dockerfile * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update scripts/hyperspace.Dockerfile * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Update CI config * Add possibility to change relaychain and parachain IPs for the build script of grandpa-prover crate * Update CI config * Add possibility to change relaychain and parachain IPs for the build script of beefy-prover crate * Add possibility to change relaychain and parachain IPs for the build script of hyperspace-parachain crate * use correct host for hyperspace-testsuite * use proper host for all integration tests * query session lenghth for grandpa-light-client-verifier tests Signed-off-by: Blas Rodriguez Irizar <[email protected]> Co-authored-by: Blas Rodriguez Irizar <[email protected]> Co-authored-by: Obsessed Cake <[email protected]>
1 parent 282906c commit 3a84f2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2753
-63
lines changed

.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
**/target
2+
**/node_modules
3+
**/.git
4+
**/.github
5+
scripts/

.github/workflows/checks.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
pull_request:
55
branches:
66
- '*'
7+
push:
8+
branches:
9+
- master
10+
711

812
jobs:
913
checker:
@@ -35,4 +39,4 @@ jobs:
3539
run: ./scripts/no_std_checks.sh
3640

3741
- name: pallet-ibc check benchmarks
38-
run: cargo test -p pallet-ibc --features=runtime-benchmarks
42+
run: cargo test -p pallet-ibc --release --locked --features=runtime-benchmarks
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Build and publish Hyperspace Docker image"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- seun/integration-test # tmp
9+
10+
jobs:
11+
build-and-publish:
12+
runs-on: ubuntu-latest
13+
concurrency:
14+
group: hyperspace-docker-image-${{ github.ref }}
15+
cancel-in-progress: true
16+
strategy:
17+
fail-fast: true
18+
19+
steps:
20+
- name: Clean up
21+
continue-on-error: true
22+
run: |
23+
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
24+
docker system prune --force --all --volumes
25+
26+
- uses: actions/checkout@v2
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Login to DockerHub
31+
uses: docker/login-action@v1
32+
with:
33+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
34+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
35+
36+
- name: Build Docker image
37+
run: make -f hyperspace/Makefile build-docker-image-hyperspace
38+
39+
- name: Docker push
40+
run: make -f hyperspace/Makefile publish-docker-image-hyperspace

.github/workflows/lint.yml

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request:
55
branches:
66
- '*'
7+
push:
8+
branches:
9+
- master
710

811
jobs:
912
linters:

.github/workflows/test.yml

+99-12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request:
55
branches:
66
- '*'
7+
push:
8+
branches:
9+
- master
710

811
jobs:
912
linters:
@@ -12,28 +15,112 @@ jobs:
1215
group: tests-${{ github.ref }}
1316
cancel-in-progress: true
1417
container:
15-
image: paritytech/ci-linux:production
16-
runs-on: [ubuntu-latest]
18+
image: ubuntu:jammy
19+
# options: --privileged
20+
runs-on:
21+
- self-hosted
22+
- sre
1723
steps:
1824
- uses: actions/checkout@v2
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup deps
29+
run: |
30+
apt update -y
31+
apt install -y \
32+
curl \
33+
netcat \
34+
iproute2 \
35+
gcc \
36+
g++ \
37+
build-essential \
38+
clang \
39+
libclang-dev \
40+
pkg-config \
41+
libssl-dev
42+
43+
# Get Rust
44+
curl https://sh.rustup.rs -sSf | bash -s -- -y
45+
$HOME/.cargo/bin/rustup toolchain install nightly
46+
47+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
48+
49+
- name: Rustup show
50+
run: $HOME/.cargo/bin/rustup show
1951

2052
- name: Install Protoc
2153
uses: arduino/setup-protoc@v1
2254
with:
2355
version: '3.x'
2456

25-
- name: Rustup show
26-
run: rustup show
27-
2857
- name: Install latest nextest release
2958
uses: taiki-e/install-action@nextest
3059

60+
- name: Install Docker
61+
run: |
62+
apt-get install -y \
63+
ca-certificates \
64+
gnupg \
65+
lsb-release
66+
67+
mkdir -p /etc/apt/keyrings
68+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
69+
70+
echo \
71+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
72+
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
73+
74+
apt-get update
75+
apt-get install -y \
76+
docker-ce \
77+
docker-ce-cli \
78+
containerd.io \
79+
docker-compose-plugin
80+
81+
docker --version
82+
83+
- name: Install docker-compose
84+
run: |
85+
curl -L "https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-$(uname -s)-$(uname -m)" -o ./docker-compose
86+
chmod +x ./docker-compose
87+
88+
- name: Store network gateway IP
89+
run: |
90+
# GATEWAY_IP equals host ip where this docker container was ran, this ip has access to Docker port mapping.
91+
GATEWAY_IP=$(ip r l | grep default | awk '{print $3}')
92+
echo "GATEWAY_IP=$GATEWAY_IP" >> $GITHUB_ENV
93+
echo "RELAY_HOST=$GATEWAY_IP" >> $GITHUB_ENV
94+
echo "PARA_HOST=$GATEWAY_IP" >> $GITHUB_ENV
95+
96+
- name: Run local parachain cluster
97+
run: |
98+
# DOCKER_BUILDKIT=0 docker build --platform linux/amd64 -f scripts/parachain.Dockerfile . -t parachain-node:latest
99+
./docker-compose -f scripts/parachain-launch/docker-compose.yml up --detach --build
100+
# ./docker-compose -f scripts/parachain-launch/docker-compose.yml ps
101+
./scripts/wait_for_tcp_port_opening.sh $GATEWAY_IP 9944
102+
./scripts/wait_for_tcp_port_opening.sh $GATEWAY_IP 9188
103+
# sleep 60
104+
# echo "# ip -o a"
105+
# ip -o a
106+
# echo "# ip r l"
107+
# ip r l
108+
# echo "# ss -nltp"
109+
# ss -nltp
110+
111+
- name: Check that subxt-generated is up to date
112+
run: |
113+
./scripts/generate-subxt.sh
114+
# git status --porcelain
115+
31116
- name: Run all unit tests
32117
run: |
33-
SKIP_WASM_BUILD=1 cargo +nightly nextest run --workspace \
34-
--exclude ibc-derive \
35-
--exclude ics10-grandpa \
36-
--exclude ics11-beefy \
37-
--exclude hyperspace-testsuite \
38-
--exclude grandpa-light-client-verifier \
39-
--exclude beefy-light-client \
118+
SKIP_WASM_BUILD=1 cargo +nightly nextest run --locked --release --workspace --exclude ibc-derive --exclude hyperspace-testsuite
119+
120+
- name: Run hyperspace integration tests
121+
run: |
122+
cargo +nightly test -p hyperspace-testsuite --locked --release
123+
124+
- name: Termintate local parachain cluster
125+
run: |
126+
./docker-compose -f scripts/parachain-launch/docker-compose.yml down -v

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
## no embedded chain specs
55
rococo-dev-raw.json
66
rococo-local-raw.json
7-
rococo-local.json
87
rococo-dev.json
98
kusama-local.json
109
kusama-local-raw.json

Cargo.lock

+5-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

algorithms/beefy/prover/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ targets = ["x86_64-unknown-linux-gnu"]
99

1010
[build-dependencies]
1111
anyhow = "1.0.66"
12-
tokio = { version = "1.19.2", features = ["macros", "rt-multi-thread"] }
12+
once_cell = "1.16.0"
1313
subxt-codegen = { package = "codegen", path = "../../../utils/subxt/codegen" }
14+
tokio = { version = "1.19.2", features = ["macros", "rt-multi-thread"] }
1415

1516
[dependencies]
1617
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }

algorithms/beefy/prover/build.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16+
use once_cell::sync::Lazy;
17+
18+
static RELAY_URL: Lazy<String> = Lazy::new(|| {
19+
let ip = std::env::var("RELAY_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
20+
format!("ws://{}:9944", ip)
21+
});
22+
1623
#[tokio::main]
1724
async fn main() -> anyhow::Result<()> {
1825
if cfg!(feature = "build-metadata-from-ws") {
19-
subxt_codegen::build_script("ws://127.0.0.1:9944", "runtime").await?;
26+
subxt_codegen::build_script(&RELAY_URL, "runtime").await?;
2027
}
2128
Ok(())
2229
}

algorithms/beefy/verifier/src/tests.rs

+24-10
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,18 @@ use subxt::{
3535
#[tokio::test]
3636
#[ignore]
3737
async fn test_verify_mmr_with_proof() {
38-
let url = std::env::var("NODE_ENDPOINT").unwrap_or("ws://127.0.0.1:9944".to_string());
39-
let client = subxt::client::OnlineClient::<PolkadotConfig>::from_url(url).await.unwrap();
40-
let para_url = std::env::var("PARA_NODE_ENDPOINT").unwrap_or("ws://127.0.0.1:9188".to_string());
41-
let para_client =
42-
subxt::client::OnlineClient::<PolkadotConfig>::from_url(para_url).await.unwrap();
38+
let relay = std::env::var("RELAY_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
39+
let para = std::env::var("PARA_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
40+
41+
let relay_ws_url = format!("ws://{relay}:9944");
42+
let para_ws_url = format!("ws://{para}:9188");
43+
44+
let client = subxt::client::OnlineClient::<PolkadotConfig>::from_url(relay_ws_url)
45+
.await
46+
.unwrap();
47+
let para_client = subxt::client::OnlineClient::<PolkadotConfig>::from_url(para_ws_url)
48+
.await
49+
.unwrap();
4350

4451
let mut client_state = Prover::get_initial_client_state(Some(&client)).await;
4552
let subscription: Subscription<String> = client
@@ -197,11 +204,18 @@ async fn should_fail_with_invalid_validator_set_id() {
197204
#[tokio::test]
198205
#[ignore]
199206
async fn verify_parachain_headers() {
200-
let url = std::env::var("NODE_ENDPOINT").unwrap_or("ws://127.0.0.1:9944".to_string());
201-
let client = subxt::client::OnlineClient::<PolkadotConfig>::from_url(url).await.unwrap();
202-
let para_url = std::env::var("PARA_NODE_ENDPOINT").unwrap_or("ws://127.0.0.1:9188".to_string());
203-
let para_client =
204-
subxt::client::OnlineClient::<PolkadotConfig>::from_url(para_url).await.unwrap();
207+
let relay = std::env::var("RELAY_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
208+
let para = std::env::var("PARA_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
209+
210+
let relay_ws_url = format!("ws://{relay}:9944");
211+
let para_ws_url = format!("ws://{para}:9188");
212+
213+
let client = subxt::client::OnlineClient::<PolkadotConfig>::from_url(relay_ws_url)
214+
.await
215+
.unwrap();
216+
let para_client = subxt::client::OnlineClient::<PolkadotConfig>::from_url(para_ws_url)
217+
.await
218+
.unwrap();
205219

206220
let mut client_state = Prover::get_initial_client_state(Some(&client)).await;
207221
let subscription: Subscription<String> = client

algorithms/grandpa/prover/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ authors = ["Seun Lanlege <[email protected]>"]
66

77
[build-dependencies]
88
anyhow = "1.0.66"
9+
once_cell = "1.16.0"
910
tokio = { version = "1.19.2", features = ["macros", "rt-multi-thread"] }
1011
subxt-codegen = { package = "codegen", path = "../../../utils/subxt/codegen" }
1112

algorithms/grandpa/prover/build.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,23 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16+
use once_cell::sync::Lazy;
17+
18+
static RELAY_URL: Lazy<String> = Lazy::new(|| {
19+
let ip = std::env::var("RELAY_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
20+
format!("ws://{}:9944", ip)
21+
});
22+
23+
static PARA_URL: Lazy<String> = Lazy::new(|| {
24+
let ip = std::env::var("PARA_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
25+
format!("ws://{}:9188", ip)
26+
});
27+
1628
#[tokio::main]
1729
async fn main() -> anyhow::Result<()> {
1830
if cfg!(feature = "build-metadata-from-ws") {
19-
subxt_codegen::build_script("ws://127.0.0.1:9944", "polkadot").await?;
20-
subxt_codegen::build_script("ws://127.0.0.1:9188", "parachain").await?;
31+
subxt_codegen::build_script(&RELAY_URL, "polkadot").await?;
32+
subxt_codegen::build_script(&PARA_URL, "parachain").await?;
2133
}
2234
Ok(())
2335
}

algorithms/grandpa/verifier/src/tests.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,26 @@ async fn follow_grandpa_justifications() {
3939
.format_module_path(false)
4040
.init();
4141

42-
let relay_ws_url = std::env::var("NODE_ENDPOINT").unwrap_or("ws://127.0.0.1:9944".to_string());
43-
let para_ws_url =
44-
std::env::var("PARA_NODE_ENDPOINT").unwrap_or("ws://127.0.0.1:9188".to_string());
42+
let relay = std::env::var("RELAY_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
43+
let para = std::env::var("PARA_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
44+
45+
let relay_ws_url = format!("ws://{relay}:9944");
46+
let para_ws_url = format!("ws://{para}:9188");
4547

4648
let prover = GrandpaProver::<PolkadotConfig>::new(&relay_ws_url, &para_ws_url, 2000)
4749
.await
4850
.unwrap();
4951

5052
println!("Waiting for grandpa proofs to become available");
53+
let session_length = prover.session_length().await.unwrap();
5154
prover
5255
.relay_client
5356
.rpc()
5457
.subscribe_blocks()
5558
.await
5659
.unwrap()
5760
.filter_map(|result| futures::future::ready(result.ok()))
58-
.skip_while(|h| futures::future::ready(h.number < 90))
61+
.skip_while(|h| futures::future::ready(h.number < (session_length * 2) + 10))
5962
.take(1)
6063
.collect::<Vec<_>>()
6164
.await;

0 commit comments

Comments
 (0)