Skip to content

Commit

Permalink
Add task for list_all_resources.sh
Browse files Browse the repository at this point in the history
Signed-off-by: mehabhalodiya <mehabhalodiya@gmail.com>
  • Loading branch information
mehabhalodiya committed Dec 5, 2024
1 parent 1ca4ba8 commit 9bc0b15
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions reliability-v2/config/reliability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ reliability:
- func apply_nonamespace -p "<path_to_content>/network-policy/02_anp_allow-traffic-egress-cidr-cluster-network-p20.yaml"
- func apply_nonamespace -p "<path_to_content>/network-policy/04_anp_allow-traffic-dev-test-p30.yaml"
- func apply_nonamespace -p "<path_to_content>/network-policy/03_anp_allow-traffic-dev-prod-p31.yaml"
- <path_to_script>/list_all_resources.sh
tasks:
- func check_operators
- oc get project -l purpose=reliability
- func check_nodes
- kubectl get pods -A -o wide | egrep -v "Completed|Running"
# Run test case as scripts. KUBECONFIG of the current user is set as env variable by reliability-v2.
#- . <path_to_script>/create-delete-pod-ensure-service.sh
post_tasks:
- <path_to_script>/list_all_resources.sh

- name: dev-test
user_name: testuser- # if user_start and user_end exist, this will be username prefix
Expand Down
2 changes: 1 addition & 1 deletion reliability-v2/tasks/Tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,4 +445,4 @@ def check_netobserv_pods(self, user):
else:
self.logger.error(f"Pods status fetch error: result {result}, rc - {rc}")

return (result, rc_return)
return (result, rc_return)
30 changes: 15 additions & 15 deletions reliability-v2/tasks/script/list_all_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ get_all_items() {
fi
elapsed_time=$(($(date +%s) - start_time))
if [[ "$VERBOSE" == true ]]; then
echo "$this_type: ${elapsed_time}s"
echo "$this_type: ${elapsed_time}s" >> resource_list.log
fi
if [[ -n "$result" ]]; then
for this_result in $result; do
Expand All @@ -88,7 +88,7 @@ get_all_items() {
done
fi
done
echo -e "${type_items[@]}"
echo -e "${type_items[@]}" >> resource_list.log
}

# Function to print items based on the output format
Expand All @@ -97,32 +97,32 @@ print_items() {
local output=${OUTPUT:-"list"}
for this_type in "${all_items[@]}"; do
if [[ "$output" == "list" ]]; then
echo -e "\n\n==============="
echo "TYPE: $this_type"
echo -e "${all_items[$this_type]}"
echo -e "\n\n==============="
echo -e "\n\n===============" >> resource_list.log
echo "TYPE: $this_type" >> resource_list.log
echo -e "${all_items[$this_type]}" >> resource_list.log
echo -e "\n\n===============" >> resource_list.log
elif [[ "$output" == "ns-count" ]]; then
declare -A ns_count
for item in ${all_items[$this_type]}; do
ns="${item%%:*}"
((ns_count["$ns"]++))
done
echo -e "\n\n==============="
echo "TYPE: $this_type"
echo -e "\n\n===============" >> resource_list.log
echo "TYPE: $this_type" >> resource_list.log
for ns in "${!ns_count[@]}"; do
echo -e "\t$ns: ${ns_count[$ns]}"
echo -e "\n\n==============="
echo -e "\t$ns: ${ns_count[$ns]}" >> resource_list.log
echo -e "\n\n===============" >> resource_list.log
done
else
count=0
echo -e "\n\n==============="
echo "TYPE: $this_type"
echo -e "\n\n===============" >> resource_list.log
echo "TYPE: $this_type" >> resource_list.log
for item in ${all_items[$this_type]}; do
echo "$item"
echo "$item" >> resource_list.log
((count++))
done
echo "$this_type Count: $count"
echo -e "\n\n==============="
echo "$this_type Count: $count" >> resource_list.log
echo -e "\n\n===============" >> resource_list.log
fi


Expand Down

0 comments on commit 9bc0b15

Please sign in to comment.