Skip to content

Commit 6198d1c

Browse files
committed
bug fixes
1 parent d07488e commit 6198d1c

File tree

4 files changed

+70
-50
lines changed

4 files changed

+70
-50
lines changed

scripts/cli/playground

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10253,7 +10253,6 @@ function bootstrap_ccloud_environment () {
1025310253
fi
1025410254

1025510255
playground ccloud-costs-history > /tmp/ccloud-costs-history.txt &
10256-
playground ccloud-costs-history --detailed > /tmp/ccloud-costs-history-detailed.txt &
1025710256

1025810257
suggest_use_previous_example_ccloud=1
1025910258
test_file=$(playground state get run.test_file)
@@ -14363,12 +14362,6 @@ playground_ccloud_costs_history_command() {
1436314362

1436414363
current_date="$start_date"
1436514364

14366-
maybe_display_only_total_cost="--display-only-total-cost"
14367-
if [[ -n "$detailed" ]]
14368-
then
14369-
maybe_display_only_total_cost=""
14370-
fi
14371-
1437214365
# Function to display histograms
1437314366
display_histogram() {
1437414367
local label=$1
@@ -14396,15 +14389,26 @@ playground_ccloud_costs_history_command() {
1439614389
# Break the loop if end_date is in the future
1439714390
if [[ "$end_date" > "$(date +%Y-%m-%d)" ]]; then
1439814391
end_date=$(date +%Y-%m-%d) # Set end_date to today
14399-
cost=$(playground ccloud-costs --start-date "$current_date" --end-date "$end_date" $maybe_display_only_total_cost)
14392+
cost=$(playground ccloud-costs --start-date "$current_date" --end-date "$end_date" --display-only-total-cost)
1440014393
display_histogram "$(readable_date $current_date) to $(readable_date $end_date)" "$cost"
14394+
if [[ -n "$detailed" ]]
14395+
then
14396+
playground ccloud-costs --start-date "$current_date" --end-date "$end_date"
14397+
14398+
fi
1440114399
break
1440214400
fi
1440314401

1440414402
# Call playground ccloud-costs for the current range
14405-
cost=$(playground ccloud-costs --start-date "$current_date" --end-date "$end_date" $maybe_display_only_total_cost)
14403+
cost=$(playground ccloud-costs --start-date "$current_date" --end-date "$end_date" --display-only-total-cost)
1440614404
display_histogram "$(readable_date $current_date) to $(readable_date $end_date)" "$cost"
1440714405

14406+
if [[ -n "$detailed" ]]
14407+
then
14408+
playground ccloud-costs --start-date "$current_date" --end-date "$end_date"
14409+
14410+
fi
14411+
1440814412
# Move to the next range
1440914413
current_date="$end_date"
1441014414
done
@@ -16013,24 +16017,9 @@ playground_run_command() {
1601316017
fi
1601416018
check_for_ec2_instance_running
1601516019

16016-
if [ -z "$GITHUB_RUN_NUMBER" ]
16017-
then
16018-
if [[ $test_file == *"ccloud"* ]]
16019-
then
16020-
if [ -f /tmp/ccloud-costs-history.txt ]
16021-
then
16022-
log "📅💰 monthly ccloud costs"
16023-
cat /tmp/ccloud-costs-history.txt
16024-
fi
16025-
if [ -f /tmp/ccloud-costs-history-detailed.txt ]
16026-
then
16027-
log "👀 if you want more details, open /tmp/ccloud-costs-history-detailed.txt file"
16028-
fi
16029-
fi
16030-
fi
16031-
1603216020
if [ ! -z "$ENABLE_JMX_GRAFANA" ]
1603316021
then
16022+
echo ""
1603416023
if [[ $test_file == *"ccloud"* ]]
1603516024
then
1603616025
log "🛡️ Prometheus is reachable at http://127.0.0.1:9090"
@@ -16077,6 +16066,28 @@ playground_run_command() {
1607716066
fi
1607816067
fi
1607916068
fi
16069+
16070+
if [ -z "$GITHUB_RUN_NUMBER" ]
16071+
then
16072+
if [[ $test_file == *"ccloud"* ]]
16073+
then
16074+
echo ""
16075+
# wait that process with "playground ccloud-costs-history" is finished
16076+
set +e
16077+
while pgrep -f "playground ccloud-costs-history" > /dev/null
16078+
do
16079+
log "⌛ wait for monthly ccloud costs..."
16080+
sleep 5
16081+
done
16082+
set -e
16083+
if [ -f /tmp/ccloud-costs-history.txt ]
16084+
then
16085+
log "📅💰 monthly ccloud costs"
16086+
cat /tmp/ccloud-costs-history.txt
16087+
fi
16088+
log "👀 if you want more details, run <playground ccloud-costs-history --detailed>"
16089+
fi
16090+
fi
1608016091
}
1608116092

1608216093
# :command.function

scripts/cli/src/commands/ccloud-costs-history.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ fi
1717

1818
current_date="$start_date"
1919

20-
maybe_display_only_total_cost="--display-only-total-cost"
21-
if [[ -n "$detailed" ]]
22-
then
23-
maybe_display_only_total_cost=""
24-
fi
25-
2620
# Function to display histograms
2721
display_histogram() {
2822
local label=$1
@@ -50,15 +44,24 @@ while true; do
5044
# Break the loop if end_date is in the future
5145
if [[ "$end_date" > "$(date +%Y-%m-%d)" ]]; then
5246
end_date=$(date +%Y-%m-%d) # Set end_date to today
53-
cost=$(playground ccloud-costs --start-date "$current_date" --end-date "$end_date" $maybe_display_only_total_cost)
47+
cost=$(playground ccloud-costs --start-date "$current_date" --end-date "$end_date" --display-only-total-cost)
5448
display_histogram "$(readable_date $current_date) to $(readable_date $end_date)" "$cost"
49+
if [[ -n "$detailed" ]]
50+
then
51+
playground ccloud-costs --start-date "$current_date" --end-date "$end_date"
52+
fi
5553
break
5654
fi
5755

5856
# Call playground ccloud-costs for the current range
59-
cost=$(playground ccloud-costs --start-date "$current_date" --end-date "$end_date" $maybe_display_only_total_cost)
57+
cost=$(playground ccloud-costs --start-date "$current_date" --end-date "$end_date" --display-only-total-cost)
6058
display_histogram "$(readable_date $current_date) to $(readable_date $end_date)" "$cost"
6159

60+
if [[ -n "$detailed" ]]
61+
then
62+
playground ccloud-costs --start-date "$current_date" --end-date "$end_date"
63+
fi
64+
6265
# Move to the next range
6366
current_date="$end_date"
6467
done

scripts/cli/src/commands/run.sh

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,24 +1587,9 @@ else
15871587
fi
15881588
check_for_ec2_instance_running
15891589

1590-
if [ -z "$GITHUB_RUN_NUMBER" ]
1591-
then
1592-
if [[ $test_file == *"ccloud"* ]]
1593-
then
1594-
if [ -f /tmp/ccloud-costs-history.txt ]
1595-
then
1596-
log "📅💰 monthly ccloud costs"
1597-
cat /tmp/ccloud-costs-history.txt
1598-
fi
1599-
if [ -f /tmp/ccloud-costs-history-detailed.txt ]
1600-
then
1601-
log "👀 if you want more details, open /tmp/ccloud-costs-history-detailed.txt file"
1602-
fi
1603-
fi
1604-
fi
1605-
16061590
if [ ! -z "$ENABLE_JMX_GRAFANA" ]
16071591
then
1592+
echo ""
16081593
if [[ $test_file == *"ccloud"* ]]
16091594
then
16101595
log "🛡️ Prometheus is reachable at http://127.0.0.1:9090"
@@ -1650,4 +1635,26 @@ then
16501635
fi
16511636
fi
16521637
fi
1638+
fi
1639+
1640+
if [ -z "$GITHUB_RUN_NUMBER" ]
1641+
then
1642+
if [[ $test_file == *"ccloud"* ]]
1643+
then
1644+
echo ""
1645+
# wait that process with "playground ccloud-costs-history" is finished
1646+
set +e
1647+
while pgrep -f "playground ccloud-costs-history" > /dev/null
1648+
do
1649+
log "⌛ wait for monthly ccloud costs..."
1650+
sleep 5
1651+
done
1652+
set -e
1653+
if [ -f /tmp/ccloud-costs-history.txt ]
1654+
then
1655+
log "📅💰 monthly ccloud costs"
1656+
cat /tmp/ccloud-costs-history.txt
1657+
fi
1658+
log "👀 if you want more details, run <playground ccloud-costs-history --detailed>"
1659+
fi
16531660
fi

scripts/cli/src/lib/utils_function.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,6 @@ function bootstrap_ccloud_environment () {
17451745
fi
17461746

17471747
playground ccloud-costs-history > /tmp/ccloud-costs-history.txt &
1748-
playground ccloud-costs-history --detailed > /tmp/ccloud-costs-history-detailed.txt &
17491748

17501749
suggest_use_previous_example_ccloud=1
17511750
test_file=$(playground state get run.test_file)

0 commit comments

Comments
 (0)