add unit test for alias
@@ -663,6 +663,38 @@ var _ = Describe("Prometheus", func() {
Expect(result.Desc().String()).To(ContainSubstring("kubevirt_vmi_storage_flush_times_ms_total"))
})
+ It("should respect aliases", func() {
+ ch := make(chan prometheus.Metric, 1)
+ defer close(ch)
+
+ ps := prometheusScraper{ch: ch}
+
+ vmStats := &stats.DomainStats{
+ Cpu: &stats.DomainStatsCPU{},
+ Memory: &stats.DomainStatsMemory{},
+ Block: []stats.DomainStatsBlock{
+ {
+ NameSet: true,
+ Name: "vda",
+ Alias: "disk0",
+ FlTimesSet: true,
+ FlTimes: 1000000,
+ },
+ },
+ }
+
+ vmi := k6tv1.VirtualMachineInstance{}
+ ps.Report("test", &vmi, vmStats)
+
+ result := <-ch
+ Expect(result).ToNot(BeNil())
+
+ dto := &io_prometheus_client.Metric{}
+ err := result.Write(dto)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(dto.String()).To(ContainSubstring("name:\"drive\" value:\"disk0\""))
+ })
+
It("should not expose nameless block metrics", func() {
ch := make(chan prometheus.Metric, 1)
defer close(ch)
