Skip to content

Commit aea3b9b

Browse files
authored
Bring back the kind remote net tests (#4410)
## Motivation We removed this a while back, and never added it back. This is useful to test the changes against a kubernetes network, running ScyllaDB as well. ## Proposal Test against a kind network again. ## Test Plan CI ## Release Plan - Nothing to do / These changes follow the usual release cycle.
1 parent b6b59d4 commit aea3b9b

File tree

7 files changed

+105
-46
lines changed

7 files changed

+105
-46
lines changed

.github/workflows/rust.yml

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ jobs:
7373
cargo run --release -p linera-storage-service -- memory --endpoint $LINERA_STORAGE_SERVICE &
7474
- name: Wait for storage service to be ready
7575
run: |
76-
until nc -z 127.0.0.1 1235; do sleep 1; done
76+
STORAGE_HOST=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f1)
77+
STORAGE_PORT=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f2)
78+
until nc -z "$STORAGE_HOST" "$STORAGE_PORT"; do sleep 1; done
7779
- name: Build binaries
7880
run: |
7981
cargo build --features storage-service --bin linera-server --bin linera-proxy --bin linera
@@ -87,14 +89,53 @@ jobs:
8789
mkdir /tmp/linera-faucet
8890
cargo run --bin linera -- resource-control-policy --http-request-timeout-ms 1000
8991
cargo run --bin linera -- resource-control-policy --http-request-timeout-ms 500
90-
cargo run --bin linera -- faucet --storage-path /tmp/linera-faucet/faucet_storage.sqlite --amount 1000 --port 8079 &
92+
FAUCET_PORT=$(echo "$LINERA_FAUCET_URL" | cut -d: -f3)
93+
cargo run --bin linera -- faucet --storage-path /tmp/linera-faucet/faucet_storage.sqlite --amount 1000 --port $FAUCET_PORT &
9194
- name: Wait for faucet to be ready
9295
run: |
93-
until curl -s http://localhost:8079 >/dev/null; do sleep 1; done
96+
until curl -s $LINERA_FAUCET_URL >/dev/null; do sleep 1; done
9497
- name: Run the remote-net tests
9598
run: |
9699
cargo test -p linera-service remote_net_grpc --features remote-net
97100
101+
remote-kubernetes-net-test:
102+
needs: changed-files
103+
if: needs.changed-files.outputs.should-run == 'true'
104+
runs-on: ubuntu-latest-16-cores
105+
timeout-minutes: 90
106+
107+
steps:
108+
- uses: actions/checkout@v4
109+
- uses: actions-rust-lang/setup-rust-toolchain@v1
110+
- name: Install Protoc
111+
uses: arduino/setup-protoc@v3
112+
with:
113+
repo-token: ${{ secrets.GITHUB_TOKEN }}
114+
- name: Install helmfile
115+
run: |
116+
# Install specific version to match local development environment
117+
HELMFILE_VERSION="v0.168.0"
118+
curl -fsSL -o helmfile.tar.gz "https://github.com/helmfile/helmfile/releases/download/${HELMFILE_VERSION}/helmfile_${HELMFILE_VERSION#v}_linux_amd64.tar.gz"
119+
tar -xzf helmfile.tar.gz helmfile
120+
sudo mv helmfile /usr/local/bin/
121+
rm helmfile.tar.gz
122+
# Verify installation
123+
which helmfile && helmfile --version
124+
- name: Build binaries
125+
run: |
126+
cargo build --features storage-service --bin linera-server --bin linera-proxy --bin linera
127+
- name: Run the validators with Kubernetes
128+
run: |
129+
mkdir /tmp/local-linera-net
130+
FAUCET_PORT=$(echo "$LINERA_FAUCET_URL" | cut -d: -f3)
131+
cargo run --bin linera --features kubernetes -- net up --kubernetes --policy-config testnet --path /tmp/local-linera-net --validators 1 --shards 2 --with-faucet --faucet-port $FAUCET_PORT --faucet-amount 1000 &
132+
- name: Wait for faucet to be ready
133+
run: |
134+
until curl -s $LINERA_FAUCET_URL >/dev/null; do sleep 1; done
135+
- name: Run the Kubernetes tests
136+
run: |
137+
cargo test -p linera-service remote_net_grpc --features remote-net
138+
98139
execution-wasmtime-test:
99140
needs: changed-files
100141
if: needs.changed-files.outputs.should-run == 'true'
@@ -226,7 +267,9 @@ jobs:
226267
cargo run --release -p linera-storage-service -- memory --endpoint $LINERA_STORAGE_SERVICE &
227268
- name: Wait for storage service to be ready
228269
run: |
229-
until nc -z 127.0.0.1 1235; do sleep 1; done
270+
STORAGE_HOST=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f1)
271+
STORAGE_PORT=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f2)
272+
until nc -z "$STORAGE_HOST" "$STORAGE_PORT"; do sleep 1; done
230273
- name: Run the benchmark test
231274
run: |
232275
cargo build --locked -p linera-service --bin linera-benchmark --features storage-service
@@ -286,7 +329,9 @@ jobs:
286329
cargo run --release -p linera-storage-service -- memory --endpoint $LINERA_STORAGE_SERVICE &
287330
- name: Wait for storage service to be ready
288331
run: |
289-
until nc -z 127.0.0.1 1235; do sleep 1; done
332+
STORAGE_HOST=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f1)
333+
STORAGE_PORT=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f2)
334+
until nc -z "$STORAGE_HOST" "$STORAGE_PORT"; do sleep 1; done
290335
- name: Run Ethereum tests
291336
run: |
292337
cargo test -p linera-ethereum --features ethereum
@@ -316,7 +361,9 @@ jobs:
316361
cargo run --release -p linera-storage-service -- memory --endpoint $LINERA_STORAGE_SERVICE &
317362
- name: Wait for storage service to be ready
318363
run: |
319-
until nc -z 127.0.0.1 1235; do sleep 1; done
364+
STORAGE_HOST=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f1)
365+
STORAGE_PORT=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f2)
366+
until nc -z "$STORAGE_HOST" "$STORAGE_PORT"; do sleep 1; done
320367
- name: Run the storage-service tests
321368
run: |
322369
cargo test --features storage-service -- storage_service --nocapture

linera-service/src/cli/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,7 @@ async fn run(options: &ClientOptions) -> Result<i32, Error> {
22712271
indexer_image_name,
22722272
explorer_image_name,
22732273
dual_store,
2274+
path,
22742275
..
22752276
} => {
22762277
net_up_utils::handle_net_up_kubernetes(
@@ -2294,6 +2295,7 @@ async fn run(options: &ClientOptions) -> Result<i32, Error> {
22942295
indexer_image_name.clone(),
22952296
explorer_image_name.clone(),
22962297
*dual_store,
2298+
path,
22972299
)
22982300
.boxed()
22992301
.await?;

linera-service/src/cli/net_up_utils.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ pub async fn handle_net_up_kubernetes(
130130
indexer_image_name: String,
131131
explorer_image_name: String,
132132
dual_store: bool,
133+
path: &Option<String>,
133134
) -> anyhow::Result<()> {
134135
assert!(
135136
num_initial_validators >= 1,
@@ -180,6 +181,7 @@ pub async fn handle_net_up_kubernetes(
180181
indexer_image_name,
181182
explorer_image_name,
182183
dual_store,
184+
path_provider: PathProvider::from_path_option(path)?,
183185
};
184186
let (mut net, client) = config.instantiate().await?;
185187
let faucet_service = print_messages_and_create_faucet(
@@ -338,18 +340,23 @@ async fn print_messages_and_create_faucet(
338340

339341
// Run the faucet,
340342
let faucet_service = if with_faucet {
341-
let faucet_chain_idx = faucet_chain.unwrap_or(0);
342-
assert!(
343-
num_other_initial_chains > faucet_chain_idx,
344-
"num_other_initial_chains must be strictly greater than the faucet chain index if \
343+
let faucet_chain = if let Some(faucet_chain_idx) = faucet_chain {
344+
assert!(
345+
num_other_initial_chains > faucet_chain_idx,
346+
"num_other_initial_chains must be strictly greater than the faucet chain index if \
345347
with_faucet is true"
346-
);
347-
// This picks a lexicographically faucet_chain_idx-th non-admin chain.
348-
let faucet_chain = chains
349-
.into_iter()
350-
.filter(|chain_id| *chain_id != wallet.genesis_admin_chain())
351-
.nth(faucet_chain_idx as usize)
352-
.unwrap(); // we checked that there are enough chains above, so this should be safe
348+
);
349+
// This picks a lexicographically faucet_chain_idx-th non-admin chain.
350+
Some(
351+
chains
352+
.into_iter()
353+
.filter(|chain_id| *chain_id != wallet.genesis_admin_chain())
354+
.nth(faucet_chain_idx as usize)
355+
.unwrap(),
356+
) // we checked that there are enough chains above, so this should be safe
357+
} else {
358+
None
359+
};
353360
let service = client
354361
.run_faucet(Some(faucet_port.into()), faucet_chain, faucet_amount)
355362
.await?;

linera-service/src/cli_wrappers/local_kubernetes_net.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use linera_base::{
1313
data_types::Amount,
1414
};
1515
use linera_client::client_options::ResourceControlPolicyConfig;
16-
use tempfile::{tempdir, TempDir};
1716
use tokio::{process::Command, task::JoinSet};
1817
#[cfg(with_testing)]
1918
use {linera_base::command::current_binary_parent, tokio::sync::OnceCell};
@@ -73,6 +72,7 @@ pub struct LocalKubernetesNetConfig {
7372
pub indexer_image_name: String,
7473
pub explorer_image_name: String,
7574
pub dual_store: bool,
75+
pub path_provider: PathProvider,
7676
}
7777

7878
/// A wrapper of [`LocalKubernetesNetConfig`] to create a shared local Kubernetes network
@@ -86,7 +86,6 @@ pub struct LocalKubernetesNet {
8686
network: Network,
8787
testing_prng_seed: Option<u64>,
8888
next_client_id: usize,
89-
tmp_dir: Arc<TempDir>,
9089
binaries: BuildArg,
9190
no_build: bool,
9291
docker_image_name: String,
@@ -100,6 +99,7 @@ pub struct LocalKubernetesNet {
10099
indexer_image_name: String,
101100
explorer_image_name: String,
102101
dual_store: bool,
102+
path_provider: PathProvider,
103103
}
104104

105105
#[cfg(with_testing)]
@@ -139,6 +139,8 @@ impl SharedLocalKubernetesNetTestingConfig {
139139
indexer_image_name: String::from("linera-indexer:latest"),
140140
explorer_image_name: String::from("linera-explorer:latest"),
141141
dual_store: false,
142+
path_provider: PathProvider::create_temporary_directory()
143+
.expect("Creating temporary directory should not fail"),
142144
})
143145
}
144146
}
@@ -176,6 +178,7 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
176178
self.indexer_image_name,
177179
self.explorer_image_name,
178180
self.dual_store,
181+
self.path_provider,
179182
)?;
180183

181184
let client = net.make_client().await;
@@ -292,11 +295,8 @@ impl LineraNet for LocalKubernetesNet {
292295
}
293296

294297
async fn make_client(&mut self) -> ClientWrapper {
295-
let path_provider = PathProvider::TemporaryDirectory {
296-
tmp_dir: self.tmp_dir.clone(),
297-
};
298298
let client = ClientWrapper::new(
299-
path_provider,
299+
self.path_provider.clone(),
300300
self.network,
301301
self.testing_prng_seed,
302302
self.next_client_id,
@@ -360,12 +360,12 @@ impl LocalKubernetesNet {
360360
indexer_image_name: String,
361361
explorer_image_name: String,
362362
dual_store: bool,
363+
path_provider: PathProvider,
363364
) -> Result<Self> {
364365
Ok(Self {
365366
network,
366367
testing_prng_seed,
367368
next_client_id: 0,
368-
tmp_dir: Arc::new(tempdir()?),
369369
binaries,
370370
no_build,
371371
docker_image_name,
@@ -379,22 +379,23 @@ impl LocalKubernetesNet {
379379
indexer_image_name,
380380
explorer_image_name,
381381
dual_store,
382+
path_provider,
382383
})
383384
}
384385

385386
async fn command_for_binary(&self, name: &'static str) -> Result<Command> {
386387
let path = resolve_binary(name, env!("CARGO_PKG_NAME")).await?;
387388
let mut command = Command::new(path);
388-
command.current_dir(self.tmp_dir.path());
389+
command.current_dir(self.path_provider.path());
389390
Ok(command)
390391
}
391392

392393
fn configuration_string(&self, validator_number: usize) -> Result<String> {
393394
let path = self
394-
.tmp_dir
395+
.path_provider
395396
.path()
396397
.join(format!("validator_{validator_number}.toml"));
397-
let public_port = 19100;
398+
let public_port = 19100 + validator_number;
398399
let private_port = 20100;
399400
let metrics_port = 21100;
400401
let protocol = self.network.toml();
@@ -535,12 +536,12 @@ impl LocalKubernetesNet {
535536
.join("linera-validator")
536537
.join("working");
537538
fs_err::copy(
538-
self.tmp_dir.path().join("genesis.json"),
539+
self.path_provider.path().join("genesis.json"),
539540
base_dir.join("genesis.json"),
540541
)?;
541542

542543
let kubectl_instance_clone = self.kubectl_instance.clone();
543-
let tmp_dir_path_clone = self.tmp_dir.path().to_path_buf();
544+
let path_provider_path_clone = self.path_provider.path().to_path_buf();
544545
let num_proxies = self.num_proxies;
545546
let num_shards = self.num_shards;
546547

@@ -550,7 +551,7 @@ impl LocalKubernetesNet {
550551
let github_root = github_root.clone();
551552

552553
let kubectl_instance = kubectl_instance_clone.clone();
553-
let tmp_dir_path = tmp_dir_path_clone.clone();
554+
let path_provider_path = path_provider_path_clone.clone();
554555

555556
let docker_image_name = docker_image_name.clone();
556557
let indexer_image_name = indexer_image_name.clone();
@@ -565,7 +566,7 @@ impl LocalKubernetesNet {
565566

566567
let server_config_filename = format!("server_{}.json", validator_number);
567568
fs_err::copy(
568-
tmp_dir_path.join(&server_config_filename),
569+
path_provider_path.join(&server_config_filename),
569570
base_dir.join(&server_config_filename),
570571
)?;
571572

linera-service/src/cli_wrappers/wallet.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -540,24 +540,26 @@ impl ClientWrapper {
540540
pub async fn run_faucet(
541541
&self,
542542
port: impl Into<Option<u16>>,
543-
chain_id: ChainId,
543+
chain_id: Option<ChainId>,
544544
amount: Amount,
545545
) -> Result<FaucetService> {
546546
let port = port.into().unwrap_or(8080);
547547
let temp_dir = tempfile::tempdir()
548548
.context("Failed to create temporary directory for faucet storage")?;
549549
let storage_path = temp_dir.path().join("faucet_storage.sqlite");
550550
let mut command = self.command().await?;
551-
let child = command
551+
let command = command
552552
.arg("faucet")
553-
.arg(chain_id.to_string())
554553
.args(["--port".to_string(), port.to_string()])
555554
.args(["--amount".to_string(), amount.to_string()])
556555
.args([
557556
"--storage-path".to_string(),
558557
storage_path.to_string_lossy().to_string(),
559-
])
560-
.spawn_into()?;
558+
]);
559+
if let Some(chain_id) = chain_id {
560+
command.arg(chain_id.to_string());
561+
}
562+
let child = command.spawn_into()?;
561563
let client = reqwest_client();
562564
for i in 0..10 {
563565
linera_base::time::timer::sleep(Duration::from_secs(i)).await;

linera-service/tests/linera_net_tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4167,7 +4167,7 @@ async fn test_end_to_end_faucet(config: impl LineraNetConfig) -> Result<()> {
41674167
let owner2 = client2.keygen().await?;
41684168

41694169
let mut faucet_service = client1
4170-
.run_faucet(None, chain1, Amount::from_tokens(2))
4170+
.run_faucet(None, Some(chain1), Amount::from_tokens(2))
41714171
.await?;
41724172
let faucet = faucet_service.instance();
41734173
let chain2 = faucet.claim(&owner2).await?.id();
@@ -4252,7 +4252,7 @@ async fn test_end_to_end_faucet_with_long_chains(config: impl LineraNetConfig) -
42524252

42534253
let new_chain_init_balance = Amount::ONE;
42544254
let mut faucet_service = faucet_client
4255-
.run_faucet(None, faucet_chain, new_chain_init_balance)
4255+
.run_faucet(None, Some(faucet_chain), new_chain_init_balance)
42564256
.await?;
42574257
let faucet = faucet_service.instance();
42584258

@@ -4323,7 +4323,7 @@ async fn test_end_to_end_faucet_batch_processing(config: impl LineraNetConfig) -
43234323

43244324
// Start faucet with small batch size for testing
43254325
let mut faucet_service = client1
4326-
.run_faucet(None, chain1, Amount::from_tokens(2))
4326+
.run_faucet(None, Some(chain1), Amount::from_tokens(2))
43274327
.await?;
43284328
let faucet = faucet_service.instance();
43294329

@@ -4412,7 +4412,7 @@ async fn test_end_to_end_fungible_client_benchmark(config: impl LineraNetConfig)
44124412

44134413
let chain1 = client1.load_wallet()?.default_chain().unwrap();
44144414

4415-
let mut faucet_service = client1.run_faucet(None, chain1, Amount::ONE).await?;
4415+
let mut faucet_service = client1.run_faucet(None, Some(chain1), Amount::ONE).await?;
44164416
let faucet = faucet_service.instance();
44174417

44184418
let path =

0 commit comments

Comments
 (0)