Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
lionelvillard committed Jun 10, 2020
1 parent 44e4d8d commit 7f5fae6
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 41 deletions.
77 changes: 77 additions & 0 deletions config/pre-install/v0.16.0/pingsource.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion config/pre-install/v0.16.0/storage-version-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion pkg/reconciler/pingsource/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import (
"knative.dev/pkg/tracker"

"knative.dev/eventing/pkg/apis/sources/v1alpha2"
"knative.dev/pkg/client/injection/kube/informers/rbac/v1/rolebinding"
pingsourceinformer "knative.dev/eventing/pkg/client/injection/informers/sources/v1alpha2/pingsource"
pingsourcereconciler "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1alpha2/pingsource"
kubeclient "knative.dev/pkg/client/injection/kube/client"
deploymentinformer "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment"
"knative.dev/pkg/client/injection/kube/informers/core/v1/serviceaccount"
"knative.dev/pkg/client/injection/kube/informers/rbac/v1/rolebinding"
)

// envConfig will be used to extract the required environment variables using
Expand Down
10 changes: 10 additions & 0 deletions pkg/reconciler/pingsource/pingsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
39 changes: 0 additions & 39 deletions test/e2e/source_ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,48 +33,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 * * * *"

recordEventPodName = "e2e-ping-source-logger-pod-v1alpha1"
)

client := setup(t, true)
defer tearDown(client)

// create event logger pod and service
eventTracker, _ := recordevents.StartEventRecordOrFail(client, recordEventPodName)
defer eventTracker.Cleanup()

// create cron job source
data := fmt.Sprintf(`{"msg":"TestPingSource %s"}`, uuid.NewUUID())
source := eventingtesting.NewPingSourceV1Alpha1(
sourceName,
client.Namespace,
eventingtesting.WithPingSourceSpec(sourcesv1alpha1.PingSourceSpec{
Schedule: schedule,
Data: data,
Sink: &duckv1.Destination{Ref: resources.KnativeRefForService(recordEventPodName, client.Namespace)},
}),
)
client.CreatePingSourceV1Alpha1OrFail(source)

// wait for all test resources to be ready
client.WaitForAllTestResourcesReadyOrFail()

eventTracker.AssertExact(1, recordevents.MatchEvent(
HasSource(sourcesv1alpha1.PingSourceSource(client.Namespace, sourceName)),
HasData([]byte(data)),
))
}

func TestPingSourceV1Alpha2(t *testing.T) {
const (
sourceName = "e2e-ping-source"
Expand Down

0 comments on commit 7f5fae6

Please sign in to comment.