tests: observe pod events

Signed-off-by: Paulo Pires <pjpires@gmail.com>
This commit is contained in:
Paulo Pires
2018-12-15 11:01:39 +00:00
parent 6a7fa9f6f1
commit c108962821
2 changed files with 58 additions and 6 deletions

View File

@@ -10,6 +10,8 @@ import (
"k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
"github.com/virtual-kubelet/virtual-kubelet/vkubelet"
)
const (
@@ -210,6 +212,11 @@ func TestCreatePodWithOptionalInexistentSecrets(t *testing.T) {
t.Fatal(err)
}
// Wait for an event concerning the missing secret to be reported on the pod.
if err := f.WaitUntilPodEventWithReason(pod, vkubelet.ReasonOptionalSecretNotFound); err != nil {
t.Fatal(err)
}
// Check that the pod is known to the provider.
stats, err := f.GetStatsSummary()
if err != nil {
@@ -236,9 +243,10 @@ func TestCreatePodWithMandatoryInexistentSecrets(t *testing.T) {
}
}()
// Wait for a small period so we can later assert the pod is not running.
// TODO (@pires) Wait for event to be reported.
time.Sleep(5 * time.Second)
// Wait for an event concerning the missing secret to be reported on the pod.
if err := f.WaitUntilPodEventWithReason(pod, vkubelet.ReasonMandatorySecretNotFound); err != nil {
t.Fatal(err)
}
// Check that the pod is NOT known to the provider.
stats, err := f.GetStatsSummary()
@@ -271,6 +279,11 @@ func TestCreatePodWithOptionalInexistentConfigMap(t *testing.T) {
t.Fatal(err)
}
// Wait for an event concerning the missing config map to be reported on the pod.
if err := f.WaitUntilPodEventWithReason(pod, vkubelet.ReasonOptionalConfigMapNotFound); err != nil {
t.Fatal(err)
}
// Check that the pod is known to the provider.
stats, err := f.GetStatsSummary()
if err != nil {
@@ -297,9 +310,10 @@ func TestCreatePodWithMandatoryInexistentConfigMap(t *testing.T) {
}
}()
// Wait for a small period so we can later assert the pod is not running.
// TODO (@pires) Wait for event to be reported.
time.Sleep(5 * time.Second)
// Wait for an event concerning the missing config map to be reported on the pod.
if err := f.WaitUntilPodEventWithReason(pod, vkubelet.ReasonMandatoryConfigMapNotFound); err != nil {
t.Fatal(err)
}
// Check that the pod is NOT known to the provider.
stats, err := f.GetStatsSummary()