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

Commit

Permalink
resolving test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Lopez committed Feb 21, 2020
1 parent 85afea7 commit 760c7c6
Showing 1 changed file with 30 additions and 47 deletions.
77 changes: 30 additions & 47 deletions test/e2e/test_broker_pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,21 @@ Note: the number denotes the sequence of the event that flows in this test case.
*/

func BrokerWithPubSubChannelTestImpl(t *testing.T) {
brokerName := helpers.AppendRandomString("pubsub")
dummyTriggerName := "dummy-broker-" + brokerName
respTriggerName := "resp-broker-" + brokerName
kserviceName := helpers.AppendRandomString("kservice")
senderName := helpers.AppendRandomString("sender")
targetName := helpers.AppendRandomString("target")

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

// Create a target Job to receive the events.
job := resources.TargetJob(targetName, []v1.EnvVar{{
Name: "TARGET",
Value: "falldown",
}})
client.CreateJobOrFail(job, lib.WithServiceForJob(targetName))

u := createBrokerWithPubSubChannel(t,
client,
[]v1.EnvVar{{
Name: "TARGET",
Value: "falldown",
}},
brokerName,
dummyTriggerName,
kserviceName,
respTriggerName,
targetName,
)

Expand Down Expand Up @@ -106,26 +101,21 @@ func PubSubSourceBrokerWithPubSubChannelTestImpl(t *testing.T) {
topicName, deleteTopic := lib.MakeTopicOrDie(t)
defer deleteTopic()

brokerName := helpers.AppendRandomString("pubsub")
dummyTriggerName := "dummy-broker-" + brokerName
psName := helpers.AppendRandomString(topicName + "-pubsub")
respTriggerName := "resp-broker-" + brokerName
kserviceName := helpers.AppendRandomString("kservice")
targetName := helpers.AppendRandomString(topicName + "-target")

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

// Create a target Job to receive the events.
job := resources.TargetJob(targetName, []v1.EnvVar{{
Name: "TARGET",
Value: "falldown",
}})
client.CreateJobOrFail(job, lib.WithServiceForJob(targetName))

u := createBrokerWithPubSubChannel(t,
client,
[]v1.EnvVar{{
Name: "TARGET",
Value: "falldown",
}},
brokerName,
dummyTriggerName,
kserviceName,
respTriggerName,
targetName,
)
var url apis.URL = apis.URL(u)
Expand Down Expand Up @@ -173,30 +163,24 @@ func StorageSourceBrokerWithPubSubChannelTestImpl(t *testing.T) {
targetName := helpers.AppendRandomString(bucketName + "-target")
fileName := helpers.AppendRandomString("test-file-for-storage")

brokerName := helpers.AppendRandomString("pubsub")
dummyTriggerName := "dummy-broker-" + brokerName
respTriggerName := "resp-broker-" + brokerName
kserviceName := helpers.AppendRandomString("kservice")

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

// Create a target StorageJob to receive the events.
job := resources.StorageTargetJob(targetName, []v1.EnvVar{{
Name: "SUBJECT",
Value: fileName,
}, {
Name: "TIME",
Value: "120",
}})
client.CreateJobOrFail(job, lib.WithServiceForJob(targetName))

u := createBrokerWithPubSubChannel(t,
client,
[]v1.EnvVar{{
Name: "SUBJECT",
Value: fileName,
}, {
Name: "TIME",
Value: "120",
}},
brokerName,
dummyTriggerName,
kserviceName,
respTriggerName,
targetName,
)
t.Logf("Created broker")

var url apis.URL = apis.URL(u)
// Just to make sure all resources are ready.
time.Sleep(5 * time.Second)
Expand All @@ -222,9 +206,12 @@ func StorageSourceBrokerWithPubSubChannelTestImpl(t *testing.T) {

func createBrokerWithPubSubChannel(t *testing.T,
client *lib.Client,
targetJobEnvVars []v1.EnvVar,
brokerName, dummyTriggerName, kserviceName, respTriggerName, targetName string,
targetName string,
) url.URL {
brokerName := helpers.AppendRandomString("pubsub")
dummyTriggerName := "dummy-broker-" + brokerName
respTriggerName := "resp-broker-" + brokerName
kserviceName := helpers.AppendRandomString("kservice")
// Create a new Broker.
// TODO(chizhg): maybe we don't need to create these RBAC resources as they will now be automatically created?
client.Core.CreateRBACResourcesForBrokers()
Expand All @@ -245,10 +232,6 @@ func createBrokerWithPubSubChannel(t *testing.T,
eventingtestresources.WithSubscriberKServiceRefForTrigger(kserviceName),
)

// Create a target Job to receive the events.
job := resources.StorageTargetJob(targetName, targetJobEnvVars)
client.CreateJobOrFail(job, lib.WithServiceForJob(targetName))

// Create a Trigger with the target Service subscriber.
client.Core.CreateTriggerOrFail(
respTriggerName,
Expand Down

0 comments on commit 760c7c6

Please sign in to comment.