Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/e2e/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strconv"
"strings"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -267,7 +268,7 @@ func makePrometheusQuery(address, query, token string) ([]Result, error) {
// InsecureSkipVerify is required to avoid errors due to bad certificate
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
client := &http.Client{Transport: tr, Timeout: 15 * time.Second}
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("error making GET request: %w", err)
Expand Down
27 changes: 4 additions & 23 deletions test/e2e/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,28 +979,11 @@ func (tc *testContext) waitUntilDeploymentScaled(name string) error {
return false, nil
})
if err != nil {
events, _ := tc.getPodEvents(name)
return fmt.Errorf("error waiting for deployment %v to scale: %v: %w", deployment, events, err)
return fmt.Errorf("error waiting for deployment %s to scale: %w", deployment.Name, err)
}
return nil
}

// getPodEvents gets all events for any pod with the input in its name. Used for debugging purposes
func (tc *testContext) getPodEvents(name string) ([]v1.Event, error) {
eventList, err := tc.client.K8s.CoreV1().Events(tc.workloadNamespace).List(context.TODO(), metav1.ListOptions{
FieldSelector: "involvedObject.kind=Pod"})
if err != nil {
return []v1.Event{}, err
}
var podEvents []v1.Event
for _, event := range eventList.Items {
if strings.Contains(event.InvolvedObject.Name, name) {
podEvents = append(podEvents, event)
}
}
return podEvents, nil
}

// createLinuxCurlerJob creates a linux job to curl a specific endpoint. curl must be present in the container image.
func (tc *testContext) createLinuxCurlerJob(jobSuffix, endpoint string, continuous bool) (*batchv1.Job, error) {
// Retries a failed curl attempt once to avoid flakes
Expand Down Expand Up @@ -1125,7 +1108,7 @@ func (tc *testContext) waitUntilJobSucceeds(name string) (string, error) {
for i := 0; i < 60; i++ {
job, err = tc.client.K8s.BatchV1().Jobs(tc.workloadNamespace).Get(context.TODO(), name, metav1.GetOptions{})
if err != nil {
return "", err
return "", fmt.Errorf("error getting job with name %s: %w", name, err)
}
if !slices.ContainsFunc(job.Status.Conditions, func(condition batchv1.JobCondition) bool {
return condition.Type == batchv1.JobComplete && condition.Status == v1.ConditionTrue
Expand All @@ -1143,17 +1126,15 @@ func (tc *testContext) waitUntilJobSucceeds(name string) (string, error) {
return condition.Type == batchv1.JobSuccessCriteriaMet && condition.Status == v1.ConditionTrue
}) {
// Job did not succeed, return error
events, _ := tc.getPodEvents(name)
return logs, fmt.Errorf("job %v failed: %v", job, events)
return logs, fmt.Errorf("job %s failed", name)
}
return logs, nil
}
_, err = tc.gatherPodLogs(labelSelector, true)
if err != nil {
log.Printf("Unable to get logs associated with pod %s: %v", labelSelector, err)
}
events, _ := tc.getPodEvents(name)
return "", fmt.Errorf("job %v timed out: %v", job, events)
return "", fmt.Errorf("job %s timed out", name)
}

// gatherPodLogs writes the logs associated with the label selector of a given pod job or deployment to the Artifacts
Expand Down