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 6f05b5d
Showing 1 changed file with 34 additions and 62 deletions.
96 changes: 34 additions & 62 deletions test/e2e/test_broker_pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,20 @@ 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)

u := createBrokerWithPubSubChannel(t,
client,
[]v1.EnvVar{{
Name: "TARGET",
Value: "falldown",
}},
brokerName,
dummyTriggerName,
kserviceName,
respTriggerName,
targetName,
)
// 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, targetName)

// Just to make sure all resources are ready.
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -106,28 +98,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)

u := createBrokerWithPubSubChannel(t,
client,
[]v1.EnvVar{{
Name: "TARGET",
Value: "falldown",
}},
brokerName,
dummyTriggerName,
kserviceName,
respTriggerName,
targetName,
)
// 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, targetName)

var url apis.URL = apis.URL(u)
// Just to make sure all resources are ready.
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -173,30 +158,21 @@ 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)

u := createBrokerWithPubSubChannel(t,
client,
[]v1.EnvVar{{
Name: "SUBJECT",
Value: fileName,
}, {
Name: "TIME",
Value: "120",
}},
brokerName,
dummyTriggerName,
kserviceName,
respTriggerName,
targetName,
)
t.Logf("Created broker")
// 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, targetName)

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

func createBrokerWithPubSubChannel(t *testing.T,
client *lib.Client,
targetJobEnvVars []v1.EnvVar,
brokerName, dummyTriggerName, kserviceName, respTriggerName, targetName string,
) url.URL {
func createBrokerWithPubSubChannel(t *testing.T, client *lib.Client, 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 +221,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 6f05b5d

Please sign in to comment.