...

Source file src/github.com/linkerd/linkerd2/testutil/install.go

Documentation: github.com/linkerd/linkerd2/testutil

     1  package testutil
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  	"testing"
     7  )
     8  
     9  // TestResourcesPostInstall tests resources post control plane installation
    10  func TestResourcesPostInstall(namespace string, services []Service, deploys map[string]DeploySpec, h *TestHelper, t *testing.T) {
    11  	ctx := context.Background()
    12  	// Tests Namespace
    13  	err := h.CheckIfNamespaceExists(ctx, namespace)
    14  	if err != nil {
    15  		AnnotatedFatalf(t, "received unexpected output",
    16  			"received unexpected output\n%s", err)
    17  	}
    18  
    19  	// Tests Services
    20  	for _, svc := range services {
    21  		if err := h.CheckService(ctx, svc.Namespace, svc.Name); err != nil {
    22  			AnnotatedErrorf(t, fmt.Sprintf("error validating service [%s/%s]", svc.Namespace, svc.Name),
    23  				"error validating service [%s/%s]:\n%s", svc.Namespace, svc.Name, err)
    24  		}
    25  	}
    26  
    27  	// Tests Pods and Deployments
    28  	for deploy, spec := range deploys {
    29  		if err := h.CheckPods(ctx, spec.Namespace, deploy, spec.Replicas); err != nil {
    30  			//nolint:errorlint
    31  			if rce, ok := err.(*RestartCountError); ok {
    32  				AnnotatedWarn(t, "CheckPods timed-out", rce)
    33  			} else {
    34  				AnnotatedFatal(t, "CheckPods timed-out", err)
    35  			}
    36  		}
    37  	}
    38  }
    39  
    40  // ExerciseTestAppEndpoint tests if the emojivoto service is reachable
    41  func ExerciseTestAppEndpoint(endpoint, namespace string, h *TestHelper) error {
    42  	testAppURL, err := h.URLFor(context.Background(), namespace, "web", 8080)
    43  	if err != nil {
    44  		return err
    45  	}
    46  	for i := 0; i < 30; i++ {
    47  		_, err := h.HTTPGetURL(testAppURL + endpoint)
    48  		if err != nil {
    49  			return err
    50  		}
    51  	}
    52  	return nil
    53  }
    54  

View as plain text