Skip to content

Commit

Permalink
fix(): tests (#198)
Browse files Browse the repository at this point in the history
* fix(): tests

* fix(): tests

* fix(): tests

* fix(): tests
  • Loading branch information
VaibhavPage authored and magaldima committed Mar 4, 2019
1 parent 224e333 commit cb5bb93
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 45 deletions.
46 changes: 27 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ endif

# Build the project images
.DELETE_ON_ERROR:
all: sensor-linux sensor-controller-linux gateway-controller-linux gateway-client-linux webhook-linux calendar-linux resource-linux artifact-linux file-linux nats-linux kafka-linux amqp-linux mqtt-linux storage-grid-linux github-linux hdfs-linux
all: sensor-linux sensor-controller-linux gateway-controller-linux gateway-client-linux webhook-linux calendar-linux resource-linux artifact-linux file-linux nats-linux kafka-linux amqp-linux mqtt-linux storage-grid-linux github-linux hdfs-linux gitlab-linux sns-linux sqs-linux pubsub-linux trello-linux

all-images: sensor-image sensor-controller-image gateway-controller-image gateway-client-image webhook-image calendar-image resource-image artifact-image file-image nats-image kafka-image amqp-image mqtt-image storage-grid-image github-image gitlab-image sns-image pubsub-image hdfs-image sqs-image
all-images: sensor-image sensor-controller-image gateway-controller-image gateway-client-image webhook-image calendar-image resource-image artifact-image file-image nats-image kafka-image amqp-image mqtt-image storage-grid-image github-image gitlab-image sns-image pubsub-image hdfs-image sqs-image trello-image

all-controller-images: sensor-controller-image gateway-controller-image

Expand Down Expand Up @@ -93,7 +93,7 @@ gateway-client-image: gateway-client-linux

# gateway binaries
webhook:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/webhook-gateway ./gateways/core/webhook/cmd/
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/webhook-gateway ./gateways/core/webhook/cmd/

webhook-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make webhook
Expand All @@ -104,7 +104,7 @@ webhook-image: webhook-linux


calendar:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/calendar-gateway ./gateways/core/calendar/cmd/
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/calendar-gateway ./gateways/core/calendar/cmd/

calendar-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make calendar
Expand All @@ -115,7 +115,7 @@ calendar-image: calendar-linux


resource:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/resource-gateway ./gateways/core/resource/cmd
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/resource-gateway ./gateways/core/resource/cmd

resource-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make resource
Expand All @@ -126,7 +126,7 @@ resource-image: resource-linux


artifact:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/artifact-gateway ./gateways/core/artifact/cmd
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/artifact-gateway ./gateways/core/artifact/cmd

artifact-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make artifact
Expand All @@ -137,7 +137,7 @@ artifact-image: artifact-linux


file:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/file-gateway ./gateways/core/file/cmd
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/file-gateway ./gateways/core/file/cmd

file-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make file
Expand All @@ -149,7 +149,7 @@ file-image: file-linux

#Stream gateways
nats:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/nats-gateway ./gateways/core/stream/nats/cmd
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/nats-gateway ./gateways/core/stream/nats/cmd

nats-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make nats
Expand All @@ -160,7 +160,7 @@ nats-image: nats-linux


kafka:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/kafka-gateway ./gateways/core/stream/kafka/cmd
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/kafka-gateway ./gateways/core/stream/kafka/cmd

kafka-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make kafka
Expand All @@ -171,7 +171,7 @@ kafka-image: kafka-linux


amqp:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/amqp-gateway ./gateways/core/stream/amqp/cmd
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/amqp-gateway ./gateways/core/stream/amqp/cmd

amqp-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make amqp
Expand All @@ -182,7 +182,7 @@ amqp-image: amqp-linux


mqtt:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/mqtt-gateway ./gateways/core/stream/mqtt/cmd
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/mqtt-gateway ./gateways/core/stream/mqtt/cmd

mqtt-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make mqtt
Expand All @@ -194,7 +194,7 @@ mqtt-image: mqtt-linux

# Custom gateways
storage-grid:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/storagegrid-gateway ./gateways/community/storagegrid/cmd
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/storagegrid-gateway ./gateways/community/storagegrid/cmd

storage-grid-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make storage-grid
Expand All @@ -204,7 +204,7 @@ storage-grid-image: storage-grid-linux
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)storage-grid-gateway:$(IMAGE_TAG) ; fi

gitlab:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/gitlab-gateway ./gateways/community/gitlab/cmd
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/gitlab-gateway ./gateways/community/gitlab/cmd

gitlab-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make gitlab
Expand All @@ -214,7 +214,7 @@ gitlab-image: gitlab-linux
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)gitlab-gateway:$(IMAGE_TAG) ; fi

github:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/github-gateway ./gateways/community/github/cmd
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/github-gateway ./gateways/community/github/cmd

github-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make github
Expand All @@ -223,22 +223,28 @@ github-image: github-linux
docker build -t $(IMAGE_PREFIX)github-gateway:$(IMAGE_TAG) -f ./gateways/community/github/Dockerfile .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)github-gateway:$(IMAGE_TAG) ; fi

sns:
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/aws-sns-gateway ./gateways/community/aws-sns/cmd

sns-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/aws-sns-gateway ./gateways/community/aws-sns/cmd
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make sns

sns-image:
docker build -t $(IMAGE_PREFIX)aws-sns-gateway:$(IMAGE_TAG) -f ./gateways/community/aws-sns/Dockerfile .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)aws-sns-gateway:$(IMAGE_TAG) ; fi

pubsub:
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/gcp-pubsub-gateway ./gateways/community/gcp-pubsub/cmd

pubsub-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/gcp-pubsub-gateway ./gateways/community/gcp-pubsub/cmd
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make pubsub

pubsub-image: pubsub-linux
docker build -t $(IMAGE_PREFIX)gcp-pubsub-gateway:$(IMAGE_TAG) -f ./gateways/community/gcp-pubsub/Dockerfile .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)gcp-pubsub-gateway:$(IMAGE_TAG) ; fi

hdfs:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/hdfs-gateway ./gateways/community/hdfs/cmd
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/hdfs-gateway ./gateways/community/hdfs/cmd

hdfs-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make hdfs
Expand All @@ -247,13 +253,15 @@ hdfs-image: hdfs-linux
docker build -t $(IMAGE_PREFIX)hdfs-gateway:$(IMAGE_TAG) -f ./gateways/community/hdfs/Dockerfile .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)hdfs-gateway:$(IMAGE_TAG) ; fi

sqs:
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/aws-sqs-gateway ./gateways/community/aws-sqs/cmd

sqs-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/aws-sqs-gateway ./gateways/community/aws-sqs/cmd
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make sqs

sqs-image: sqs-linux
docker build -t $(IMAGE_PREFIX)aws-sqs-gateway:$(IMAGE_TAG) -f ./gateways/community/aws-sqs/Dockerfile .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)aws-sqs-gateway:$(IMAGE_TAG) ; fi
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)aws-sqs-gateway:$(IMAGE_TAG) ; fi

trello:
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/trello-gateway ./gateways/community/trello/cmd
Expand Down
12 changes: 0 additions & 12 deletions controllers/gateway/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package gateway

import (
"context"
"testing"

"github.com/argoproj/argo-events/common"
Expand All @@ -33,17 +32,6 @@ var (
func TestGatewayControllerConfigWatch(t *testing.T) {
gc := getGatewayController()

convey.Convey("Given a gateway", t, func() {
convey.Convey("Watch a configuration", func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
_, err := gc.watchControllerConfigMap(ctx)
convey.Convey("Make sure no error occurs", func() {
convey.So(err, convey.ShouldBeNil)
})
})
})

convey.Convey("Given a gateway", t, func() {
convey.Convey("Create a new watch and make sure watcher is not nil", func() {
watcher := gc.newControllerConfigMapWatch()
Expand Down
12 changes: 0 additions & 12 deletions controllers/sensor/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package sensor

import (
"context"
"testing"

"github.com/argoproj/argo-events/common"
Expand All @@ -29,17 +28,6 @@ import (
func TestSensorControllerConfigWatch(t *testing.T) {
sc := getSensorController()

convey.Convey("Given a sensor", t, func() {
convey.Convey("Watch a configuration", func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
_, err := sc.watchControllerConfigMap(ctx)
convey.Convey("Make sure no error occurs", func() {
convey.So(err, convey.ShouldBeNil)
})
})
})

convey.Convey("Given a sensor", t, func() {
convey.Convey("Create a new watch and make sure watcher is not nil", func() {
watcher := sc.newControllerConfigMapWatch()
Expand Down
2 changes: 1 addition & 1 deletion gateways/common/naivewatcher/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (w *WatchableTestFS) Walk(root string, walkFn filepath.WalkFunc) error {
func (w *WatchableTestFS) GetFileID(fi os.FileInfo) interface{} {
stat := fi.Sys().(*syscall.Stat_t)
return TestFSID{
Device: stat.Dev,
Device: int32(stat.Dev),
Inode: stat.Ino,
}
}
Expand Down
2 changes: 1 addition & 1 deletion gateways/community/aws-sqs/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ secretKey:
key: secretkey
name: sns
queue: "test-queue"
frequency: "10s"
waitTimeSeconds: 10
`

invalidConfig = `
Expand Down
25 changes: 25 additions & 0 deletions gateways/event-source_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
/*
Copyright 2018 BlackRock, Inc.
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.
*/

package gateways

import (
"context"
"fmt"
"os"
"sync"
"testing"
Expand Down Expand Up @@ -46,10 +63,18 @@ func getGatewayConfig() *GatewayConfig {
type testEventSourceExecutor struct{}

func (ese *testEventSourceExecutor) StartEventSource(eventSource *EventSource, eventStream Eventing_StartEventSourceServer) error {
defer func() {
if r := recover(); r != nil {
fmt.Println(r)
}
}()
_ = eventStream.Send(&Event{
Name: eventSource.Name,
Payload: []byte("test payload"),
})

<-eventStream.Context().Done()

return nil
}

Expand Down

0 comments on commit cb5bb93

Please sign in to comment.