add alias test
@@ -829,6 +829,25 @@ var _ = Describe("[Serial][sig-compute]Infrastructure", func() {
table.Entry("storage write traffic in bytes metric by using IPv6", k8sv1.IPv6Protocol, "kubevirt_vmi_storage_write_traffic_bytes_total", ">="),
)
+ table.DescribeTable("should respect alias for disk names", func(family k8sv1.IPFamily, metricSubstring string) {
+ if family == k8sv1.IPv6Protocol {
+ libnet.SkipWhenNotDualStackCluster(virtClient)
+ }
+
+ ip := getSupportedIP(metricsIPs, family)
+ metrics := collectMetrics(ip, metricSubstring)
+ keys := getKeysFromMetrics(metrics)
+ for _, vmi := range preparedVMIs {
+ for _, vol := range vmi.Spec.Volumes {
+ key := getMetricKeyForVmiDisk(keys, vmi.Name, vol.Name)
+ Expect(key).To(Not(BeEmpty()))
+ }
+ }
+ },
+ table.Entry("[test_id:4142] by using IPv4", k8sv1.IPv4Protocol, "kubevirt_vmi_storage_read_traffic_bytes_total"),
+ table.Entry("[test_id:4142] by using IPv6", k8sv1.IPv6Protocol, "kubevirt_vmi_storage_read_traffic_bytes_total"),
+ )
+
table.DescribeTable("should include metrics for a running VM", func(family k8sv1.IPFamily, metricSubstring, operator string) {
if family == k8sv1.IPv6Protocol {
libnet.SkipWhenNotDualStackCluster(virtClient)
@@ -1379,3 +1398,13 @@ func getSupportedIP(ips []string, family k8sv1.IPFamily) string {
func prepareMetricsURL(ip string, port int) string {
return fmt.Sprintf("https://%s/metrics", net.JoinHostPort(ip, strconv.Itoa(port)))
}
+
+func getMetricKeyForVmiDisk(keys []string, vmiName string, diskName string) interface{} {
+ for _, key := range keys {
+ if strings.Contains(key, "name=\""+vmiName+"\"") &&
+ strings.Contains(key, "drive=\""+diskName+"\"") {
+ return key
+ }
+ }
+ return ""
+}
