@@ -13,7 +13,6 @@ use linera_base::{
1313 data_types:: Amount ,
1414} ;
1515use linera_client:: client_options:: ResourceControlPolicyConfig ;
16- use tempfile:: { tempdir, TempDir } ;
1716use tokio:: process:: Command ;
1817#[ cfg( with_testing) ]
1918use { 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