mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-11 15:21:10 +00:00
Merge pull request #365 from paritytech/jsdw-minor-fixes
Jsdw minor fixes
This commit is contained in:
+119
-16
@@ -3,33 +3,46 @@ name: Backend CI
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- '.github/workflows/backend.yml'
|
||||
- 'backend/**'
|
||||
- '!frontend/**'
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./backend
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
name: Check Code
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2.3.4
|
||||
|
||||
- name: Build telemetry executables (in debug mode)
|
||||
working-directory: ./backend
|
||||
run: cargo build --bins --verbose
|
||||
- name: Install Rust stable toolchain
|
||||
uses: actions-rs/toolchain@v1.0.7
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Run tests
|
||||
working-directory: ./backend
|
||||
run: cargo test --verbose
|
||||
- name: Rust Cache
|
||||
uses: Swatinem/rust-cache@v1.3.0
|
||||
with:
|
||||
working-directory: backend
|
||||
|
||||
- name: Build, release and call telemetry executable
|
||||
working-directory: ./backend
|
||||
run: cargo run --bin telemetry_core --release -- --help
|
||||
- name: Build
|
||||
run: cargo check --all-targets
|
||||
|
||||
- name: Build, release and call shard executable
|
||||
working-directory: ./backend
|
||||
run: cargo run --bin telemetry_shard --release -- --help
|
||||
docker:
|
||||
name: Push tagged images to docker
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2.3.4
|
||||
|
||||
- name: Login to Dockerhub
|
||||
uses: docker/login-action@v1
|
||||
@@ -44,3 +57,93 @@ jobs:
|
||||
push: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
tags: parity/substrate-telemetry-backend:latest
|
||||
# add_git_labels: true
|
||||
|
||||
fmt:
|
||||
name: Run rustfmt
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2.3.4
|
||||
|
||||
- name: Install Rust stable toolchain
|
||||
uses: actions-rs/toolchain@v1.0.7
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
components: clippy, rustfmt
|
||||
|
||||
- name: Rust Cache
|
||||
uses: Swatinem/rust-cache@v1.3.0
|
||||
with:
|
||||
working-directory: backend
|
||||
|
||||
- name: Cargo fmt
|
||||
run: cargo fmt --all -- --check
|
||||
|
||||
docs:
|
||||
name: Check Documentation
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2.3.4
|
||||
|
||||
- name: Install Rust stable toolchain
|
||||
uses: actions-rs/toolchain@v1.0.7
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Rust Cache
|
||||
uses: Swatinem/rust-cache@v1.3.0
|
||||
with:
|
||||
working-directory: backend
|
||||
|
||||
- name: Check internal documentation links
|
||||
run: RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --verbose --workspace --no-deps --document-private-items
|
||||
|
||||
tests:
|
||||
name: Run tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2.3.4
|
||||
|
||||
- name: Install Rust stable toolchain
|
||||
uses: actions-rs/toolchain@v1.0.7
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Rust Cache
|
||||
uses: Swatinem/rust-cache@v1.3.0
|
||||
with:
|
||||
working-directory: backend
|
||||
|
||||
- name: Cargo test
|
||||
run: cargo test --verbose --jobs 1
|
||||
|
||||
e2e:
|
||||
name: Run potentially brittle E2E tests
|
||||
continue-on-error: true
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2.3.4
|
||||
|
||||
- name: Install Rust stable toolchain
|
||||
uses: actions-rs/toolchain@v1.0.7
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Rust Cache
|
||||
uses: Swatinem/rust-cache@v1.3.0
|
||||
with:
|
||||
working-directory: backend
|
||||
|
||||
- name: Cargo test
|
||||
run: cargo test --verbose --jobs 1 e2e -- --ignored
|
||||
|
||||
@@ -6,13 +6,16 @@ name: Frontend CI
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- '.github/workflows/frontend.yml'
|
||||
- 'frontend/**'
|
||||
- '!backend/**'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./frontend
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
@@ -21,27 +24,30 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: install
|
||||
working-directory: ./frontend
|
||||
run: yarn install
|
||||
|
||||
- name: check
|
||||
run: yarn pretty:check
|
||||
working-directory: ./frontend
|
||||
|
||||
- name: Test
|
||||
run: yarn test
|
||||
working-directory: ./frontend
|
||||
|
||||
- name: Build
|
||||
working-directory: ./frontend
|
||||
run: yarn build
|
||||
|
||||
- name: Login to Dockerhub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and Push template image
|
||||
uses: docker/build-push-action@v2 # https://github.com/docker/build-push-action
|
||||
if: matrix.node-version == '12.x'
|
||||
|
||||
+4
-4
@@ -17,8 +17,8 @@ stages:
|
||||
stage: dockerize
|
||||
image: quay.io/buildah/stable
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "jsdw-sharding"'
|
||||
when: manual
|
||||
- if: '$CI_COMMIT_BRANCH == "master"'
|
||||
# when: manual # uncomment this line if we want to make this step a manual process
|
||||
tags:
|
||||
- kubernetes-parity-build
|
||||
|
||||
@@ -54,8 +54,8 @@ stages:
|
||||
--set image.frontend.tag="${CI_COMMIT_SHORT_SHA}"
|
||||
$KUBE_NAMESPACE ./helm/
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "jsdw-sharding"'
|
||||
when: manual
|
||||
- if: '$CI_COMMIT_BRANCH == "master"'
|
||||
# when: manual # uncomment this line if we want to make this step a manual process
|
||||
tags:
|
||||
- kubernetes-parity-build
|
||||
|
||||
|
||||
@@ -96,16 +96,16 @@ impl Chain {
|
||||
}
|
||||
}
|
||||
|
||||
/// Can we add a node? If not, it's because the chain is at its quota.
|
||||
/// Is the chain the node belongs to overquota?
|
||||
pub fn is_overquota(&self) -> bool {
|
||||
// Dynamically determine the max nodes based on the most common
|
||||
// label so far, in case it changes to something with a different limit.
|
||||
self.nodes.len() < max_nodes(self.labels.best())
|
||||
self.nodes.len() >= max_nodes(self.labels.best())
|
||||
}
|
||||
|
||||
/// Assign a node to this chain.
|
||||
pub fn add_node(&mut self, node: Node) -> AddNodeResult {
|
||||
if !self.is_overquota() {
|
||||
if self.is_overquota() {
|
||||
return AddNodeResult::Overquota;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,12 @@ ulimit -n 100000
|
||||
sudo sysctl -w kern.ipc.somaxconn=100000
|
||||
sudo sysctl -w kern.ipc.maxsockbuf=16777216
|
||||
```
|
||||
|
||||
These tests can be run with:
|
||||
|
||||
```sh
|
||||
cargo test e2e -- --ignored
|
||||
```
|
||||
*/
|
||||
|
||||
use common::node_types::BlockHash;
|
||||
@@ -42,8 +48,9 @@ use test_utils::{
|
||||
|
||||
/// The simplest test we can run; the main benefit of this test (since we check similar)
|
||||
/// below) is just to give a feel for _how_ we can test basic feed related things.
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn feed_sent_version_on_connect() {
|
||||
async fn e2e_feed_sent_version_on_connect() {
|
||||
let server = start_server_debug().await;
|
||||
|
||||
// Connect a feed:
|
||||
@@ -63,8 +70,9 @@ async fn feed_sent_version_on_connect() {
|
||||
|
||||
/// Another very simple test: pings from feeds should be responded to by pongs
|
||||
/// with the same message content.
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn feed_ping_responded_to_with_pong() {
|
||||
async fn e2e_feed_ping_responded_to_with_pong() {
|
||||
let server = start_server_debug().await;
|
||||
|
||||
// Connect a feed:
|
||||
@@ -88,8 +96,9 @@ async fn feed_ping_responded_to_with_pong() {
|
||||
|
||||
/// As a prelude to `lots_of_mute_messages_dont_cause_a_deadlock`, we can check that
|
||||
/// a lot of nodes can simultaneously subscribe and are all sent the expected response.
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn multiple_feeds_sent_version_on_connect() {
|
||||
async fn e2e_multiple_feeds_sent_version_on_connect() {
|
||||
let server = start_server_debug().await;
|
||||
|
||||
// Connect a bunch of feeds:
|
||||
@@ -126,8 +135,9 @@ async fn multiple_feeds_sent_version_on_connect() {
|
||||
/// where the shard is waiting trying to send the next "add node" message, while the
|
||||
/// telemetry core is waiting trying to send up to the shard the next "mute node" message,
|
||||
/// resulting in a deadlock. This test gives confidence that we don't run into such a deadlock.
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn lots_of_mute_messages_dont_cause_a_deadlock() {
|
||||
async fn e2e_lots_of_mute_messages_dont_cause_a_deadlock() {
|
||||
let mut server = start_server_debug().await;
|
||||
let shard_id = server.add_shard().await.unwrap();
|
||||
|
||||
@@ -182,8 +192,9 @@ async fn lots_of_mute_messages_dont_cause_a_deadlock() {
|
||||
|
||||
/// If a node is added, a connecting feed should be told about the new chain.
|
||||
/// If the node is removed, the feed should be told that the chain has gone.
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn feed_add_and_remove_node() {
|
||||
async fn e2e_feed_add_and_remove_node() {
|
||||
// Connect server and add shard
|
||||
let mut server = start_server_debug().await;
|
||||
let shard_id = server.add_shard().await.unwrap();
|
||||
@@ -246,8 +257,9 @@ async fn feed_add_and_remove_node() {
|
||||
/// If nodes connect and the chain name changes, feeds will be told about this
|
||||
/// and will keep receiving messages about the renamed chain (despite subscribing
|
||||
/// to it by name).
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn feeds_told_about_chain_rename_and_stay_subscribed() {
|
||||
async fn e2e_feeds_told_about_chain_rename_and_stay_subscribed() {
|
||||
// Connect a node:
|
||||
let mut server = start_server_debug().await;
|
||||
let shard_id = server.add_shard().await.unwrap();
|
||||
@@ -338,8 +350,9 @@ async fn feeds_told_about_chain_rename_and_stay_subscribed() {
|
||||
/// If we add a couple of shards and a node for each, all feeds should be
|
||||
/// told about both node chains. If one shard goes away, we should get a
|
||||
/// "removed chain" message only for the node connected to that shard.
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn feed_add_and_remove_shard() {
|
||||
async fn e2e_feed_add_and_remove_shard() {
|
||||
let mut server = start_server_debug().await;
|
||||
|
||||
let mut shards = vec![];
|
||||
@@ -414,8 +427,9 @@ async fn feed_add_and_remove_shard() {
|
||||
|
||||
/// feeds can subscribe to one chain at a time. They should get the relevant
|
||||
/// messages for that chain and no other.
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn feed_can_subscribe_and_unsubscribe_from_chain() {
|
||||
async fn e2e_feed_can_subscribe_and_unsubscribe_from_chain() {
|
||||
use FeedMessage::*;
|
||||
|
||||
// Start server, add shard, connect node:
|
||||
@@ -522,8 +536,9 @@ async fn feed_can_subscribe_and_unsubscribe_from_chain() {
|
||||
}
|
||||
|
||||
/// If a node sends more than some rolling average amount of data, it'll be booted.
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn node_banned_if_it_sends_too_much_data() {
|
||||
async fn e2e_node_banned_if_it_sends_too_much_data() {
|
||||
async fn try_send_data(max_bytes: usize, send_msgs: usize, bytes_per_msg: usize) -> bool {
|
||||
let mut server = start_server(
|
||||
ServerOpts::default(),
|
||||
@@ -573,8 +588,9 @@ async fn node_banned_if_it_sends_too_much_data() {
|
||||
}
|
||||
|
||||
/// Feeds will be disconnected if they can't receive messages quickly enough.
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn slow_feeds_are_disconnected() {
|
||||
async fn e2e_slow_feeds_are_disconnected() {
|
||||
let mut server = start_server(
|
||||
ServerOpts::default(),
|
||||
// Timeout faster so the test can be quicker:
|
||||
@@ -605,7 +621,7 @@ async fn slow_feeds_are_disconnected() {
|
||||
// We want to exhaust any buffers between core and feed (eg BufWriters). If the number
|
||||
// is too low, data will happily be sent into a buffer and the connection won't need to
|
||||
// be closed.
|
||||
for n in 1..50_000 {
|
||||
for n in 1..100_000 {
|
||||
node_tx
|
||||
.send_json_text(json!({
|
||||
"id":n,
|
||||
@@ -634,14 +650,14 @@ async fn slow_feeds_are_disconnected() {
|
||||
|
||||
// Wait a little.. the feed hasn't been receiving messages so it should
|
||||
// be booted after ~a second.
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
tokio::time::sleep(Duration::from_secs(5)).await;
|
||||
|
||||
// Drain anything out and expect to hit a "closed" error, rather than get stuck
|
||||
// waiting to receive mroe data (or see some other error).
|
||||
// waiting to receive more data (or see some other error).
|
||||
loop {
|
||||
let mut v = Vec::new();
|
||||
let data =
|
||||
tokio::time::timeout(Duration::from_secs(1), raw_feed_rx.receive_data(&mut v)).await;
|
||||
tokio::time::timeout(Duration::from_secs(2), raw_feed_rx.receive_data(&mut v)).await;
|
||||
|
||||
match data {
|
||||
Ok(Ok(_)) => {
|
||||
@@ -650,8 +666,12 @@ async fn slow_feeds_are_disconnected() {
|
||||
Ok(Err(soketto::connection::Error::Closed)) => {
|
||||
break; // End loop; success!
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
panic!("recv should be closed but instead we saw this error: {}", e);
|
||||
Ok(Err(_e)) => {
|
||||
// Occasionally we might hit an error here before the channel is marked as closed. The error probably
|
||||
// means that the socket has been killed, but we haven't managed to set the state to closed in time
|
||||
// and so we still hit this. We may be able to tighten this up and avoid this permanently, at which point
|
||||
// this can become a test failure.
|
||||
break;
|
||||
}
|
||||
Err(_) => {
|
||||
panic!("recv should be closed but seems to be happy waiting for more data");
|
||||
@@ -666,8 +686,9 @@ async fn slow_feeds_are_disconnected() {
|
||||
/// If something connects to the `/submit` endpoint, there is a limit to the number
|
||||
/// of different messags IDs it can send telemetry about, to prevent a malicious actor from
|
||||
/// spamming a load of message IDs and exhausting our memory.
|
||||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn max_nodes_per_connection_is_enforced() {
|
||||
async fn e2e_max_nodes_per_connection_is_enforced() {
|
||||
let mut server = start_server(
|
||||
ServerOpts::default(),
|
||||
CoreOpts::default(),
|
||||
|
||||
@@ -273,7 +273,7 @@ impl FeedReceiver {
|
||||
|
||||
// Then, loop a little to make sure we catch any additional messages that are sent soon after:
|
||||
loop {
|
||||
match tokio::time::timeout(Duration::from_millis(250), self.recv_feed_messages_once())
|
||||
match tokio::time::timeout(Duration::from_millis(1000), self.recv_feed_messages_once())
|
||||
.await
|
||||
{
|
||||
// Timeout elapsed; return the messages we have so far
|
||||
|
||||
Reference in New Issue
Block a user