Skip to content

Commit

Permalink
Collect running VMs count (#191)
Browse files Browse the repository at this point in the history
Signed-off-by: assafad <[email protected]>
  • Loading branch information
assafad authored Nov 30, 2023
1 parent f6ceb2f commit 7b88169
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions collection-scripts/gather
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function main() {
"virtualmachines"
"webhooks"
"instancetypes"
"virtualization"
)
declare requested_scripts=("${mandatory_scripts[@]}")

Expand Down
15 changes: 15 additions & 0 deletions collection-scripts/gather_virtualization
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -x

DIR_NAME=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source "${DIR_NAME}/common.sh"
check_command

VIRTUALIZATION_PATH="${BASE_COLLECTION_PATH}/virtualization"
mkdir -p "${VIRTUALIZATION_PATH}"

function collect_running_vms_count() {
/usr/bin/oc get vmi --all-namespaces -o=jsonpath='{.items[?(@.status.phase=="Running")].metadata.name}' | wc -w > "${VIRTUALIZATION_PATH}/running_vms_count.txt"
}

collect_running_vms_count

14 changes: 14 additions & 0 deletions tests/validate_must_gather_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,20 @@ var _ = Describe("validate the must-gather output", func() {
Entry("should gather resources in ns005", "ns005"),
)
})

Context("[level:product]validate the virtualization directory", Label("level:product"), func() {
virtualizationDir := "virtualization"

// This test assumes, according to automation/create_workloads.sh, that there are 5 running VMs in the cluster.
It("should validate the running VMs count", func() {
runningVmsCountPath := path.Join(outputDir, virtualizationDir, "running_vms_count.txt")
countBytes, err := os.ReadFile(runningVmsCountPath)
Expect(err).ToNot(HaveOccurred())

count := strings.TrimSpace(string(countBytes))
Expect(count).To(Equal("5"))
})
})
})

func validateVmFile(vm, ns, vmPath string) {
Expand Down

0 comments on commit 7b88169

Please sign in to comment.