Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
Upgrade and fix e2e tests (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaferraro authored Oct 1, 2020
1 parent 202153b commit 99562cd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/kind-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ jobs:
kamel install --registry registry:5000 --registry-insecure --global -n camel-system
- name: Install Knative
env:
SERVING_VERSION: v0.17.2
KOURIER_VERSION: v0.17.1
EVENTING_VERSION: v0.17.3
SERVING_VERSION: v0.18.0
KOURIER_VERSION: v0.18.0
EVENTING_VERSION: v0.18.0
run: |
# Prerequisites
sudo pip install yq
# Serving
kubectl apply --filename https://github.com/knative/serving/releases/download/$SERVING_VERSION/serving-crds.yaml
sleep 5
curl -L -s https://github.com/knative/serving/releases/download/$SERVING_VERSION/serving-core.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | kubectl apply -f -
curl -L -s https://github.com/knative/serving/releases/download/$SERVING_VERSION/serving-core.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | kubectl apply -f -
sleep 60
kubectl get pod -n knative-serving
Expand All @@ -126,11 +126,11 @@ jobs:
# Eventing
kubectl apply --filename https://github.com/knative/eventing/releases/download/$EVENTING_VERSION/eventing-crds.yaml
sleep 5
curl -L -s https://github.com/knative/eventing/releases/download/$EVENTING_VERSION/eventing-core.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | kubectl apply -f -
curl -L -s https://github.com/knative/eventing/releases/download/$EVENTING_VERSION/eventing-core.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | kubectl apply -f -
# Eventing channels
curl -L -s https://github.com/knative/eventing/releases/download/$EVENTING_VERSION/in-memory-channel.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | kubectl apply -f -
curl -L -s https://github.com/knative/eventing/releases/download/$EVENTING_VERSION/in-memory-channel.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | kubectl apply -f -
# Eventing broker
curl -L -s https://github.com/knative/eventing/releases/download/$EVENTING_VERSION/mt-channel-broker.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | kubectl apply -f -
curl -L -s https://github.com/knative/eventing/releases/download/$EVENTING_VERSION/mt-channel-broker.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | kubectl apply -f -
sleep 30
kubectl get pod -n knative-eventing
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ cover.out
bin/
*.swp
.history
.envrc
28 changes: 16 additions & 12 deletions test/e2e/camel_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
package e2e

import (
"context"
"os"
"strings"
"testing"
Expand All @@ -45,19 +46,22 @@ func TestCamelSource(t *testing.T) {
body = "Hello, world!"
)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

client := testlib.Setup(t, true)
defer testlib.TearDown(client)

t.Logf("Creating event record")
eventTracker, _ := recordevents.StartEventRecordOrFail(client, loggerPodName)
eventTracker, _ := recordevents.StartEventRecordOrFail(ctx, client, loggerPodName)

camelClient := getCamelKClient(client)

t.Logf("Creating Camel K IntegrationPlatform")
createCamelPlatformOrFail(client, camelClient, camelSourceName)
createCamelPlatformOrFail(ctx, client, camelClient, camelSourceName)

t.Logf("Creating CamelSource")
createCamelSourceOrFail(client, &v1alpha1.CamelSource{
createCamelSourceOrFail(ctx, client, &v1alpha1.CamelSource{
ObjectMeta: meta.ObjectMeta{
Name: camelSourceName,
},
Expand Down Expand Up @@ -89,12 +93,12 @@ func TestCamelSource(t *testing.T) {
})

t.Logf("Waiting for all resources ready")
client.WaitForAllTestResourcesReadyOrFail()
client.WaitForAllTestResourcesReadyOrFail(ctx)

t.Logf("Sleeping for 3s to let the timer tick at least once")
time.Sleep(3 * time.Second)

pods, err := client.Kube.Kube.CoreV1().Pods(client.Namespace).List(meta.ListOptions{
pods, err := client.Kube.Kube.CoreV1().Pods(client.Namespace).List(ctx, meta.ListOptions{
LabelSelector: "camel.apache.org/integration",
})
if err != nil {
Expand All @@ -103,37 +107,37 @@ func TestCamelSource(t *testing.T) {
if len(pods.Items) == 0 {
t.Fatalf("no integration pod found")
}
printPodLogs(t, client, pods.Items[0].Name, "integration")
printPodLogs(ctx, t, client, pods.Items[0].Name, "integration")

eventTracker.AssertAtLeast(1, recordevents.MatchEvent(test.AllOf(
test.HasData([]byte(body))),
test.HasType("org.apache.camel.event"),
))
}

func printPodLogs(t *testing.T, c *testlib.Client, podName, containerName string) {
logs, err := c.Kube.PodLogs(podName, containerName, c.Namespace)
func printPodLogs(ctx context.Context, t *testing.T, c *testlib.Client, podName, containerName string) {
logs, err := c.Kube.PodLogs(ctx, podName, containerName, c.Namespace)
if err == nil {
t.Log(string(logs))
}
t.Logf("End of pod %s logs", podName)
}

func createCamelSourceOrFail(c *testlib.Client, camelSource *v1alpha1.CamelSource) {
func createCamelSourceOrFail(ctx context.Context, c *testlib.Client, camelSource *v1alpha1.CamelSource) {
camelSourceClientSet, err := camelsourceclient.NewForConfig(c.Config)
if err != nil {
c.T.Fatalf("Failed to create CamelSource client: %v", err)
}

cSources := camelSourceClientSet.SourcesV1alpha1().CamelSources(c.Namespace)
if createdCamelSource, err := cSources.Create(camelSource); err != nil {
if createdCamelSource, err := cSources.Create(ctx, camelSource, meta.CreateOptions{}); err != nil {
c.T.Fatalf("Failed to create CamelSource %q: %v", camelSource.Name, err)
} else {
c.Tracker.AddObj(createdCamelSource)
}
}

func createCamelPlatformOrFail(c *testlib.Client, camelClient camelclientset.Interface, camelSourceName string) {
func createCamelPlatformOrFail(ctx context.Context, c *testlib.Client, camelClient camelclientset.Interface, camelSourceName string) {
platform := camelv1.IntegrationPlatform{
ObjectMeta: meta.ObjectMeta{
Name: "camel-k",
Expand All @@ -150,7 +154,7 @@ func createCamelPlatformOrFail(c *testlib.Client, camelClient camelclientset.Int
},
}

if _, err := camelClient.CamelV1().IntegrationPlatforms(c.Namespace).Create(&platform); err != nil {
if _, err := camelClient.CamelV1().IntegrationPlatforms(c.Namespace).Create(ctx, &platform, meta.CreateOptions{}); err != nil {
c.T.Fatalf("Failed to create IntegrationPlatform for CamelSource %q: %v", camelSourceName, err)
}
}
Expand Down

0 comments on commit 99562cd

Please sign in to comment.