Skip to content

Commit a1f632f

Browse files
committed
Bring back the kind remote net tests
1 parent a925bbc commit a1f632f

File tree

5 files changed

+81
-23
lines changed

5 files changed

+81
-23
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
@@ -86,14 +88,53 @@ jobs:
8688
run: |
8789
cargo run --bin linera -- resource-control-policy --http-request-timeout-ms 1000
8890
cargo run --bin linera -- resource-control-policy --http-request-timeout-ms 500
89-
cargo run --bin linera -- faucet --amount 1000 --port 8079 &
91+
FAUCET_PORT=$(echo "$LINERA_FAUCET_URL" | cut -d: -f3)
92+
cargo run --bin linera -- faucet --amount 1000 --port $FAUCET_PORT &
9093
- name: Wait for faucet to be ready
9194
run: |
92-
until curl -s http://localhost:8079 >/dev/null; do sleep 1; done
95+
until curl -s $LINERA_FAUCET_URL >/dev/null; do sleep 1; done
9396
- name: Run the remote-net tests
9497
run: |
9598
cargo test -p linera-service remote_net_grpc --features remote-net
9699
100+
remote-kubernetes-net-test:
101+
needs: changed-files
102+
if: needs.changed-files.outputs.should-run == 'true'
103+
runs-on: ubuntu-latest-16-cores
104+
timeout-minutes: 60
105+
106+
steps:
107+
- uses: actions/checkout@v4
108+
- uses: actions-rust-lang/setup-rust-toolchain@v1
109+
- name: Install Protoc
110+
uses: arduino/setup-protoc@v3
111+
with:
112+
repo-token: ${{ secrets.GITHUB_TOKEN }}
113+
- name: Install helmfile
114+
run: |
115+
# Install specific version to match local development environment
116+
HELMFILE_VERSION="v0.168.0"
117+
curl -fsSL -o helmfile.tar.gz "https://github.com/helmfile/helmfile/releases/download/${HELMFILE_VERSION}/helmfile_${HELMFILE_VERSION#v}_linux_amd64.tar.gz"
118+
tar -xzf helmfile.tar.gz helmfile
119+
sudo mv helmfile /usr/local/bin/
120+
rm helmfile.tar.gz
121+
# Verify installation
122+
which helmfile && helmfile --version
123+
- name: Build binaries
124+
run: |
125+
cargo build --features storage-service --bin linera-server --bin linera-proxy --bin linera
126+
- name: Run the validators with Kubernetes
127+
run: |
128+
mkdir /tmp/local-linera-net
129+
FAUCET_PORT=$(echo "$LINERA_FAUCET_URL" | cut -d: -f3)
130+
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 &
131+
- name: Wait for faucet to be ready
132+
run: |
133+
until curl -s $LINERA_FAUCET_URL >/dev/null; do sleep 1; done
134+
- name: Run the Kubernetes tests
135+
run: |
136+
cargo test -p linera-service remote_net_grpc --features remote-net
137+
97138
execution-wasmtime-test:
98139
needs: changed-files
99140
if: needs.changed-files.outputs.should-run == 'true'
@@ -202,7 +243,9 @@ jobs:
202243
cargo run --release -p linera-storage-service -- memory --endpoint $LINERA_STORAGE_SERVICE &
203244
- name: Wait for storage service to be ready
204245
run: |
205-
until nc -z 127.0.0.1 1235; do sleep 1; done
246+
STORAGE_HOST=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f1)
247+
STORAGE_PORT=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f2)
248+
until nc -z "$STORAGE_HOST" "$STORAGE_PORT"; do sleep 1; done
206249
- name: Run the benchmark test
207250
run: |
208251
cargo build --locked -p linera-service --bin linera-benchmark --features storage-service
@@ -262,7 +305,9 @@ jobs:
262305
cargo run --release -p linera-storage-service -- memory --endpoint $LINERA_STORAGE_SERVICE &
263306
- name: Wait for storage service to be ready
264307
run: |
265-
until nc -z 127.0.0.1 1235; do sleep 1; done
308+
STORAGE_HOST=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f1)
309+
STORAGE_PORT=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f2)
310+
until nc -z "$STORAGE_HOST" "$STORAGE_PORT"; do sleep 1; done
266311
- name: Run Ethereum tests
267312
run: |
268313
cargo test -p linera-ethereum --features ethereum
@@ -292,7 +337,9 @@ jobs:
292337
cargo run --release -p linera-storage-service -- memory --endpoint $LINERA_STORAGE_SERVICE &
293338
- name: Wait for storage service to be ready
294339
run: |
295-
until nc -z 127.0.0.1 1235; do sleep 1; done
340+
STORAGE_HOST=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f1)
341+
STORAGE_PORT=$(echo "$LINERA_STORAGE_SERVICE" | cut -d: -f2)
342+
until nc -z "$STORAGE_HOST" "$STORAGE_PORT"; do sleep 1; done
296343
- name: Run the storage-service tests
297344
run: |
298345
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
@@ -2211,6 +2211,7 @@ async fn run(options: &ClientOptions) -> Result<i32, Error> {
22112211
faucet_port,
22122212
faucet_amount,
22132213
dual_store,
2214+
path,
22142215
..
22152216
} => {
22162217
net_up_utils::handle_net_up_kubernetes(
@@ -2229,6 +2230,7 @@ async fn run(options: &ClientOptions) -> Result<i32, Error> {
22292230
*faucet_port,
22302231
*faucet_amount,
22312232
*dual_store,
2233+
path,
22322234
)
22332235
.boxed()
22342236
.await?;

linera-service/src/cli/net_up_utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pub async fn handle_net_up_kubernetes(
125125
faucet_port: NonZeroU16,
126126
faucet_amount: Amount,
127127
dual_store: bool,
128+
path: &Option<String>,
128129
) -> anyhow::Result<()> {
129130
if num_initial_validators < 1 {
130131
panic!("The local test network must have at least one validator.");
@@ -155,6 +156,7 @@ pub async fn handle_net_up_kubernetes(
155156
build_mode,
156157
policy_config,
157158
dual_store,
159+
path_provider: PathProvider::from_path_option(path)?,
158160
};
159161
let (mut net, client) = config.instantiate().await?;
160162
let faucet_service = print_messages_and_create_faucet(

linera-service/src/cli_wrappers/helmfile.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ impl HelmFile {
4242
)
4343
.env("LINERA_HELMFILE_SET_NUM_SHARDS", num_shards.to_string())
4444
.env("LINERA_HELMFILE_LINERA_IMAGE", docker_image_name)
45+
.env(
46+
"LINERA_HELMFILE_SET_KUBE_CONTEXT",
47+
format!("kind-{}", cluster_id),
48+
)
4549
.arg("sync")
4650
.arg("--wait")
47-
.args(["--kube-context", &format!("kind-{}", cluster_id)])
4851
.spawn_and_wait()
4952
.await
5053
}

linera-service/src/cli_wrappers/local_kubernetes_net.rs

Lines changed: 20 additions & 16 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};
@@ -69,6 +68,7 @@ pub struct LocalKubernetesNetConfig {
6968
pub build_mode: BuildMode,
7069
pub policy_config: ResourceControlPolicyConfig,
7170
pub dual_store: bool,
71+
pub path_provider: PathProvider,
7272
}
7373

7474
/// A wrapper of [`LocalKubernetesNetConfig`] to create a shared local Kubernetes network
@@ -82,7 +82,6 @@ pub struct LocalKubernetesNet {
8282
network: Network,
8383
testing_prng_seed: Option<u64>,
8484
next_client_id: usize,
85-
tmp_dir: Arc<TempDir>,
8685
binaries: BuildArg,
8786
no_build: bool,
8887
docker_image_name: String,
@@ -92,6 +91,7 @@ pub struct LocalKubernetesNet {
9291
num_initial_validators: usize,
9392
num_shards: usize,
9493
dual_store: bool,
94+
path_provider: PathProvider,
9595
}
9696

9797
#[cfg(with_testing)]
@@ -127,6 +127,8 @@ impl SharedLocalKubernetesNetTestingConfig {
127127
build_mode: BuildMode::Release,
128128
policy_config: ResourceControlPolicyConfig::Testnet,
129129
dual_store: false,
130+
path_provider: PathProvider::create_temporary_directory()
131+
.expect("Creating temporary directory should not fail"),
130132
})
131133
}
132134
}
@@ -160,6 +162,7 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
160162
self.num_initial_validators,
161163
self.num_shards,
162164
self.dual_store,
165+
self.path_provider,
163166
)?;
164167

165168
let client = net.make_client().await;
@@ -276,11 +279,8 @@ impl LineraNet for LocalKubernetesNet {
276279
}
277280

278281
async fn make_client(&mut self) -> ClientWrapper {
279-
let path_provider = PathProvider::TemporaryDirectory {
280-
tmp_dir: self.tmp_dir.clone(),
281-
};
282282
let client = ClientWrapper::new(
283-
path_provider,
283+
self.path_provider.clone(),
284284
self.network,
285285
self.testing_prng_seed,
286286
self.next_client_id,
@@ -340,12 +340,12 @@ impl LocalKubernetesNet {
340340
num_initial_validators: usize,
341341
num_shards: usize,
342342
dual_store: bool,
343+
path_provider: PathProvider,
343344
) -> Result<Self> {
344345
Ok(Self {
345346
network,
346347
testing_prng_seed,
347348
next_client_id: 0,
348-
tmp_dir: Arc::new(tempdir()?),
349349
binaries,
350350
no_build,
351351
docker_image_name,
@@ -355,19 +355,23 @@ impl LocalKubernetesNet {
355355
num_initial_validators,
356356
num_shards,
357357
dual_store,
358+
path_provider,
358359
})
359360
}
360361

361362
async fn command_for_binary(&self, name: &'static str) -> Result<Command> {
362363
let path = resolve_binary(name, env!("CARGO_PKG_NAME")).await?;
363364
let mut command = Command::new(path);
364-
command.current_dir(self.tmp_dir.path());
365+
command.current_dir(self.path_provider.path());
365366
Ok(command)
366367
}
367368

368369
fn configuration_string(&self, server_number: usize) -> Result<String> {
369370
let n = server_number;
370-
let path = self.tmp_dir.path().join(format!("validator_{n}.toml"));
371+
let path = self
372+
.path_provider
373+
.path()
374+
.join(format!("validator_{n}.toml"));
371375
let port = 19100 + server_number;
372376
let internal_port = 20100;
373377
let metrics_port = 21100;
@@ -382,8 +386,8 @@ impl LocalKubernetesNet {
382386
Grpc = "ClearText"
383387
384388
[[proxies]]
385-
host = "proxy-0.default.svc.cluster.local"
386-
public_port = {port}
389+
host = "proxy.default.svc.cluster.local"
390+
public_port = 19100
387391
private_port = {internal_port}
388392
metrics_port = {metrics_port}
389393
"#
@@ -451,12 +455,12 @@ impl LocalKubernetesNet {
451455
.join("linera-validator")
452456
.join("working");
453457
fs_err::copy(
454-
self.tmp_dir.path().join("genesis.json"),
458+
self.path_provider.path().join("genesis.json"),
455459
base_dir.join("genesis.json"),
456460
)?;
457461

458462
let kubectl_instance_clone = self.kubectl_instance.clone();
459-
let tmp_dir_path_clone = self.tmp_dir.path().to_path_buf();
463+
let path_provider_path_clone = self.path_provider.path().to_path_buf();
460464
let num_shards = self.num_shards;
461465

462466
let mut validators_initialization_futures = Vec::new();
@@ -465,7 +469,7 @@ impl LocalKubernetesNet {
465469
let github_root = github_root.clone();
466470

467471
let kubectl_instance = kubectl_instance_clone.clone();
468-
let tmp_dir_path = tmp_dir_path_clone.clone();
472+
let path_provider_path = path_provider_path_clone.clone();
469473

470474
let docker_image_name = docker_image_name.clone();
471475
let dual_store = self.dual_store;
@@ -475,7 +479,7 @@ impl LocalKubernetesNet {
475479

476480
let server_config_filename = format!("server_{}.json", i);
477481
fs_err::copy(
478-
tmp_dir_path.join(&server_config_filename),
482+
path_provider_path.join(&server_config_filename),
479483
base_dir.join(&server_config_filename),
480484
)?;
481485

@@ -495,7 +499,7 @@ impl LocalKubernetesNet {
495499
let local_port = 19100 + i;
496500
kubectl_instance.port_forward(
497501
proxy_service,
498-
&format!("{local_port}:{local_port}"),
502+
&format!("{local_port}:19100"),
499503
cluster_id,
500504
)?;
501505

0 commit comments

Comments
 (0)