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
b4f5b64a
Unverified
Commit
b4f5b64a
authored
1 year ago
by
s0me0ne-unkn0wn
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Generalize metric assertions (#189)
parent
1b124e59
Branches
Branches containing commit
No related merge requests found
Pipeline
#455804
failed with stage
in 7 minutes and 50 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
crates/orchestrator/src/network/node.rs
+13
-3
13 additions, 3 deletions
crates/orchestrator/src/network/node.rs
with
13 additions
and
3 deletions
crates/orchestrator/src/network/node.rs
+
13
−
3
View file @
b4f5b64a
...
...
@@ -148,17 +148,27 @@ impl NetworkNode {
&
self
,
metric_name
:
impl
Into
<
String
>
,
value
:
impl
Into
<
f64
>
,
)
->
Result
<
bool
,
anyhow
::
Error
>
{
let
value
:
f64
=
value
.into
();
self
.assert_with
(
metric_name
,
|
v
|
v
==
value
)
.await
}
/// Assert on a metric value using a given predicate.
/// See [`assert`] description for details.
pub
async
fn
assert_with
(
&
self
,
metric_name
:
impl
Into
<
String
>
,
predicate
:
impl
Fn
(
f64
)
->
bool
,
)
->
Result
<
bool
,
anyhow
::
Error
>
{
let
metric_name
=
metric_name
.into
();
let
value
=
value
.into
();
let
val
=
self
.metric
(
&
metric_name
)
.await
?
;
if
val
==
val
ue
{
if
predicate
(
val
)
{
Ok
(
true
)
}
else
{
// reload metrics
self
.fetch_metrics
()
.await
?
;
let
val
=
self
.metric
(
&
metric_name
)
.await
?
;
Ok
(
val
==
val
ue
)
Ok
(
predicate
(
val
)
)
}
}
...
...
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