github.com/solo-io/service-mesh-hub@v0.9.2/test/e2e/istio/istio_e2e_test.go (about)

     1  package istio_test
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  	"os/exec"
     7  	"time"
     8  
     9  	"github.com/solo-io/service-mesh-hub/test/extensions"
    10  
    11  	v1 "github.com/solo-io/skv2/pkg/api/core.skv2.solo.io/v1"
    12  
    13  	. "github.com/onsi/ginkgo"
    14  	. "github.com/onsi/gomega"
    15  	"github.com/solo-io/service-mesh-hub/test/e2e"
    16  	"sigs.k8s.io/controller-runtime/pkg/client"
    17  )
    18  
    19  // Shared test vars
    20  var (
    21  	BookinfoNamespace = "bookinfo"
    22  
    23  	mgmtClusterName   = "mgmt-cluster"
    24  	remoteClusterName = "remote-cluster"
    25  
    26  	masterMesh = &v1.ObjectRef{
    27  		Name:      "istiod-istio-system-mgmt-cluster",
    28  		Namespace: "service-mesh-hub",
    29  	}
    30  
    31  	remoteMesh = &v1.ObjectRef{
    32  		Name:      "istiod-istio-system-remote-cluster",
    33  		Namespace: "service-mesh-hub",
    34  	}
    35  
    36  	// Initialize in BeforeSuite
    37  	dynamicClient client.Client
    38  
    39  	curlReviews = func() string {
    40  		return curlFromProductpage("http://reviews:9080/reviews/1")
    41  	}
    42  
    43  	curlHelloServer = func() string {
    44  		return curlFromProductpage(fmt.Sprintf("http://%v:%v/", extensions.HelloServerHostname, extensions.HelloServerPort))
    45  	}
    46  
    47  	curlRemoteReviews = func() string {
    48  		return curlFromProductpage(fmt.Sprintf("http://reviews.%v.svc.%v.global:9080/reviews/1", BookinfoNamespace, remoteClusterName))
    49  	}
    50  
    51  	curlRatings = func() string {
    52  		return curlFromProductpage("http://ratings:9080/ratings/1")
    53  	}
    54  
    55  	curlFromProductpage = func(url string) string {
    56  		env := e2e.GetEnv()
    57  		ctx, cancel := context.WithTimeout(context.Background(), time.Minute/3)
    58  		defer cancel()
    59  		out := env.Management.GetPod(ctx, BookinfoNamespace, "productpage").Curl(ctx, url, "-v")
    60  		GinkgoWriter.Write([]byte(out))
    61  		return out
    62  	}
    63  
    64  	curlGateway = func(hostname, path, body, method string) string {
    65  		out, err := exec.Command("curl", "--connect-timeout", "1", "--max-time", "5", "-H", hostname, "http://localhost:32000"+path, "-v", "-d", body, "-X", method).CombinedOutput()
    66  		Expect(err).NotTo(HaveOccurred())
    67  
    68  		GinkgoWriter.Write(out)
    69  
    70  		return string(out)
    71  	}
    72  )