Skip to content

Commit

Permalink
ci: use node manager for running local testnets
Browse files Browse the repository at this point in the history
WIP

The node registry from the node manager has been transferred to the `sn_protocol` crate to reduce
duplication between `safe_network` and `sn-node-manager`, because they both need access to these
data structures. The local network deployment inventory is represented using the node registry.
  • Loading branch information
jacderida committed Jan 12, 2024
1 parent eee302d commit f3db89a
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 48 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/benchmark-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: start
interval: 2000
node-path: target/release/safenode
faucet-path: target/release/faucet
platform: ubuntu-latest
build: true

- name: Check SAFE_PEERS was set
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-benchmark-charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: start
interval: 2000
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/memcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ jobs:

- name: Start a local network
env:
SN_LOG: all
uses: maidsafe/sn-local-testnet-action@main
SN_LOG: "all"
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: start
interval: 2000
Expand All @@ -75,6 +75,8 @@ jobs:
platform: ubuntu-latest
set-safe-peers: false
build: true
node-manager-branch: safe-peers-arg
node-manager-repo-owner: jacderida
join: true

# In this case we did *not* want SAFE_PEERS to be set to another value by starting the testnet
Expand Down
35 changes: 12 additions & 23 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,13 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: start
interval: 2000
node-path: target/release/safenode
faucet-path: target/release/faucet
platform: ${{ matrix.os }}
build: true

- name: Check SAFE_PEERS was set
shell: bash
Expand Down Expand Up @@ -274,12 +273,11 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: stop
log_file_prefix: safe_test_logs_e2e
platform: ${{ matrix.os }}
build: true

gossipsub:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
Expand All @@ -304,7 +302,7 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: start
interval: 2000
Expand All @@ -319,12 +317,11 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: stop
log_file_prefix: safe_test_logs_gossipsub_e2e
platform: ${{ matrix.os }}
build: true

spend_test:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
Expand All @@ -350,14 +347,13 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: start
interval: 2000
node-path: target/release/safenode
faucet-path: target/release/faucet
platform: ${{ matrix.os }}
build: true

- name: Check SAFE_PEERS was set
shell: bash
Expand Down Expand Up @@ -391,12 +387,11 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: stop
log_file_prefix: safe_test_logs_spend
platform: ${{ matrix.os }}
build: true

churn:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
Expand Down Expand Up @@ -430,14 +425,13 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: start
interval: 2000
node-path: target/release/safenode
faucet-path: target/release/faucet
platform: ${{ matrix.os }}
build: true

- name: Check SAFE_PEERS was set
shell: bash
Expand All @@ -459,12 +453,11 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: stop
log_file_prefix: safe_test_logs_churn
platform: ${{ matrix.os }}
build: true

- name: Verify restart of nodes using rg
shell: bash
Expand Down Expand Up @@ -552,14 +545,13 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: start
interval: 2000
node-path: target/release/safenode
faucet-path: target/release/faucet
platform: ${{ matrix.os }}
build: true

- name: Check SAFE_PEERS was set
shell: bash
Expand Down Expand Up @@ -588,12 +580,11 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: stop
log_file_prefix: safe_test_logs_data_location
platform: ${{ matrix.os }}
build: true

- name: Verify restart of nodes using rg
shell: bash
Expand Down Expand Up @@ -672,14 +663,13 @@ jobs:
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: start
interval: 2000
node-path: target/release/safenode
faucet-path: target/release/faucet
platform: ubuntu-latest
build: true

- name: Check SAFE_PEERS was set
shell: bash
Expand Down Expand Up @@ -717,9 +707,8 @@ jobs:

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/sn-local-testnet-action@main
uses: jacderida/sn-local-testnet-action@node-manager
with:
action: stop
log_file_prefix: safe_test_logs_heavy_replicate_bench
platform: ubuntu-latest
build: true
5 changes: 0 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ jobs:
target: aarch64-unknown-linux-musl
steps:
- uses: actions/checkout@v4



- uses: dtolnay/rust-toolchain@stable
# It's quite slow to install just by building it, but here we need a cross-platform solution.
- shell: bash
Expand Down Expand Up @@ -75,8 +72,6 @@ jobs:
GH_TOKEN: ${{ secrets.VERSION_BUMP_COMMIT_PAT }}

steps:


- uses: actions/checkout@v4
with:
fetch-depth: "0"
Expand Down
20 changes: 8 additions & 12 deletions sn_node/tests/common/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use eyre::{bail, Result};
use lazy_static::lazy_static;
use sn_client::{send, Client};
use sn_peers_acquisition::parse_peer_addr;
use sn_protocol::node_registry::{get_local_node_registry_path, NodeRegistry};
use sn_protocol::test_utils::DeploymentInventory;
use sn_transfers::{create_faucet_wallet, LocalWallet, NanoTokens, Transfer};
use std::{
Expand Down Expand Up @@ -53,18 +54,13 @@ pub fn get_all_rpc_addresses() -> Result<Vec<SocketAddr>> {
match DeploymentInventory::load() {
Ok(inventory) => Ok(inventory.rpc_endpoints),
Err(_) => {
let starting_port = match std::env::var("CHURN_TEST_START_PORT") {
Ok(val) => val.parse()?,
Err(_) => 12000,
};
let mut addresses = Vec::new();
for i in 1..LOCAL_NODE_COUNT + 1 {
let addr = SocketAddr::new(
IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
starting_port + i as u16,
);
addresses.push(addr);
}
let local_node_reg_path = &get_local_node_registry_path()?;
let local_node_registry = NodeRegistry::load(local_node_reg_path)?;
let addresses = local_node_registry
.nodes
.iter()
.map(|n| SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), n.rpc_port))
.collect::<Vec<SocketAddr>>();
Ok(addresses)
}
}
Expand Down
6 changes: 3 additions & 3 deletions sn_protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ repository = "https://github.com/maidsafe/safe_network"
version = "0.10.6"

[features]
test-utils=["dirs-next", "serde_json"]
test-utils=[]

[dependencies]
bls = { package = "blsttc", version = "8.0.1" }
bytes = { version = "1.0.1", features = ["serde"] }
color-eyre = "0.6.2"
crdts = { version = "7.3", default-features = false, features = ["merkle"] }
custom_debug = "~0.5.0"
dirs-next = { version = "~2.0.0", optional = true }
dirs-next = "~2.0.0"
hex = "~0.4.3"
libp2p = { version="0.53", features = ["identify", "kad"] }
rmp-serde = "1.1.1"
serde = { version = "1.0.133", features = [ "derive", "rc" ]}
serde_json = {version = "1.0", optional = true }
serde_json = "1.0"
sha2 = "0.10.7"
sn_transfers = { path = "../sn_transfers", version = "0.14.36" }
sn_registers = { path = "../sn_registers", version = "0.3.7" }
Expand Down
4 changes: 4 additions & 0 deletions sn_protocol/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Clone, PartialEq, Eq, Serialize, Deserialize, custom_debug::Debug)]
#[non_exhaustive]
pub enum Error {
// ---------- Misc errors
#[error("Could not obtain user's data directory")]
UserDataDirectoryNotObtainable,

// ---------- Chunk Proof errors
#[error("Chunk does not exist {0:?}")]
ChunkDoesNotExist(NetworkAddress),
Expand Down
2 changes: 2 additions & 0 deletions sn_protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ extern crate tracing;
pub mod error;
/// Messages types
pub mod messages;
/// Data structures for node management.
pub mod node_registry;
/// RPC commands to node
pub mod node_rpc;
/// Storage types for spends, chunks and registers.
Expand Down
Loading

0 comments on commit f3db89a

Please sign in to comment.