Skip to content

Commit 9b6a9d0

Browse files
authored
test: enable skipped tests (streamnative#788)
* test: enable skipped tests Signed-off-by: Zixuan Liu <[email protected]> * test: enable skipped tests Signed-off-by: Zixuan Liu <[email protected]> * ci: upgrade Pulsar version Signed-off-by: Zixuan Liu <[email protected]> * Update pulsar version Signed-off-by: Zixuan Liu <[email protected]>
1 parent 7f9a1f9 commit 9b6a9d0

15 files changed

+271
-310
lines changed

pkg/ctl/namespace/publish_rate_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import (
2828
)
2929

3030
func TestPublishRateCmd(t *testing.T) {
31-
t.Skipf("The need to keep the same behavior in 2.8.0.13 and 2.8.2.2")
32-
3331
ns := "public/test-publish-rate-ns" + test.RandomSuffix()
3432

3533
args := []string{"create", ns}
@@ -38,9 +36,7 @@ func TestPublishRateCmd(t *testing.T) {
3836

3937
args = []string{"get-publish-rate", ns}
4038
_, execErr, _, _ = TestNamespaceCommands(GetPublishRateCmd, args)
41-
// unset will return 404
42-
assert.NotNil(t, execErr)
43-
assert.Contains(t, execErr.Error(), "404")
39+
assert.Nil(t, execErr)
4440

4541
args = []string{"set-publish-rate", ns}
4642
out, execErr, _, _ := TestNamespaceCommands(SetPublishRateCmd, args)

pkg/ctl/subscription/delete_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ func TestDeleteNonExistingSub(t *testing.T) {
8686
}
8787

8888
func TestDeleteNonExistingTopicSub(t *testing.T) {
89-
t.Skipf("Need fix https://github.com/apache/pulsar/issues/13211")
90-
9189
args := []string{"delete", "non-existing-topic", "non-existing-topic-sub"}
9290
_, execErr, _, _ := TestSubCommands(DeleteCmd, args)
9391
assert.NotNil(t, execErr)

pkg/ctl/subscription/reset_cursor_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package subscription
1919

2020
import (
21+
"strings"
2122
"testing"
2223

2324
"github.com/stretchr/testify/assert"
@@ -56,13 +57,12 @@ func TestResetCursorFlagError(t *testing.T) {
5657
}
5758

5859
func TestResetCursorNonExistingTopic(t *testing.T) {
59-
t.Skipf("Need fix https://github.com/apache/pulsar/issues/13211")
60-
6160
args := []string{"seek", "--time", "1m", "test-reset-cursor-non-existing-topic",
6261
"test-reset-cursor-non-existing-topic-sub"}
6362
_, execErr, _, _ := TestSubCommands(ResetCursorCmd, args)
6463
assert.NotNil(t, execErr)
65-
assert.Equal(t, "code: 404 reason: Topic not found", execErr.Error())
64+
t.Log(execErr.Error())
65+
assert.True(t, strings.Contains(execErr.Error(), "code: 404"))
6666
}
6767

6868
func TestResetCursorNonExistingSub(t *testing.T) {
@@ -74,5 +74,5 @@ func TestResetCursorNonExistingSub(t *testing.T) {
7474
"test-reset-cursor-non-existing-sub"}
7575
_, execErr, _, _ = TestSubCommands(ResetCursorCmd, args)
7676
assert.NotNil(t, execErr)
77-
assert.Equal(t, "code: 404 reason: Subscription not found", execErr.Error())
77+
assert.True(t, strings.Contains(execErr.Error(), "code: 404"))
7878
}

pkg/ctl/topic/compact_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ func TestCompactArgError(t *testing.T) {
5454
}
5555

5656
func TestCompactNonExistingTopic(t *testing.T) {
57-
t.Skipf("Need fix https://github.com/apache/pulsar/issues/13211")
58-
5957
args := []string{"compact", "test-compact-non-existing-topic"}
6058
_, execErr, _, _ := TestTopicCommands(CompactCmd, args)
6159
assert.NotNil(t, execErr)

pkg/ctl/topic/dispatch_rate_test.go

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -20,74 +20,70 @@ package topic
2020
import (
2121
"encoding/json"
2222
"testing"
23-
"time"
2423

24+
"github.com/onsi/gomega"
2525
"github.com/streamnative/pulsarctl/pkg/pulsar/utils"
26-
"github.com/stretchr/testify/assert"
2726
)
2827

2928
func TestDispatchRate(t *testing.T) {
30-
t.Skipf("Refactoring with gomega")
29+
g := gomega.NewWithT(t)
3130

3231
topicName := "persistent://public/default/test-dispatch-rate-topic"
3332
args := []string{"create", topicName, "1"}
3433
_, execErr, _, _ := TestTopicCommands(CreateTopicCmd, args)
35-
assert.Nil(t, execErr)
34+
g.Expect(execErr).Should(gomega.BeNil())
3635

3736
setArgs := []string{"set-dispatch-rate", topicName, "--msg-dispatch-rate", "5", "--byte-dispatch-rate", "4",
3837
"--dispatch-rate-period", "3", "--relative-to-publish-rate"}
3938
setOut, execErr, _, _ := TestTopicCommands(SetDispatchRateCmd, setArgs)
40-
assert.Nil(t, execErr)
41-
assert.Equal(t, setOut.String(), "Set message dispatch rate successfully for ["+topicName+"]\n")
39+
g.Expect(execErr).Should(gomega.BeNil())
40+
g.Expect(setOut.String()).Should(gomega.Equal("Set message dispatch rate successfully for [" + topicName + "]\n"))
4241

43-
time.Sleep(time.Duration(1) * time.Second)
4442
getArgs := []string{"get-dispatch-rate", topicName}
45-
getOut, execErr, _, _ := TestTopicCommands(GetDispatchRateCmd, getArgs)
46-
var dispatchRateData utils.DispatchRateData
47-
err := json.Unmarshal(getOut.Bytes(), &dispatchRateData)
48-
if err != nil {
49-
t.Fatal(err)
50-
}
51-
assert.Nil(t, execErr)
52-
assert.Equal(t, dispatchRateData.DispatchThrottlingRateInMsg, int64(5))
53-
assert.Equal(t, dispatchRateData.DispatchThrottlingRateInByte, int64(4))
54-
assert.Equal(t, dispatchRateData.RatePeriodInSecond, int64(3))
55-
assert.Equal(t, dispatchRateData.RelativeToPublishRate, true)
43+
g.Eventually(func(g gomega.Gomega) {
44+
getOut, execErr, _, _ := TestTopicCommands(GetDispatchRateCmd, getArgs)
45+
g.Expect(execErr).Should(gomega.BeNil())
46+
var dispatchRateData utils.DispatchRateData
47+
err := json.Unmarshal(getOut.Bytes(), &dispatchRateData)
48+
g.Expect(err).Should(gomega.BeNil())
49+
g.Expect(dispatchRateData.DispatchThrottlingRateInMsg).Should(gomega.Equal(int64(5)))
50+
g.Expect(dispatchRateData.DispatchThrottlingRateInByte).Should(gomega.Equal(int64(4)))
51+
g.Expect(dispatchRateData.RatePeriodInSecond).Should(gomega.Equal(int64(3)))
52+
g.Expect(dispatchRateData.RelativeToPublishRate).Should(gomega.Equal(true))
53+
}).Should(gomega.Succeed())
5654

5755
setArgs = []string{"remove-dispatch-rate", topicName}
5856
setOut, execErr, _, _ = TestTopicCommands(RemoveDispatchRateCmd, setArgs)
59-
assert.Nil(t, execErr)
60-
assert.Equal(t, setOut.String(), "Remove message dispatch rate successfully for ["+topicName+"]\n")
57+
g.Expect(execErr).Should(gomega.BeNil())
58+
g.Expect(setOut.String()).Should(gomega.Equal("Remove message dispatch rate successfully for [" + topicName + "]\n"))
6159

62-
time.Sleep(time.Duration(1) * time.Second)
63-
getArgs = []string{"get-dispatch-rate", topicName}
64-
getOut, execErr, _, _ = TestTopicCommands(GetDispatchRateCmd, getArgs)
65-
err = json.Unmarshal(getOut.Bytes(), &dispatchRateData)
66-
if err != nil {
67-
t.Fatal(err)
68-
}
69-
assert.Nil(t, execErr)
70-
assert.Equal(t, dispatchRateData.DispatchThrottlingRateInMsg, int64(0))
71-
assert.Equal(t, dispatchRateData.DispatchThrottlingRateInByte, int64(0))
72-
assert.Equal(t, dispatchRateData.RatePeriodInSecond, int64(0))
73-
assert.Equal(t, dispatchRateData.RelativeToPublishRate, false)
60+
g.Eventually(func(g gomega.Gomega) {
61+
getOut, execErr, _, _ := TestTopicCommands(GetDispatchRateCmd, getArgs)
62+
g.Expect(execErr).Should(gomega.BeNil())
63+
var dispatchRateData utils.DispatchRateData
64+
err := json.Unmarshal(getOut.Bytes(), &dispatchRateData)
65+
g.Expect(err).Should(gomega.BeNil())
66+
g.Expect(dispatchRateData.DispatchThrottlingRateInMsg).Should(gomega.Equal(int64(0)))
67+
g.Expect(dispatchRateData.DispatchThrottlingRateInByte).Should(gomega.Equal(int64(0)))
68+
g.Expect(dispatchRateData.RatePeriodInSecond).Should(gomega.Equal(int64(0)))
69+
g.Expect(dispatchRateData.RelativeToPublishRate).Should(gomega.Equal(false))
70+
}).Should(gomega.Succeed())
7471

7572
setArgs = []string{"set-dispatch-rate", topicName, "--msg-dispatch-rate", "5", "--byte-dispatch-rate", "4",
7673
"--dispatch-rate-period", "3"}
7774
setOut, execErr, _, _ = TestTopicCommands(SetDispatchRateCmd, setArgs)
78-
assert.Nil(t, execErr)
79-
assert.Equal(t, setOut.String(), "Set message dispatch rate successfully for ["+topicName+"]\n")
75+
g.Expect(execErr).Should(gomega.BeNil())
76+
g.Expect(setOut.String()).Should(gomega.Equal("Set message dispatch rate successfully for [" + topicName + "]\n"))
8077

81-
time.Sleep(time.Duration(1) * time.Second)
82-
getArgs = []string{"get-dispatch-rate", topicName}
83-
getOut, execErr, _, _ = TestTopicCommands(GetDispatchRateCmd, getArgs)
84-
err = json.Unmarshal(getOut.Bytes(), &dispatchRateData)
85-
if err != nil {
86-
t.Fatal(err)
87-
}
88-
assert.Nil(t, execErr)
89-
assert.Equal(t, dispatchRateData.DispatchThrottlingRateInMsg, int64(5))
90-
assert.Equal(t, dispatchRateData.DispatchThrottlingRateInByte, int64(4))
91-
assert.Equal(t, dispatchRateData.RatePeriodInSecond, int64(3))
92-
assert.Equal(t, dispatchRateData.RelativeToPublishRate, false)
78+
g.Eventually(func(g gomega.Gomega) {
79+
getOut, execErr, _, _ := TestTopicCommands(GetDispatchRateCmd, getArgs)
80+
g.Expect(execErr).Should(gomega.BeNil())
81+
var dispatchRateData utils.DispatchRateData
82+
err := json.Unmarshal(getOut.Bytes(), &dispatchRateData)
83+
g.Expect(err).Should(gomega.BeNil())
84+
g.Expect(dispatchRateData.DispatchThrottlingRateInMsg).Should(gomega.Equal(int64(5)))
85+
g.Expect(dispatchRateData.DispatchThrottlingRateInByte).Should(gomega.Equal(int64(4)))
86+
g.Expect(dispatchRateData.RatePeriodInSecond).Should(gomega.Equal(int64(3)))
87+
g.Expect(dispatchRateData.RelativeToPublishRate).Should(gomega.Equal(false))
88+
}).Should(gomega.Succeed())
9389
}

pkg/ctl/topic/inactive_topic_test.go

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,60 +21,56 @@ import (
2121
"encoding/json"
2222
"fmt"
2323
"testing"
24-
"time"
2524

25+
"github.com/onsi/gomega"
2626
"github.com/streamnative/pulsarctl/pkg/pulsar/utils"
2727
"github.com/streamnative/pulsarctl/pkg/test"
28-
"github.com/stretchr/testify/assert"
2928
)
3029

3130
func TestInactiveTopicCmd(t *testing.T) {
32-
t.Skipf("Refactoring with gomega")
31+
g := gomega.NewWithT(t)
3332

3433
topicName := fmt.Sprintf("persistent://public/default/test-inactive-topic-%s",
3534
test.RandomSuffix())
3635
createArgs := []string{"create", topicName, "1"}
3736
_, execErr, _, _ := TestTopicCommands(CreateTopicCmd, createArgs)
38-
assert.Nil(t, execErr)
39-
40-
<-time.After(5 * time.Second)
37+
g.Expect(execErr).Should(gomega.BeNil())
4138

4239
setArgs := []string{"set-inactive-topic-policies", topicName,
4340
"-e=true",
4441
"-t", "1h",
4542
"-m", "delete_when_no_subscriptions"}
4643
out, execErr, _, _ := TestTopicCommands(SetInactiveTopicCmd, setArgs)
47-
assert.Nil(t, execErr)
48-
assert.Equal(t, out.String(),
49-
fmt.Sprintf("Set inactive topic policies successfully for [%s]", topicName))
50-
51-
<-time.After(5 * time.Second)
44+
g.Expect(execErr).Should(gomega.BeNil())
45+
g.Expect(out.String()).Should(gomega.Equal(fmt.Sprintf("Set inactive topic policies successfully for [%s]",
46+
topicName)))
5247

5348
getArgs := []string{"get-inactive-topic-policies", topicName}
54-
out, execErr, _, _ = TestTopicCommands(GetInactiveTopicCmd, getArgs)
55-
assert.Nil(t, execErr)
56-
57-
var inactiveTopic utils.InactiveTopicPolicies
58-
err := json.Unmarshal(out.Bytes(), &inactiveTopic)
59-
assert.NoError(t, err)
60-
assert.Equal(t, true, inactiveTopic.DeleteWhileInactive)
61-
assert.Equal(t, 3600, inactiveTopic.MaxInactiveDurationSeconds)
62-
assert.Equal(t, "delete_when_no_subscriptions", inactiveTopic.InactiveTopicDeleteMode.String())
49+
g.Eventually(func(g gomega.Gomega) {
50+
out, execErr, _, _ = TestTopicCommands(GetInactiveTopicCmd, getArgs)
51+
g.Expect(execErr).Should(gomega.BeNil())
52+
var inactiveTopic utils.InactiveTopicPolicies
53+
err := json.Unmarshal(out.Bytes(), &inactiveTopic)
54+
g.Expect(err).Should(gomega.BeNil())
55+
g.Expect(inactiveTopic.DeleteWhileInactive).Should(gomega.Equal(true))
56+
g.Expect(inactiveTopic.MaxInactiveDurationSeconds).Should(gomega.Equal(3600))
57+
g.Expect(inactiveTopic.InactiveTopicDeleteMode.String()).Should(gomega.Equal("delete_when_no_subscriptions"))
58+
}).Should(gomega.Succeed())
6359

6460
removeArgs := []string{"remove-inactive-topic-policies", topicName}
6561
out, execErr, _, _ = TestTopicCommands(RemoveInactiveTopicCmd, removeArgs)
66-
assert.Nil(t, execErr)
67-
assert.Equal(t, out.String(),
68-
fmt.Sprintf("Remove inactive topic policies successfully from [%s]", topicName))
69-
70-
<-time.After(5 * time.Second)
71-
72-
out, execErr, _, _ = TestTopicCommands(GetInactiveTopicCmd, getArgs)
73-
assert.Nil(t, execErr)
62+
g.Expect(execErr).Should(gomega.BeNil())
63+
g.Expect(out.String()).Should(gomega.Equal(fmt.Sprintf("Remove inactive topic policies successfully from [%s]",
64+
topicName)))
7465

75-
err = json.Unmarshal(out.Bytes(), &inactiveTopic)
76-
assert.NoError(t, err)
77-
assert.Equal(t, false, inactiveTopic.DeleteWhileInactive)
78-
assert.Equal(t, 0, inactiveTopic.MaxInactiveDurationSeconds)
79-
assert.Nil(t, inactiveTopic.InactiveTopicDeleteMode)
66+
g.Eventually(func(g gomega.Gomega) {
67+
out, execErr, _, _ = TestTopicCommands(GetInactiveTopicCmd, getArgs)
68+
g.Expect(execErr).Should(gomega.BeNil())
69+
var inactiveTopic utils.InactiveTopicPolicies
70+
err := json.Unmarshal(out.Bytes(), &inactiveTopic)
71+
g.Expect(err).Should(gomega.BeNil())
72+
g.Expect(inactiveTopic.DeleteWhileInactive).Should(gomega.Equal(false))
73+
g.Expect(inactiveTopic.MaxInactiveDurationSeconds).Should(gomega.Equal(0))
74+
g.Expect(inactiveTopic.InactiveTopicDeleteMode).Should(gomega.BeNil())
75+
}).Should(gomega.Succeed())
8076
}

pkg/ctl/topic/max_consumers_test.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,45 @@ package topic
1919

2020
import (
2121
"testing"
22-
"time"
2322

24-
"github.com/stretchr/testify/assert"
23+
"github.com/onsi/gomega"
2524
)
2625

2726
func TestMaxConsumers(t *testing.T) {
28-
t.Skipf("Refactoring with gomega")
27+
g := gomega.NewWithT(t)
2928

3029
topicName := "persistent://public/default/test-max-consumers-topic"
3130
args := []string{"create", topicName, "1"}
3231
_, execErr, _, _ := TestTopicCommands(CreateTopicCmd, args)
33-
assert.Nil(t, execErr)
32+
g.Expect(execErr).Should(gomega.BeNil())
3433

3534
setArgs := []string{"set-max-consumers", topicName, "-c", "20"}
3635
setOut, execErr, _, _ := TestTopicCommands(SetMaxConsumersCmd, setArgs)
37-
assert.Nil(t, execErr)
38-
assert.Equal(t, setOut.String(), "Set max number of consumers successfully for ["+topicName+"]\n")
36+
g.Expect(execErr).Should(gomega.BeNil())
37+
g.Expect(setOut.String()).Should(gomega.Equal("Set max number of consumers successfully for [" + topicName + "]\n"))
3938

40-
time.Sleep(time.Duration(1) * time.Second)
4139
getArgs := []string{"get-max-consumers", topicName}
42-
getOut, execErr, _, _ := TestTopicCommands(GetMaxConsumersCmd, getArgs)
43-
assert.Nil(t, execErr)
44-
assert.Equal(t, getOut.String(), "20")
40+
g.Eventually(func(g gomega.Gomega) {
41+
getOut, execErr, _, _ := TestTopicCommands(GetMaxConsumersCmd, getArgs)
42+
g.Expect(execErr).Should(gomega.BeNil())
43+
g.Expect(getOut.String()).Should(gomega.Equal("20"))
44+
}).Should(gomega.Succeed())
4545

4646
setArgs = []string{"remove-max-consumers", topicName}
4747
setOut, execErr, _, _ = TestTopicCommands(RemoveMaxConsumersCmd, setArgs)
48-
assert.Nil(t, execErr)
49-
assert.Equal(t, setOut.String(), "Remove max number of consumers successfully for ["+topicName+"]\n")
48+
g.Expect(execErr).Should(gomega.BeNil())
49+
g.Expect(setOut.String()).Should(gomega.Equal("Remove max number of consumers successfully for [" + topicName + "]\n"))
5050

51-
time.Sleep(time.Duration(1) * time.Second)
5251
getArgs = []string{"get-max-consumers", topicName}
53-
getOut, execErr, _, _ = TestTopicCommands(GetMaxConsumersCmd, getArgs)
54-
assert.Nil(t, execErr)
55-
assert.Equal(t, getOut.String(), "0")
52+
g.Eventually(func(g gomega.Gomega) {
53+
getOut, execErr, _, _ := TestTopicCommands(GetMaxConsumersCmd, getArgs)
54+
g.Expect(execErr).Should(gomega.BeNil())
55+
g.Expect(getOut.String()).Should(gomega.Equal("0"))
56+
}).Should(gomega.Succeed())
5657

5758
// test negative value
5859
setArgs = []string{"set-max-consumers", topicName, "-c", "-2"}
5960
_, execErr, _, _ = TestTopicCommands(SetMaxConsumersCmd, setArgs)
60-
assert.NotNil(t, execErr)
61-
assert.Equal(t, execErr.Error(), "code: 412 reason: maxConsumers must be 0 or more")
61+
g.Expect(execErr).ShouldNot(gomega.BeNil())
62+
g.Expect(execErr.Error()).Should(gomega.Equal("code: 412 reason: maxConsumers must be 0 or more"))
6263
}

0 commit comments

Comments
 (0)