Skip to content

Commit

Permalink
tests: Remove table prefix
Browse files Browse the repository at this point in the history
The table prefix is not needed anymore
because it is part of core Ginkgo 2.0 DSL.

Signed-off-by: Or Shoval <[email protected]>
  • Loading branch information
oshoval committed Mar 20, 2022
1 parent 81dc679 commit 764465f
Show file tree
Hide file tree
Showing 124 changed files with 1,974 additions and 2,101 deletions.
31 changes: 15 additions & 16 deletions pkg/container-disk/container-disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"strings"

. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
k8sv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -82,12 +81,12 @@ var _ = Describe("ContainerDisk", func() {

Describe("container-disk", func() {
Context("verify helper functions", func() {
table.DescribeTable("by verifying mapping of ",
DescribeTable("by verifying mapping of ",
func(diskType string) {
VerifyDiskType(diskType)
},
table.Entry("qcow2 disk", "qcow2"),
table.Entry("raw disk", "raw"),
Entry("qcow2 disk", "qcow2"),
Entry("raw disk", "raw"),
)
It("by verifying error when no disk is present", func() {

Expand Down Expand Up @@ -317,7 +316,7 @@ var _ = Describe("ContainerDisk", func() {
Expect(err.Error()).To(Equal(`failed to identify image digest for container "someimage:v1.2.3.4" with id "rubish"`))
})

table.DescribeTable("It should detect the image ID from", func(imageID string) {
DescribeTable("It should detect the image ID from", func(imageID string) {
expected := "myregistry.io/myimage@sha256:4gjffGJlg4"
res, err := toImageWithDigest("myregistry.io/myimage", imageID)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -329,23 +328,23 @@ var _ = Describe("ContainerDisk", func() {
Expect(err).ToNot(HaveOccurred())
Expect(res).To(Equal(expected))
},
table.Entry("docker", "docker://sha256:4gjffGJlg4"),
table.Entry("dontainerd", "sha256:4gjffGJlg4"),
table.Entry("cri-o", "myregistry/myimage@sha256:4gjffGJlg4"),
Entry("docker", "docker://sha256:4gjffGJlg4"),
Entry("dontainerd", "sha256:4gjffGJlg4"),
Entry("cri-o", "myregistry/myimage@sha256:4gjffGJlg4"),
)

table.DescribeTable("It should detect the base image from", func(given, expected string) {
DescribeTable("It should detect the base image from", func(given, expected string) {
res, err := toImageWithDigest(given, "docker://sha256:4gjffGJlg4")
Expect(err).ToNot(HaveOccurred())
Expect(strings.Split(res, "@sha256:")[0]).To(Equal(expected))
},
table.Entry("image with registry and no tags or shasum", "myregistry.io/myimage", "myregistry.io/myimage"),
table.Entry("image with registry and tag", "myregistry.io/myimage:latest", "myregistry.io/myimage"),
table.Entry("image with registry and shasum", "myregistry.io/myimage@sha256:123534", "myregistry.io/myimage"),
table.Entry("image with registry and no tags or shasum and custom port", "myregistry.io:5000/myimage", "myregistry.io:5000/myimage"),
table.Entry("image with registry and tag and custom port", "myregistry.io:5000/myimage:latest", "myregistry.io:5000/myimage"),
table.Entry("image with registry and shasum and custom port", "myregistry.io:5000/myimage@sha256:123534", "myregistry.io:5000/myimage"),
table.Entry("image with registry and shasum and custom port and group", "myregistry.io:5000/mygroup/myimage@sha256:123534", "myregistry.io:5000/mygroup/myimage"),
Entry("image with registry and no tags or shasum", "myregistry.io/myimage", "myregistry.io/myimage"),
Entry("image with registry and tag", "myregistry.io/myimage:latest", "myregistry.io/myimage"),
Entry("image with registry and shasum", "myregistry.io/myimage@sha256:123534", "myregistry.io/myimage"),
Entry("image with registry and no tags or shasum and custom port", "myregistry.io:5000/myimage", "myregistry.io:5000/myimage"),
Entry("image with registry and tag and custom port", "myregistry.io:5000/myimage:latest", "myregistry.io:5000/myimage"),
Entry("image with registry and shasum and custom port", "myregistry.io:5000/myimage@sha256:123534", "myregistry.io:5000/myimage"),
Entry("image with registry and shasum and custom port and group", "myregistry.io:5000/mygroup/myimage@sha256:123534", "myregistry.io:5000/mygroup/myimage"),
)
})
})
Expand Down
21 changes: 10 additions & 11 deletions pkg/downwardmetrics/vhostmd/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,27 @@ package metrics

import (
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"

"kubevirt.io/kubevirt/pkg/downwardmetrics/vhostmd/api"
)

var _ = Describe("metrics", func() {
table.DescribeTable("should write", func(value interface{}, result string, metricType api.MetricType) {
DescribeTable("should write", func(value interface{}, result string, metricType api.MetricType) {
m := MustToMetric(value, "TotalCPUTime", "", api.MetricContextHost)
Expect(m.Value).To(Equal(result))
Expect(m.Type).To(Equal(metricType))
Expect(m.Unit).To(BeEmpty())
},
table.Entry("string with proper type", "mystring", "mystring", api.MetricTypeString),
table.Entry("int with proper type", 1, "1", api.MetricTypeInt64),
table.Entry("uint with proper type", uint(1), "1", api.MetricTypeUInt64),
table.Entry("int64 with proper type", int64(1), "1", api.MetricTypeInt64),
table.Entry("uint64 with proper type", uint64(1), "1", api.MetricTypeUInt64),
table.Entry("int32 with proper type", int32(1), "1", api.MetricTypeInt32),
table.Entry("uint32 with proper type", uint32(1), "1", api.MetricTypeUInt32),
table.Entry("float64 with proper type", float64(1292869.190000), "1292869.190000", api.MetricTypeReal64),
table.Entry("float32 with proper type", float32(92869.1875), "92869.187500", api.MetricTypeReal32),
Entry("string with proper type", "mystring", "mystring", api.MetricTypeString),
Entry("int with proper type", 1, "1", api.MetricTypeInt64),
Entry("uint with proper type", uint(1), "1", api.MetricTypeUInt64),
Entry("int64 with proper type", int64(1), "1", api.MetricTypeInt64),
Entry("uint64 with proper type", uint64(1), "1", api.MetricTypeUInt64),
Entry("int32 with proper type", int32(1), "1", api.MetricTypeInt32),
Entry("uint32 with proper type", uint32(1), "1", api.MetricTypeUInt32),
Entry("float64 with proper type", float64(1292869.190000), "1292869.190000", api.MetricTypeReal64),
Entry("float32 with proper type", float32(92869.1875), "92869.187500", api.MetricTypeReal32),
)

It("should set the unit", func() {
Expand Down
9 changes: 4 additions & 5 deletions pkg/host-disk/host-disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (

"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
k8sv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -377,7 +376,7 @@ var _ = Describe("HostDisk", func() {
virtClient.EXPECT().CoreV1().Return(kubeClient.CoreV1()).AnyTimes()
})

table.DescribeTable("PVC in", func(mode k8sv1.PersistentVolumeMode, pvcReferenceObj string) {
DescribeTable("PVC in", func(mode k8sv1.PersistentVolumeMode, pvcReferenceObj string) {

pvcName := "madeup"

Expand Down Expand Up @@ -449,9 +448,9 @@ var _ = Describe("HostDisk", func() {

},

table.Entry("filemode", k8sv1.PersistentVolumeFilesystem, "disk"),
table.Entry("blockmode", k8sv1.PersistentVolumeBlock, "disk"),
table.Entry("filesystem passthrough", k8sv1.PersistentVolumeFilesystem, "filesystem"),
Entry("filemode", k8sv1.PersistentVolumeFilesystem, "disk"),
Entry("blockmode", k8sv1.PersistentVolumeBlock, "disk"),
Entry("filesystem passthrough", k8sv1.PersistentVolumeFilesystem, "filesystem"),
)
})

Expand Down
38 changes: 18 additions & 20 deletions pkg/monitoring/client/prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"net/http"
"net/url"

"github.com/onsi/ginkgo/extensions/table"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
Expand All @@ -34,7 +32,7 @@ var _ = BeforeSuite(func() {

var _ = Describe("URL Parsing", func() {
Context("with resource and operation", func() {
table.DescribeTable("accurately parse resource and operation", func(urlStr, method, expectedResource, expectedOperation string) {
DescribeTable("accurately parse resource and operation", func(urlStr, method, expectedResource, expectedOperation string) {

request := &http.Request{
Method: method,
Expand All @@ -48,23 +46,23 @@ var _ = Describe("URL Parsing", func() {
Expect(operation).To(Equal(expectedOperation))

},
table.Entry("should handle an empty URL and method", "", "", "", ""),
table.Entry("should handle an empty URL", "", "GET", "", ""),
table.Entry("should handle an empty Method", "/api/v1/watch/namespaces/kubevirt/pods", "", "", ""),
table.Entry("should handle watching namespaced resource", "/api/v1/watch/namespaces/kubevirt/pods", "GET", "pods", "WATCH"),
table.Entry("should handle watching globally scoped resource", "/api/v1/watch/pods", "GET", "pods", "WATCH"),
table.Entry("should handle list of namespaced resources", "/api/v1/namespaces/kubevirt/pods", "GET", "pods", "LIST"),
table.Entry("should handle get of namespaced resources", "/api/v1/namespaces/kubevirt/pods/my-pod", "GET", "pods", "GET"),
table.Entry("should handle list of custom namespaced resources", "/apis/kubevirt.io/v1/namespaces/kubevirt/virtualmachineinstances", "GET", "virtualmachineinstances", "LIST"),
table.Entry("should handle get of custom namespaced resources", "/apis/kubevirt.io/v1/namespaces/kubevirt/virtualmachineinstances/my-vmi", "GET", "virtualmachineinstances", "GET"),
table.Entry("should handle list of custom globally scoped resources", "/apis/kubevirt.io/v1/kubevirts", "GET", "kubevirts", "LIST"),
table.Entry("should handle get of custom globally scoped resources", "/apis/kubevirt.io/v1/kubevirts/my-kv", "GET", "kubevirts", "GET"),
table.Entry("should handle UPDATE of namespaced resources", "/api/v1/namespaces/kubevirt/pods/my-pod", "PUT", "pods", "UPDATE"),
table.Entry("should handle PATCH of namespaced resources", "/api/v1/namespaces/kubevirt/pods/my-pod", "PATCH", "pods", "PATCH"),
table.Entry("should handle CREATE of namespaced resources", "/api/v1/namespaces/kubevirt/pods/my-pod", "POST", "pods", "CREATE"),
table.Entry("should handle DELETE of namespaced resources", "/api/v1/namespaces/kubevirt/pods/my-pod", "DELETE", "pods", "DELETE"),
table.Entry("should handle UPDATE to status subresource", "/api/v1/namespaces/kubevirt/pods/my-pod/status", "PUT", "pods", "UPDATE"),
table.Entry("should handle UPDATE to custom subresource", "/apis/kubevirt.io/v1/namespaces/kubevirt/virtualmachineinstances/my-vmi/some-subresource", "PUT", "virtualmachineinstances", "UPDATE"),
Entry("should handle an empty URL and method", "", "", "", ""),
Entry("should handle an empty URL", "", "GET", "", ""),
Entry("should handle an empty Method", "/api/v1/watch/namespaces/kubevirt/pods", "", "", ""),
Entry("should handle watching namespaced resource", "/api/v1/watch/namespaces/kubevirt/pods", "GET", "pods", "WATCH"),
Entry("should handle watching globally scoped resource", "/api/v1/watch/pods", "GET", "pods", "WATCH"),
Entry("should handle list of namespaced resources", "/api/v1/namespaces/kubevirt/pods", "GET", "pods", "LIST"),
Entry("should handle get of namespaced resources", "/api/v1/namespaces/kubevirt/pods/my-pod", "GET", "pods", "GET"),
Entry("should handle list of custom namespaced resources", "/apis/kubevirt.io/v1/namespaces/kubevirt/virtualmachineinstances", "GET", "virtualmachineinstances", "LIST"),
Entry("should handle get of custom namespaced resources", "/apis/kubevirt.io/v1/namespaces/kubevirt/virtualmachineinstances/my-vmi", "GET", "virtualmachineinstances", "GET"),
Entry("should handle list of custom globally scoped resources", "/apis/kubevirt.io/v1/kubevirts", "GET", "kubevirts", "LIST"),
Entry("should handle get of custom globally scoped resources", "/apis/kubevirt.io/v1/kubevirts/my-kv", "GET", "kubevirts", "GET"),
Entry("should handle UPDATE of namespaced resources", "/api/v1/namespaces/kubevirt/pods/my-pod", "PUT", "pods", "UPDATE"),
Entry("should handle PATCH of namespaced resources", "/api/v1/namespaces/kubevirt/pods/my-pod", "PATCH", "pods", "PATCH"),
Entry("should handle CREATE of namespaced resources", "/api/v1/namespaces/kubevirt/pods/my-pod", "POST", "pods", "CREATE"),
Entry("should handle DELETE of namespaced resources", "/api/v1/namespaces/kubevirt/pods/my-pod", "DELETE", "pods", "DELETE"),
Entry("should handle UPDATE to status subresource", "/api/v1/namespaces/kubevirt/pods/my-pod/status", "PUT", "pods", "UPDATE"),
Entry("should handle UPDATE to custom subresource", "/apis/kubevirt.io/v1/namespaces/kubevirt/virtualmachineinstances/my-vmi/some-subresource", "PUT", "virtualmachineinstances", "UPDATE"),
)
})

Expand Down
11 changes: 5 additions & 6 deletions pkg/monitoring/domainstats/downwardmetrics/hostmetrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package downwardmetrics

import (
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
)

Expand Down Expand Up @@ -48,7 +47,7 @@ var _ = Describe("Hostmetrics", func() {
Expect(metrics[8].Unit).To(Equal("s"))
})

table.DescribeTable("should cope with failed reads on stats files and return what it can get for", func(cpuinfo, meminfo, stat, vmstat string, count int) {
DescribeTable("should cope with failed reads on stats files and return what it can get for", func(cpuinfo, meminfo, stat, vmstat string, count int) {
hostmetrics := &hostMetricsCollector{
procCPUInfo: cpuinfo,
procStat: meminfo,
Expand All @@ -61,10 +60,10 @@ var _ = Describe("Hostmetrics", func() {
Expect(len(metrics)).To(Equal(count))

},
table.Entry("cpuinfo", "nonexistent", "testdata/meminfo", "testdata/stat", "testdata/vmstat", 8),
table.Entry("meminfo", "testdata/cpuinfo", "nonexistent", "testdata/stat", "testdata/vmstat", 8),
table.Entry("stat", "testdata/cpuinfo", "testdata/meminfo", "nonexistent", "testdata/vmstat", 5),
table.Entry("vmstat", "testdata/cpuinfo", "testdata/meminfo", "testdata/stat", "nonexistent", 7),
Entry("cpuinfo", "nonexistent", "testdata/meminfo", "testdata/stat", "testdata/vmstat", 8),
Entry("meminfo", "testdata/cpuinfo", "nonexistent", "testdata/stat", "testdata/vmstat", 8),
Entry("stat", "testdata/cpuinfo", "testdata/meminfo", "nonexistent", "testdata/vmstat", 5),
Entry("vmstat", "testdata/cpuinfo", "testdata/meminfo", "testdata/stat", "nonexistent", 7),
)

})
25 changes: 12 additions & 13 deletions pkg/monitoring/perfscale/perfscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package perfscale
import (
"time"

"github.com/onsi/ginkgo/extensions/table"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

. "github.com/onsi/ginkgo"
Expand All @@ -36,7 +35,7 @@ var _ = BeforeSuite(func() {

var _ = Describe("VMI phase transition time histogram", func() {
Context("Transition Time calculations", func() {
table.DescribeTable("time diff calculations", func(expectedVal float64, curPhase v1.VirtualMachineInstancePhase, oldPhase v1.VirtualMachineInstancePhase) {
DescribeTable("time diff calculations", func(expectedVal float64, curPhase v1.VirtualMachineInstancePhase, oldPhase v1.VirtualMachineInstancePhase) {
var oldVMI *v1.VirtualMachineInstance

vmi := createVMISForPhaseTransitionTime(curPhase, oldPhase, expectedVal*1000, true)
Expand All @@ -50,16 +49,16 @@ var _ = Describe("VMI phase transition time histogram", func() {
Expect(diffSeconds).To(Equal(expectedVal))

},
table.Entry("Time between running and scheduled", 5.0, v1.Running, v1.Scheduled),
table.Entry("Time between running and scheduled using fraction of a second", .5, v1.Running, v1.Scheduled),
table.Entry("Time between scheduled and scheduling", 2.0, v1.Scheduled, v1.Scheduling),
table.Entry("Time between scheduling and pending", 1.0, v1.Scheduling, v1.Pending),
table.Entry("Time between running and failed", 1.0, v1.Running, v1.Failed),
Entry("Time between running and scheduled", 5.0, v1.Running, v1.Scheduled),
Entry("Time between running and scheduled using fraction of a second", .5, v1.Running, v1.Scheduled),
Entry("Time between scheduled and scheduling", 2.0, v1.Scheduled, v1.Scheduling),
Entry("Time between scheduling and pending", 1.0, v1.Scheduling, v1.Pending),
Entry("Time between running and failed", 1.0, v1.Running, v1.Failed),
)
})

Context("Time since Create/Delete calculations", func() {
table.DescribeTable("time diff calculations", func(expectedVal float64, curPhase v1.VirtualMachineInstancePhase, oldPhase v1.VirtualMachineInstancePhase, creation bool) {
DescribeTable("time diff calculations", func(expectedVal float64, curPhase v1.VirtualMachineInstancePhase, oldPhase v1.VirtualMachineInstancePhase, creation bool) {
var oldVMI *v1.VirtualMachineInstance

vmi := createVMISForPhaseTransitionTime(curPhase, oldPhase, expectedVal*1000, true)
Expand All @@ -80,11 +79,11 @@ var _ = Describe("VMI phase transition time histogram", func() {
// 1x expectedVal because the measurement is creationtime -> oldphase -> newphase
Expect(diffSeconds).To(Equal(2 * expectedVal))
},
table.Entry("Time between creation and pending", 3.0, v1.Pending, v1.VmPhaseUnset, true),
table.Entry("Time between creation and running", 5.0, v1.Running, v1.Scheduled, true),
table.Entry("Time between creation and scheduling using fraction of a second", .5, v1.Scheduling, v1.Scheduled, true),
table.Entry("Time spent deleting a VMI that exited in a failed state", 5.0, v1.Failed, v1.Running, false),
table.Entry("Time spent deleting a VMI that exited in a succeeded state", 5.0, v1.Succeeded, v1.Running, false),
Entry("Time between creation and pending", 3.0, v1.Pending, v1.VmPhaseUnset, true),
Entry("Time between creation and running", 5.0, v1.Running, v1.Scheduled, true),
Entry("Time between creation and scheduling using fraction of a second", .5, v1.Scheduling, v1.Scheduled, true),
Entry("Time spent deleting a VMI that exited in a failed state", 5.0, v1.Failed, v1.Running, false),
Entry("Time spent deleting a VMI that exited in a succeeded state", 5.0, v1.Succeeded, v1.Running, false),
)
})
})
Expand Down
15 changes: 7 additions & 8 deletions pkg/monitoring/vmistats/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package vmistats

import (
"github.com/onsi/ginkgo/extensions/table"
"github.com/prometheus/client_golang/prometheus"
io_prometheus_client "github.com/prometheus/client_model/go"
k8sv1 "k8s.io/api/core/v1"
Expand All @@ -41,7 +40,7 @@ var _ = Describe("VMI Stats Collector", func() {
Context("VMI Eviction blocker", func() {

liveMigrateEvictPolicy := k6tv1.EvictionStrategyLiveMigrate
table.DescribeTable("Add eviction alert metrics", func(evictionPolicy *k6tv1.EvictionStrategy, migrateCondStatus k8sv1.ConditionStatus, expectedVal float64) {
DescribeTable("Add eviction alert metrics", func(evictionPolicy *k6tv1.EvictionStrategy, migrateCondStatus k8sv1.ConditionStatus, expectedVal float64) {
vmiInformer, _ := testutils.NewFakeInformerFor(&k6tv1.VirtualMachineInstance{})
clusterConfig, _, _ := testutils.NewFakeClusterConfigUsingKV(&k6tv1.KubeVirt{})
collector := &VMICollector{
Expand All @@ -63,12 +62,12 @@ var _ = Describe("VMI Stats Collector", func() {
Expect(result.Desc().String()).To(ContainSubstring("kubevirt_vmi_non_evictable"))
Expect(dto.Gauge.GetValue()).To(BeEquivalentTo(expectedVal))
},
table.Entry("VMI Eviction policy set to LiveMigration and vm is not migratable", &liveMigrateEvictPolicy, k8sv1.ConditionFalse, 1.0),
table.Entry("VMI Eviction policy set to LiveMigration and vm migratable status is not known", &liveMigrateEvictPolicy, k8sv1.ConditionUnknown, 1.0),
table.Entry("VMI Eviction policy set to LiveMigration and vm is migratable", &liveMigrateEvictPolicy, k8sv1.ConditionTrue, 0.0),
table.Entry("VMI Eviction policy is not set and vm is not migratable", nil, k8sv1.ConditionFalse, 0.0),
table.Entry("VMI Eviction policy is not set and vm is migratable", nil, k8sv1.ConditionTrue, 0.0),
table.Entry("VMI Eviction policy is not set and vm migratable status is not known", nil, k8sv1.ConditionUnknown, 0.0),
Entry("VMI Eviction policy set to LiveMigration and vm is not migratable", &liveMigrateEvictPolicy, k8sv1.ConditionFalse, 1.0),
Entry("VMI Eviction policy set to LiveMigration and vm migratable status is not known", &liveMigrateEvictPolicy, k8sv1.ConditionUnknown, 1.0),
Entry("VMI Eviction policy set to LiveMigration and vm is migratable", &liveMigrateEvictPolicy, k8sv1.ConditionTrue, 0.0),
Entry("VMI Eviction policy is not set and vm is not migratable", nil, k8sv1.ConditionFalse, 0.0),
Entry("VMI Eviction policy is not set and vm is migratable", nil, k8sv1.ConditionTrue, 0.0),
Entry("VMI Eviction policy is not set and vm migratable status is not known", nil, k8sv1.ConditionUnknown, 0.0),
)
})
})
Expand Down
Loading

0 comments on commit 764465f

Please sign in to comment.