Skip to content

Commit

Permalink
Adding tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <[email protected]>
  • Loading branch information
rubenvp8510 committed Feb 27, 2020
1 parent 55d5042 commit d60c42f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/e2e/sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/wait"

Expand Down Expand Up @@ -99,6 +100,42 @@ func (suite *SidecarTestSuite) TestSidecar() {
return len(resp.Data) > 0, nil
})
require.NoError(t, err, "Failed waiting for expected content")

/* Testing other instance */

otherJaegerInstanceName := "agent-as-sidecar2"
j2 := getJaegerAgentAsSidecarDefinition(otherJaegerInstanceName, namespace)
err = fw.Client.Create(goctx.TODO(), j2, cleanupOptions)
err = e2eutil.WaitForDeployment(t, fw.KubeClient, namespace, jaegerInstanceName, 1, retryInterval, timeout)
require.NoError(t, err, "Error waiting for Jaeger instance deployment")

persisted := &appsv1.Deployment{}
err = fw.Client.Get(goctx.TODO(), types.NamespacedName{
Name: "vertx-create-span-sidecar",
Namespace: namespace,
}, persisted)
require.NoError(t, err, "Error getting jaeger instance")
require.Equal(t, "agent-as-sidecar", persisted.Labels[inject.Label])

fw.Client.Delete(goctx.TODO(), j)

url, httpClient := getQueryURLAndHTTPClient(otherJaegerInstanceName, "%s/api/traces?service=order", true)
req, err := http.NewRequest(http.MethodGet, url, nil)

err = wait.Poll(retryInterval, timeout, func() (done bool, err error) {
res, err := httpClient.Do(req)
require.NoError(t, err)

body, err := ioutil.ReadAll(res.Body)
require.NoError(t, err)

resp := &resp{}
err = json.Unmarshal(body, &resp)
require.NoError(t, err)

return len(resp.Data) > 0, nil
})
require.NoError(t, err, "Failed waiting for expected content")
}

func getVertxDefinition(annotations map[string]string) *appsv1.Deployment {
Expand Down

0 comments on commit d60c42f

Please sign in to comment.