-
Notifications
You must be signed in to change notification settings - Fork 29
/
mirrormaker_replication_flow_acc_test.go
148 lines (125 loc) · 4.13 KB
/
mirrormaker_replication_flow_acc_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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package aiven
import (
"context"
"math/rand"
"os"
"strconv"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("MirrorMaker 2 Replication flow", func() {
var (
projectName string
project *Project
err error
)
ctx := context.Background()
BeforeEach(func() {
projectName = os.Getenv("AIVEN_PROJECT_NAME")
project, err = client.Projects.Get(ctx, projectName)
})
Context("Get a project", func() {
It("should not error", func() {
Expect(err).NotTo(HaveOccurred())
})
It("should populate fields properly", func() {
Expect(project).NotTo(BeNil())
if project != nil {
Expect(project.Name).NotTo(BeEmpty())
}
})
// mirror maker service
var (
serviceName string
service *Service
errS error
)
JustBeforeEach(func() {
serviceName = "test-acc-sr-mm-" + strconv.Itoa(rand.Int())
service, errS = client.Services.Create(ctx, projectName, CreateServiceRequest{
Cloud: "google-europe-west1",
Plan: "startup-4",
ProjectVPCID: nil,
ServiceName: serviceName,
ServiceType: "kafka_mirrormaker",
})
})
Context("Create new mirror maker service", func() {
It("should not error", func() {
Expect(errS).NotTo(HaveOccurred())
})
It("should populate fields properly", func() {
Expect(service).NotTo(BeNil())
if service != nil {
Expect(service.Name).NotTo(BeEmpty())
Expect(service.Plan).NotTo(BeEmpty())
Expect(service.Type).Should(Equal("kafka_mirrormaker"))
Eventually(func() string {
service, _ = client.Services.Get(ctx, projectName, serviceName)
return service.State
}).ShouldNot(Equal("RUNNING"))
}
})
// mirror maker replication flow
var (
errR error
)
JustBeforeEach(func() {
errR = client.KafkaMirrorMakerReplicationFlow.Create(ctx, projectName, serviceName, MirrorMakerReplicationFlowRequest{
ReplicationFlow{
Enabled: false,
OffsetSyncsTopicLocation: "source",
SourceCluster: "source",
TargetCluster: "target",
Topics: []string{".*"},
TopicsBlacklist: []string{},
SyncGroupOffsetsIntervalSeconds: ref(2),
ReplicationPolicyClass: "org.apache.kafka.connect.mirror.DefaultReplicationPolicy",
},
})
})
Context("Create new mirror maker replication flow", func() {
It("should not error", func() {
Expect(errR).NotTo(HaveOccurred())
})
It("should populate fields properly", func() {
r, errG := client.KafkaMirrorMakerReplicationFlow.Get(ctx, projectName, serviceName, "source", "target")
Expect(errG).NotTo(HaveOccurred())
Expect(r).NotTo(BeNil())
if r != nil {
Expect(r.ReplicationFlow.TargetCluster).NotTo(BeEmpty())
Expect(r.ReplicationFlow.SourceCluster).NotTo(BeEmpty())
}
})
It("should update", func() {
r, errU := client.KafkaMirrorMakerReplicationFlow.Update(ctx, projectName, serviceName, "source", "target", MirrorMakerReplicationFlowRequest{
ReplicationFlow: ReplicationFlow{
Enabled: false,
Topics: []string{".*"},
TopicsBlacklist: []string{"test"},
SyncGroupOffsetsIntervalSeconds: ref(2),
ReplicationPolicyClass: "org.apache.kafka.connect.mirror.DefaultReplicationPolicy",
},
})
Expect(errU).NotTo(HaveOccurred())
Expect(r).NotTo(BeNil())
if r != nil {
Expect(r.ReplicationFlow.TargetCluster).NotTo(BeEmpty())
Expect(r.ReplicationFlow.SourceCluster).NotTo(BeEmpty())
Expect(len(r.ReplicationFlow.TopicsBlacklist)).Should(Equal(1))
}
})
AfterEach(func() {
if errD := client.KafkaMirrorMakerReplicationFlow.Delete(ctx, projectName, serviceName, "source", "target"); errD != nil {
Fail("cannot delete mirror maker replication flow:" + errD.Error())
}
})
})
})
AfterEach(func() {
if errD := client.Services.Delete(ctx, projectName, serviceName); errD != nil {
Fail("cannot delete service:" + errD.Error())
}
})
})
})