From 72beb86944ea3c499d668653ec42c6ff306133a1 Mon Sep 17 00:00:00 2001 From: Lionel Villard Date: Thu, 4 Jun 2020 13:58:06 -0400 Subject: [PATCH] fix e2e --- config/pre-install/v0.16.0/pingsource.yaml | 77 +++++++++++++++++++ .../v0.16.0/storage-version-migration.yaml | 2 +- pkg/reconciler/pingsource/pingsource.go | 10 +++ test/e2e/source_ping_test.go | 45 ----------- 4 files changed, 88 insertions(+), 46 deletions(-) create mode 100644 config/pre-install/v0.16.0/pingsource.yaml diff --git a/config/pre-install/v0.16.0/pingsource.yaml b/config/pre-install/v0.16.0/pingsource.yaml new file mode 100644 index 00000000000..cd7e086b23c --- /dev/null +++ b/config/pre-install/v0.16.0/pingsource.yaml @@ -0,0 +1,77 @@ +# Copyright 2020 The Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + labels: + eventing.knative.dev/release: devel + eventing.knative.dev/source: "true" + duck.knative.dev/source: "true" + knative.dev/crd-install: "true" + annotations: + # TODO add schemas and descriptions + registry.knative.dev/eventTypes: | + [ + { "type": "dev.knative.sources.ping" } + ] + name: pingsources.sources.knative.dev +spec: + group: sources.knative.dev + names: + categories: + - all + - knative + - eventing + - sources + kind: PingSource + plural: pingsources + scope: Namespaced + subresources: + status: {} + preserveUnknownFields: false + validation: + openAPIV3Schema: + type: object + # this is a work around so we don't need to flesh out the + # schema for each version at this time + # + # see issue: https://github.com/knative/serving/issues/912 + x-kubernetes-preserve-unknown-fields: true + conversion: + strategy: Webhook + webhookClientConfig: + service: + name: eventing-webhook + namespace: knative-eventing + additionalPrinterColumns: + - name: Ready + type: string + JSONPath: ".status.conditions[?(@.type=='Ready')].status" + - name: Reason + type: string + JSONPath: ".status.conditions[?(@.type=='Ready')].reason" + - name: Sink + type: string + JSONPath: .status.sinkUri + - name: Age + type: date + JSONPath: .metadata.creationTimestamp + versions: + - name: v1alpha1 + served: false + storage: false + - name: v1alpha2 + served: true + storage: true diff --git a/config/pre-install/v0.16.0/storage-version-migration.yaml b/config/pre-install/v0.16.0/storage-version-migration.yaml index 0a7221959e3..09751496e00 100644 --- a/config/pre-install/v0.16.0/storage-version-migration.yaml +++ b/config/pre-install/v0.16.0/storage-version-migration.yaml @@ -37,4 +37,4 @@ spec: image: ko://knative.dev/eventing/vendor/knative.dev/pkg/apiextensions/storageversion/cmd/migrate args: - "brokers.eventing.knative.dev" - - "pingsources.eventing.knative.dev" + - "pingsources.sources.knative.dev" diff --git a/pkg/reconciler/pingsource/pingsource.go b/pkg/reconciler/pingsource/pingsource.go index d3eb1460b27..3c1fd85eca8 100644 --- a/pkg/reconciler/pingsource/pingsource.go +++ b/pkg/reconciler/pingsource/pingsource.go @@ -170,6 +170,16 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, source *v1alpha2.PingSou return err } } else { + if _, err := r.reconcileServiceAccount(ctx, source); err != nil { + logging.FromContext(ctx).Error("Unable to create the receive adapter service account", zap.Error(err)) + return fmt.Errorf("creating receive adapter service account: %v", err) + } + + if _, err := r.reconcileRoleBinding(ctx, source); err != nil { + logging.FromContext(ctx).Error("Unable to create the receive adapter role binding", zap.Error(err)) + return fmt.Errorf("creating receive adapter role binding: %v", err) + } + ra, err := r.createReceiveAdapter(ctx, source, sinkURI) if err != nil { logging.FromContext(ctx).Error("Unable to create the receive adapter", zap.Error(err)) diff --git a/test/e2e/source_ping_test.go b/test/e2e/source_ping_test.go index b873c4377f0..40fc8661470 100644 --- a/test/e2e/source_ping_test.go +++ b/test/e2e/source_ping_test.go @@ -31,54 +31,9 @@ import ( "knative.dev/eventing/test/lib/resources" duckv1 "knative.dev/pkg/apis/duck/v1" - sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" eventingtesting "knative.dev/eventing/pkg/reconciler/testing" ) -func TestPingSourceV1Alpha1(t *testing.T) { - const ( - sourceName = "e2e-ping-source" - // Every 1 minute starting from now - schedule = "*/1 * * * *" - - loggerPodName = "e2e-ping-source-logger-pod-v1alpha1" - ) - - client := setup(t, true) - defer tearDown(client) - - // create event logger pod and service - loggerPod := resources.EventRecordPod(loggerPodName) - client.CreatePodOrFail(loggerPod, lib.WithService(loggerPodName)) - targetTracker, err := client.NewEventInfoStore(loggerPodName, t.Logf) - if err != nil { - t.Fatalf("Pod tracker failed: %v", err) - } - defer targetTracker.Cleanup() - - // create cron job source - data := fmt.Sprintf("TestPingSource %s", uuid.NewUUID()) - source := eventingtesting.NewPingSourceV1Alpha1( - sourceName, - client.Namespace, - eventingtesting.WithPingSourceSpec(sourcesv1alpha1.PingSourceSpec{ - Schedule: schedule, - Data: data, - Sink: &duckv1.Destination{Ref: resources.KnativeRefForService(loggerPodName, client.Namespace)}, - }), - ) - client.CreatePingSourceV1Alpha1OrFail(source) - - // wait for all test resources to be ready - client.WaitForAllTestResourcesReadyOrFail() - - // verify the logger service receives the event and only once - err = targetTracker.WaitMatchSourceData(sourcesv1alpha1.PingSourceSource(client.Namespace, sourceName), data, 1, 1) - if err != nil { - t.Fatalf("Error watching for data %s event in pod %s: %v", data, loggerPodName, err) - } -} - func TestPingSourceV1Alpha2(t *testing.T) { const ( sourceName = "e2e-ping-source"