-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathkafkamq_suite_test.go
70 lines (55 loc) · 1.7 KB
/
kafkamq_suite_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package functional
import (
"context"
"testing"
"github.com/splunk/kafka-mq-go/pkg/logging"
"github.com/splunk/kafka-mq-go/queue"
"github.com/splunk/kafka-mq-go/queue/redelivery"
"github.com/splunk/kafka-mq-go/redelivery_tracker/cmd"
"github.com/splunk/kafka-mq-go/tests"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/reporters"
. "github.com/onsi/gomega"
)
var (
conf queue.Config
provisioner *tests.Provisioner
markerConsumer redelivery.MarkerConsumer
err error
logger *logging.Logger
)
func TestKafkaMessageQueue(t *testing.T) {
RegisterFailHandler(Fail)
junitReporter := reporters.NewJUnitReporter("../coverage-dir/kafka-mq-go-functional.xml")
RunSpecsWithDefaultAndCustomReporters(t, "Kafka-based Message Queue Functional Suite", []Reporter{junitReporter})
}
var _ = BeforeSuite(func() {
logger = logging.NewNoOp()
// // Uncomment the following to enable DEBUG logging
// logger = logging.New("functional_test")
// logger.SetLevel(logging.DebugLevel)
// logging.SetGlobalLogger(logger)
configFile := "../config/config.yaml"
conf, err = queue.NewConfigFromFile(configFile)
Expect(err).ShouldNot(HaveOccurred())
provisioner, err = tests.NewProvisioner(conf)
if err != nil {
logger.Fatal(err, "failed to initialize provisioner with error")
}
ctx := context.Background()
Expect(provisioner.ProvisionTopics(ctx)).Should(Succeed())
startRedeliveryTracker()
})
var _ = AfterSuite(func() {
stopRedliveryTracker()
ctx := context.Background()
Expect(provisioner.TeardownTopics(ctx)).Should(Succeed())
})
func startRedeliveryTracker() {
go func() {
markerConsumer = cmd.Start(logger, conf)
}()
}
func stopRedliveryTracker() {
markerConsumer.Stop()
}