Skip to content

Commit 05906ad

Browse files
committed
Bring back the kind remote net tests
1 parent eb4fc09 commit 05906ad

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 2 --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
@@ -2267,6 +2267,7 @@ async fn run(options: &ClientOptions) -> Result<i32, Error> {
22672267
faucet_port,
22682268
faucet_amount,
22692269
dual_store,
2270+
path,
22702271
..
22712272
} => {
22722273
net_up_utils::handle_net_up_kubernetes(
@@ -2286,6 +2287,7 @@ async fn run(options: &ClientOptions) -> Result<i32, Error> {
22862287
*faucet_port,
22872288
*faucet_amount,
22882289
*dual_store,
2290+
path,
22892291
)
22902292
.boxed()
22912293
.await?;

linera-service/src/cli/net_up_utils.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ pub async fn handle_net_up_kubernetes(
126126
faucet_port: NonZeroU16,
127127
faucet_amount: Amount,
128128
dual_store: bool,
129+
path: &Option<String>,
129130
) -> anyhow::Result<()> {
130131
assert!(
131132
num_initial_validators >= 1,
@@ -163,6 +164,7 @@ pub async fn handle_net_up_kubernetes(
163164
build_mode,
164165
policy_config,
165166
dual_store,
167+
path_provider: PathProvider::from_path_option(path)?,
166168
};
167169
let (mut net, client) = config.instantiate().await?;
168170
let faucet_service = print_messages_and_create_faucet(
@@ -325,18 +327,23 @@ async fn print_messages_and_create_faucet(
325327

326328
// Run the faucet,
327329
let faucet_service = if with_faucet {
328-
let faucet_chain_idx = faucet_chain.unwrap_or(0);
329-
assert!(
330-
num_other_initial_chains > faucet_chain_idx,
331-
"num_other_initial_chains must be strictly greater than the faucet chain index if \
330+
let faucet_chain = if let Some(faucet_chain_idx) = faucet_chain {
331+
assert!(
332+
num_other_initial_chains > faucet_chain_idx,
333+
"num_other_initial_chains must be strictly greater than the faucet chain index if \
332334
with_faucet is true"
333-
);
334-
// This picks a lexicographically faucet_chain_idx-th non-admin chain.
335-
let faucet_chain = chains
336-
.into_iter()
337-
.filter(|chain_id| *chain_id != wallet.genesis_admin_chain())
338-
.nth(faucet_chain_idx as usize)
339-
.unwrap(); // we checked that there are enough chains above, so this should be safe
335+
);
336+
// This picks a lexicographically faucet_chain_idx-th non-admin chain.
337+
Some(
338+
chains
339+
.into_iter()
340+
.filter(|chain_id| *chain_id != wallet.genesis_admin_chain())
341+
.nth(faucet_chain_idx as usize)
342+
.unwrap(),
343+
) // we checked that there are enough chains above, so this should be safe
344+
} else {
345+
None
346+
};
340347
let service = client
341348
.run_faucet(Some(faucet_port.into()), faucet_chain, faucet_amount)
342349
.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;
1817
#[cfg(with_testing)]
1918
use {linera_base::command::current_binary_parent, tokio::sync::OnceCell};
@@ -70,6 +69,7 @@ pub struct LocalKubernetesNetConfig {
7069
pub build_mode: BuildMode,
7170
pub policy_config: ResourceControlPolicyConfig,
7271
pub dual_store: bool,
72+
pub path_provider: PathProvider,
7373
}
7474

7575
/// A wrapper of [`LocalKubernetesNetConfig`] to create a shared local Kubernetes network
@@ -83,7 +83,6 @@ pub struct LocalKubernetesNet {
8383
network: Network,
8484
testing_prng_seed: Option<u64>,
8585
next_client_id: usize,
86-
tmp_dir: Arc<TempDir>,
8786
binaries: BuildArg,
8887
no_build: bool,
8988
docker_image_name: String,
@@ -94,6 +93,7 @@ pub struct LocalKubernetesNet {
9493
num_proxies: usize,
9594
num_shards: usize,
9695
dual_store: bool,
96+
path_provider: PathProvider,
9797
}
9898

9999
#[cfg(with_testing)]
@@ -130,6 +130,8 @@ impl SharedLocalKubernetesNetTestingConfig {
130130
build_mode: BuildMode::Release,
131131
policy_config: ResourceControlPolicyConfig::Testnet,
132132
dual_store: false,
133+
path_provider: PathProvider::create_temporary_directory()
134+
.expect("Creating temporary directory should not fail"),
133135
})
134136
}
135137
}
@@ -164,6 +166,7 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
164166
self.num_proxies,
165167
self.num_shards,
166168
self.dual_store,
169+
self.path_provider,
167170
)?;
168171

169172
let client = net.make_client().await;
@@ -280,11 +283,8 @@ impl LineraNet for LocalKubernetesNet {
280283
}
281284

282285
async fn make_client(&mut self) -> ClientWrapper {
283-
let path_provider = PathProvider::TemporaryDirectory {
284-
tmp_dir: self.tmp_dir.clone(),
285-
};
286286
let client = ClientWrapper::new(
287-
path_provider,
287+
self.path_provider.clone(),
288288
self.network,
289289
self.testing_prng_seed,
290290
self.next_client_id,
@@ -345,12 +345,12 @@ impl LocalKubernetesNet {
345345
num_proxies: usize,
346346
num_shards: usize,
347347
dual_store: bool,
348+
path_provider: PathProvider,
348349
) -> Result<Self> {
349350
Ok(Self {
350351
network,
351352
testing_prng_seed,
352353
next_client_id: 0,
353-
tmp_dir: Arc::new(tempdir()?),
354354
binaries,
355355
no_build,
356356
docker_image_name,
@@ -361,22 +361,23 @@ impl LocalKubernetesNet {
361361
num_proxies,
362362
num_shards,
363363
dual_store,
364+
path_provider,
364365
})
365366
}
366367

367368
async fn command_for_binary(&self, name: &'static str) -> Result<Command> {
368369
let path = resolve_binary(name, env!("CARGO_PKG_NAME")).await?;
369370
let mut command = Command::new(path);
370-
command.current_dir(self.tmp_dir.path());
371+
command.current_dir(self.path_provider.path());
371372
Ok(command)
372373
}
373374

374375
fn configuration_string(&self, validator_number: usize) -> Result<String> {
375376
let path = self
376-
.tmp_dir
377+
.path_provider
377378
.path()
378379
.join(format!("validator_{validator_number}.toml"));
379-
let public_port = 19100;
380+
let public_port = 19100 + validator_number;
380381
let private_port = 20100;
381382
let metrics_port = 21100;
382383
let protocol = self.network.toml();
@@ -464,12 +465,12 @@ impl LocalKubernetesNet {
464465
.join("linera-validator")
465466
.join("working");
466467
fs_err::copy(
467-
self.tmp_dir.path().join("genesis.json"),
468+
self.path_provider.path().join("genesis.json"),
468469
base_dir.join("genesis.json"),
469470
)?;
470471

471472
let kubectl_instance_clone = self.kubectl_instance.clone();
472-
let tmp_dir_path_clone = self.tmp_dir.path().to_path_buf();
473+
let path_provider_path_clone = self.path_provider.path().to_path_buf();
473474
let num_proxies = self.num_proxies;
474475
let num_shards = self.num_shards;
475476

@@ -479,7 +480,7 @@ impl LocalKubernetesNet {
479480
let github_root = github_root.clone();
480481

481482
let kubectl_instance = kubectl_instance_clone.clone();
482-
let tmp_dir_path = tmp_dir_path_clone.clone();
483+
let path_provider_path = path_provider_path_clone.clone();
483484

484485
let docker_image_name = docker_image_name.clone();
485486
let dual_store = self.dual_store;
@@ -489,7 +490,7 @@ impl LocalKubernetesNet {
489490

490491
let server_config_filename = format!("server_{}.json", validator_number);
491492
fs_err::copy(
492-
tmp_dir_path.join(&server_config_filename),
493+
path_provider_path.join(&server_config_filename),
493494
base_dir.join(&server_config_filename),
494495
)?;
495496

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)