-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NTCE and hotspots summary commands (#23)
* Add new ntce and hotspot summary commands * Bump version * Add tests for get_time_period function * Update src/lib/functions/get_time_period.sh Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Fix yamllint errors, regenerate keencli --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b7c8907
commit 973799c
Showing
8 changed files
with
1,051 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# shellcheck disable=SC2154 | ||
http_command \ | ||
"${args[--baseurl]}" \ | ||
"/ci/${args[system_filename]}.txt" \ | ||
"/ci/${args[configuration_file]}.txt" \ | ||
"${args[request_data]}" \ | ||
"${args[--output]}" \ | ||
"${args[--format]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function get_time_period() { | ||
case "${1:?time_period must be set}" in | ||
3m) | ||
echo 0 | ||
;; | ||
1h) | ||
echo 1 | ||
;; | ||
3h) | ||
echo 2 | ||
;; | ||
24h) | ||
echo 3 | ||
;; | ||
*) | ||
error "Unknown time period ${1}" | ||
;; | ||
esac | ||
} |
2 changes: 1 addition & 1 deletion
2
src/show_ip_hotspot_command.sh → src/show_ip_hotspot_list_command.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# shellcheck disable=SC2154 | ||
metric_type="${args[--metric_type]}" | ||
count="${args[--count]}" | ||
time_period=$(get_time_period "${args[--time_period]}") | ||
|
||
url_path="/rci/show/ip/hotspot/summary?attribute=${metric_type}&count=${count}&detail=${time_period}" | ||
|
||
http_command \ | ||
"${args[--baseurl]}" \ | ||
"${url_path}" \ | ||
"${args[request_data]}" \ | ||
"${args[--output]}" \ | ||
"${args[--format]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# shellcheck disable=SC2154 | ||
traffic_type="${args[--traffic_type]}" | ||
metric_type="${args[--metric_type]}" | ||
count="${args[--count]}" | ||
time_period=$(get_time_period "${args[--time_period]}") | ||
|
||
url_path="/rci/show/ntce/summary?${traffic_type}=true&attrib=${metric_type}&count=${count}&detail=${time_period}" | ||
|
||
http_command \ | ||
"${args[--baseurl]}" \ | ||
"${url_path}" \ | ||
"${args[request_data]}" \ | ||
"${args[--output]}" \ | ||
"${args[--format]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bats | ||
|
||
load test_helper.bash | ||
|
||
# shellcheck source=../src/lib/functions/logging.sh | ||
source "src/lib/functions/logging.sh" | ||
# shellcheck source=../src/lib/functions/get_time_period.sh | ||
source "src/lib/functions/get_time_period.sh" | ||
|
||
@test "without parameters" { | ||
run get_time_period | ||
[ "$status" -ne 0 ] | ||
} | ||
|
||
@test "with correct parameter" { | ||
run get_time_period 3m | ||
[ "$status" -eq 0 ] | ||
[ "$output" = "0" ] | ||
|
||
run get_time_period 1h | ||
[ "$status" -eq 0 ] | ||
[ "$output" = "1" ] | ||
|
||
run get_time_period 3h | ||
[ "$status" -eq 0 ] | ||
[ "$output" = "2" ] | ||
|
||
run get_time_period 24h | ||
[ "$status" -eq 0 ] | ||
[ "$output" = "3" ] | ||
} | ||
|
||
@test "with uncorrect parameter" { | ||
run get_time_period 25h | ||
[ "$status" -ne 0 ] | ||
|
||
run get_time_period adsadasdasd | ||
[ "$status" -ne 0 ] | ||
} |