MCPcopy Create free account
hub / github.com/apache/pulsar-client-go / TestMaxSubscriptionsPerTopic

Function TestMaxSubscriptionsPerTopic

pulsaradmin/pkg/admin/topic_test.go:818–863  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

816}
817
818func TestMaxSubscriptionsPerTopic(t *testing.T) {
819 randomName := newTopicName()
820 topic := "persistent://public/default/" + randomName
821 cfg := &config.Config{}
822 admin, err := New(cfg)
823 assert.NoError(t, err)
824 assert.NotNil(t, admin)
825 topicName, err := utils.GetTopicName(topic)
826 assert.NoError(t, err)
827 err = admin.Topics().Create(*topicName, 4)
828 assert.NoError(t, err)
829
830 // Get default max subscriptions per topic
831 maxSubscriptions, err := admin.Topics().GetMaxSubscriptionsPerTopic(*topicName)
832 assert.NoError(t, err)
833 assert.Equal(t, -1, maxSubscriptions)
834
835 // Set new max subscriptions per topic
836 err = admin.Topics().SetMaxSubscriptionsPerTopic(*topicName, 100)
837 assert.NoError(t, err)
838
839 // topic policy is an async operation,
840 // so we need to wait for a while to get current value
841 assert.Eventually(
842 t,
843 func() bool {
844 maxSubscriptions, err = admin.Topics().GetMaxSubscriptionsPerTopic(*topicName)
845 return err == nil && maxSubscriptions == 100
846 },
847 10*time.Second,
848 100*time.Millisecond,
849 )
850
851 // Remove max subscriptions per topic policy
852 err = admin.Topics().RemoveMaxSubscriptionsPerTopic(*topicName)
853 assert.NoError(t, err)
854 assert.Eventually(
855 t,
856 func() bool {
857 maxSubscriptions, err = admin.Topics().GetMaxSubscriptionsPerTopic(*topicName)
858 return err == nil && maxSubscriptions == -1
859 },
860 10*time.Second,
861 100*time.Millisecond,
862 )
863}
864
865func TestSchemaValidationEnforced(t *testing.T) {
866 randomName := newTopicName()

Callers

nothing calls this directly

Calls 8

GetTopicNameFunction · 0.92
NewFunction · 0.85
newTopicNameFunction · 0.70
CreateMethod · 0.65
TopicsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…