Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zombienet-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
zombienet-sdk
Commits
8b620fb9
Unverified
Commit
8b620fb9
authored
11 months ago
by
Javier Viola
Committed by
GitHub
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fix(orchestrator): compute args_output in add_node/collator (#199)
parent
c70e180a
Branches
Branches containing commit
No related merge requests found
Pipeline
#460359
passed with stage
in 10 minutes and 48 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
crates/orchestrator/src/network.rs
+15
-2
15 additions, 2 deletions
crates/orchestrator/src/network.rs
crates/orchestrator/src/network_spec.rs
+43
-1
43 additions, 1 deletion
crates/orchestrator/src/network_spec.rs
crates/sdk/tests/smoke.rs
+26
-1
26 additions, 1 deletion
crates/sdk/tests/smoke.rs
with
84 additions
and
4 deletions
crates/orchestrator/src/network.rs
+
15
−
2
View file @
8b620fb9
...
...
@@ -144,8 +144,15 @@ impl<T: FileSystem> Network<T> {
default_args
:
self
.initial_spec.relaychain.default_args
.iter
()
.collect
(),
};
let
node_spec
=
let
mut
node_spec
=
network_spec
::
node
::
NodeSpec
::
from_ad_hoc
(
&
name
,
options
.into
(),
&
chain_context
)
?
;
node_spec
.available_args_output
=
Some
(
self
.initial_spec
.node_available_args_output
(
&
node_spec
,
self
.ns
.clone
())
.await
?
,
);
let
base_dir
=
self
.ns
.base_dir
()
.to_string_lossy
();
let
scoped_fs
=
ScopedFilesystem
::
new
(
&
self
.filesystem
,
&
base_dir
);
...
...
@@ -288,9 +295,15 @@ impl<T: FileSystem> Network<T> {
));
}
let
node_spec
=
let
mut
node_spec
=
network_spec
::
node
::
NodeSpec
::
from_ad_hoc
(
name
.into
(),
options
.into
(),
&
chain_context
)
?
;
node_spec
.available_args_output
=
Some
(
self
.initial_spec
.node_available_args_output
(
&
node_spec
,
self
.ns
.clone
())
.await
?
,
);
let
node
=
spawner
::
spawn_node
(
&
node_spec
,
global_files_to_inject
,
&
ctx
)
.await
?
;
let
para
=
self
.parachains
.get_mut
(
&
para_id
)
.unwrap
();
para
.collators
.push
(
node
.clone
());
...
...
This diff is collapsed.
Click to expand it.
crates/orchestrator/src/network_spec.rs
+
43
−
1
View file @
8b620fb9
...
...
@@ -7,7 +7,7 @@ use configuration::{
shared
::
constants
::
THIS_IS_A_BUG
,
GlobalSettings
,
HrmpChannelConfig
,
NetworkConfig
,
};
use
futures
::
future
::
try_join_all
;
use
provider
::
ProviderNamespace
;
use
provider
::
{
ProviderError
,
ProviderNamespace
}
;
use
tracing
::
debug
;
use
crate
::
errors
::
OrchestratorError
;
...
...
@@ -82,6 +82,48 @@ impl NetworkSpec {
Ok
(())
}
//
pub
async
fn
node_available_args_output
(
&
self
,
node_spec
:
&
NodeSpec
,
ns
:
Arc
<
dyn
ProviderNamespace
+
Send
+
Sync
>
,
)
->
Result
<
String
,
ProviderError
>
{
// try to find a node that use the same combination of image/cmd
let
cmp_fn
=
|
ad_hoc
:
&&
NodeSpec
|
->
bool
{
ad_hoc
.image
==
node_spec
.image
&&
ad_hoc
.command
==
node_spec
.command
};
// check if we already had computed the args output for this cmd/[image]
let
node
=
self
.relaychain.nodes
.iter
()
.find
(
cmp_fn
);
let
node
=
if
let
Some
(
node
)
=
node
{
Some
(
node
)
}
else
{
let
node
=
self
.parachains
.iter
()
.find_map
(|
para
|
para
.collators
.iter
()
.find
(
cmp_fn
));
node
};
let
output
=
if
let
Some
(
node
)
=
node
{
node
.available_args_output
.clone
()
.expect
(
&
format!
(
"args_output should be set for running nodes {THIS_IS_A_BUG}"
))
}
else
{
// we need to compute the args output
let
image
=
node_spec
.image
.as_ref
()
.map
(|
image
|
image
.as_str
()
.to_string
());
let
command
=
node_spec
.command
.as_str
()
.to_string
();
ns
.get_node_available_args
((
command
,
image
))
.await
?
};
Ok
(
output
)
}
// collect mutable references to all nodes from relaychain and parachains
fn
collect_network_nodes
(
&
mut
self
)
->
Vec
<&
mut
NodeSpec
>
{
vec!
[
...
...
This diff is collapsed.
Click to expand it.
crates/sdk/tests/smoke.rs
+
26
−
1
View file @
8b620fb9
...
...
@@ -6,6 +6,7 @@ use std::{
use
configuration
::{
NetworkConfig
,
NetworkConfigBuilder
};
use
futures
::{
stream
::
StreamExt
,
Future
};
use
orchestrator
::{
AddCollatorOptions
,
AddNodeOptions
};
use
serde_json
::
json
;
use
support
::
fs
::
local
::
LocalFileSystem
;
use
zombienet_sdk
::{
Network
,
NetworkConfigExt
,
OrchestratorError
,
PROVIDERS
};
...
...
@@ -57,7 +58,6 @@ async fn ci_k8s_basic_functionalities_should_works() {
let
config
=
small_network
();
let
spawn_fn
=
get_spawn_fn
();
#[allow(unused_mut)]
let
mut
network
=
spawn_fn
(
config
)
.await
.unwrap
();
// Optionally detach the network
// network.detach().await;
...
...
@@ -129,6 +129,31 @@ async fn ci_k8s_basic_functionalities_should_works() {
println!
(
"Block (para) #{}"
,
block
.unwrap
()
.header
()
.number
);
}
// add node
let
opts
=
AddNodeOptions
{
rpc_port
:
Some
(
9444
),
is_validator
:
true
,
..
Default
::
default
()
};
network
.add_node
(
"new1"
,
opts
)
.await
.unwrap
();
// add collator
let
col_opts
=
AddCollatorOptions
{
command
:
Some
(
"polkadot-parachain"
.try_into
()
.unwrap
()),
image
:
Some
(
"docker.io/parity/polkadot-parachain:1.7.0"
.try_into
()
.unwrap
(),
),
..
Default
::
default
()
};
network
.add_collator
(
"new-col-1"
,
col_opts
,
2000
)
.await
.unwrap
();
// tear down (optional if you don't detach the network)
// network.destroy().await.unwrap();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment