-
Notifications
You must be signed in to change notification settings - Fork 1.1k
test/stats.bats: fixes #4064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test/stats.bats: fixes #4064
Conversation
test/stats.bats
Outdated
| [ "$status" -eq 0 ] | ||
| ctr1_memory_bytes="$output" | ||
| run echo $ctr2_stats_JSON | jq -e '.stats[0].memory.workingSetBytes.value' | ||
| jq -e '.stats[0].attributes.id == "'$ctr2_id'"' <<< "$output" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we lost ctr1_memory_bytes here
I think these would be better if we just did
ctr1_stats_JSON=$(crictl stats -o json --id "$ctr1_id")
ctr2_stats_JSON=$(crictl stats -o json --id "$ctr2_id")
ctr1_memory_bytes=$(echo $ctr1_stats_JSON | jq -e '.stats[0].memory.workingSetBytes.value')
ctr2_memory_bytes=$(echo $ctr2_stats_JSON | jq -e '.stats[0].memory.workingSetBytes.value')
maybe echoing them between?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we lost ctr1_memory_bytes here
Sorry, I don't understand what you mean here. ctr1_memory_bytes is assigned here: 01813a8#diff-103e5e134054b75239970c4fbec2f5e0R68
I think these would be better if we just did
you're right, and it's better to take it one step further:
set -o pipefail
ctr1_mem=$(crictl stats -o json --id "$ctr1_id" | jq -e '.stats[0].memory.workingSetBytes.value')
ctr2_mem=$(crictl stats -o json --id "$ctr2_id" | jq -e '.stats[0].memory.workingSetBytes.value')maybe echoing them between
please see the updated commit.
Initially I wanted to change as little as possible. Ended up with more radical approach. Let me know what you think.
Codecov Report
@@ Coverage Diff @@
## master #4064 +/- ##
==========================================
+ Coverage 41.11% 41.39% +0.27%
==========================================
Files 109 110 +1
Lines 9030 9061 +31
==========================================
+ Hits 3713 3751 +38
+ Misses 4978 4970 -8
- Partials 339 340 +1 |
|
I am also looking at this, it seems the test needs a bit more love... |
|
@kolyshkin wdyt about 71d459d |
Makes sense. Added on top of my changes under your authorship, PTAL @haircommander One issue though is I'm not sure if memory usage will be different in this case :-\ |
|
/retest |
As I suspected :( I think we need to run one redis and one sleep container. @wgahnagl @haircommander WDYT? |
|
Nope, it's actually worse: |
|
With the fix from #4068 the stats are returned now, but not picked up by the test. Looking... |
|
The test is passing now, but failing with |
As pointed out by shellcheck:
> In test/stats.bats line 72:
> run crictl stats -o json "$crt2_id"
> ^------^ SC2154: crt2_id is referenced but not assigned.
The test works just fine though, because
1. it is the same as running crictl stats without ID, in which case it
shows stats for all IDs.
2. the values obtained are not compared in any way, just printed.
Signed-off-by: Kir Kolyshkin <[email protected]>
1. Ensure that stats are shown for the particular ID. 2. Simplify json checks: - use "here file" instead of echo and pipe - remove intermediate variable - remove useless run and status checks (set -e is sufficient Signed-off-by: Kir Kolyshkin <[email protected]>
1. Make sure we actually compare the memory usage, rather than merely printing it. Add a comment describing what we're doing here. 2. Use "here file" instead of echo. 3. Make sure stats are provided for the given id. 4. Consolidate getting memory usage so there are less temp variables. 5. When possible, use var=$(cmd ... 2>&1) echo "$var" instead of run cmd ... [ "$status" -eq 0 ] echo "$output" var="$output" They are roughly the same, and `set -e` (set by bats) implicitly checks the exit code. The `2>&1` stance is needed to see the error Signed-off-by: Kir Kolyshkin <[email protected]>
container_redis.json seems to intermittantly exit, which makes using it as the basis for comparison for stats tretcherous. Signed-off-by: Peter Hunt <[email protected]>
|
CI status failed to update again :-/ (and, according to /retest |
|
/test integration_crun |
|
/retest |
2 similar comments
|
/retest |
|
/retest |
saschagrunert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
/retest |
|
@kolyshkin: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kolyshkin, mrunalp, saschagrunert The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/kind bug
See individual commits for more details.
Currently blocked by #4080 and #4068.@wgahnagl @haircommander PTAL