Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance assertions in test/e2e/windows #110303

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions test/e2e/windows/density.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ func runDensityBatchTest(f *framework.Framework, testArg densityTest) (time.Dura

for name, create := range createTimes {
watch, ok := watchTimes[name]
framework.ExpectEqual(ok, true)
if !ok {
framework.Failf("pod %s failed to be observed by the watch", name)
}

e2eLags = append(e2eLags,
e2emetrics.PodLatencyData{Name: name, Latency: watch.Time.Sub(create.Time)})
Expand Down Expand Up @@ -201,12 +203,16 @@ func newInformerWatchPod(f *framework.Framework, mutex *sync.Mutex, watchTimes m
cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
p, ok := obj.(*v1.Pod)
framework.ExpectEqual(ok, true)
if !ok {
framework.Failf("expected Pod, got %T", obj)
}
go checkPodRunning(p)
},
UpdateFunc: func(oldObj, newObj interface{}) {
p, ok := newObj.(*v1.Pod)
framework.ExpectEqual(ok, true)
if !ok {
framework.Failf("expected Pod, got %T", newObj)
}
go checkPodRunning(p)
},
},
Expand Down
9 changes: 5 additions & 4 deletions test/e2e/windows/host_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package windows
import (
"context"
"fmt"
"github.com/onsi/gomega"
"strings"
"time"

Expand Down Expand Up @@ -568,10 +569,10 @@ var _ = SIGDescribe("[Feature:WindowsHostProcessContainers] [MinimumKubeletVersi
// Note: This test performs relative comparisons to ensure metrics values were logged and does not validate specific values.
// This done so the test can be run in parallel with other tests which may start HostProcess containers on the same node.
ginkgo.By("Ensuring metrics were updated")
framework.ExpectEqual(beforeMetrics.StartedContainersCount < afterMetrics.StartedContainersCount, true, "Count of started HostProcess containers should increase")
framework.ExpectEqual(beforeMetrics.StartedContainersErrorCount < afterMetrics.StartedContainersErrorCount, true, "Count of started HostProcess errors containers should increase")
framework.ExpectEqual(beforeMetrics.StartedInitContainersCount < afterMetrics.StartedInitContainersCount, true, "Count of started HostProcess init containers should increase")
framework.ExpectEqual(beforeMetrics.StartedInitContainersErrorCount < afterMetrics.StartedInitContainersErrorCount, true, "Count of started HostProcess errors init containers should increase")
gomega.Expect(beforeMetrics.StartedContainersCount).To(gomega.BeNumerically("<", afterMetrics.StartedContainersCount), "Count of started HostProcess containers should increase")
gomega.Expect(beforeMetrics.StartedContainersErrorCount).To(gomega.BeNumerically("<", afterMetrics.StartedContainersErrorCount), "Count of started HostProcess errors containers should increase")
gomega.Expect(beforeMetrics.StartedInitContainersCount).To(gomega.BeNumerically("<", afterMetrics.StartedInitContainersCount), "Count of started HostProcess init containers should increase")
gomega.Expect(beforeMetrics.StartedInitContainersErrorCount).To(gomega.BeNumerically("<", afterMetrics.StartedInitContainersErrorCount), "Count of started HostProcess errors init containers should increase")
})

})
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/windows/kubelet_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ var _ = SIGDescribe("[Feature:Windows] Kubelet-Stats", func() {
framework.Logf("Using node: %v", targetNode.Name)

ginkgo.By("Getting bootid")
framework.ExpectEqual(len(targetNode.Status.NodeInfo.BootID) != 0, true, "Should find bootId in kubelet stats")
if len(targetNode.Status.NodeInfo.BootID) == 0 {
framework.Failf("expected bootId in kubelet stats, got none")
}
})
})

Expand Down