MCPcopy
hub / github.com/IBM/sarama / TestFuncAdminDescribeConfig

Function TestFuncAdminDescribeConfig

functional_admin_test.go:707–763  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

705}
706
707func TestFuncAdminDescribeConfig(t *testing.T) {
708 t.Parallel()
709 checkKafkaVersion(t, "0.11.0.0")
710 setupFunctionalTest(t)
711 defer teardownFunctionalTest(t)
712
713 kafkaVersion, err := ParseKafkaVersion(FunctionalTestEnv.KafkaVersion)
714 if err != nil {
715 t.Fatal(err)
716 }
717
718 config := NewFunctionalTestConfig()
719 adminClient, err := NewClusterAdmin(FunctionalTestEnv.KafkaBrokerAddrs, config)
720 if err != nil {
721 t.Fatal(err)
722 }
723 defer safeClose(t, adminClient)
724
725 // describe all broker configs (nil ConfigNames) to exercise the null
726 // compact-array path on the v4 flexible wire format
727 results, err := adminClient.DescribeConfigs(
728 []*ConfigResource{{Type: BrokerResource, Name: "1"}},
729 DescribeConfigsOptions{},
730 )
731 require.NoError(t, err)
732 require.Len(t, results, 1)
733 require.Equal(t, ErrNoError, results[0].ErrorCode)
734 require.NotEmpty(t, results[0].Configs)
735
736 for _, entry := range results[0].Configs {
737 assert.NotEmpty(t, entry.Name)
738 }
739
740 // IncludeDocumentation, ConfigType and Documentation are available from v3
741 // (Kafka 2.6.0); request them via the DescribeConfigs options
742 if kafkaVersion.IsAtLeast(V2_6_0_0) {
743 documented, err := adminClient.DescribeConfigs(
744 []*ConfigResource{{Type: BrokerResource, Name: "1"}},
745 DescribeConfigsOptions{IncludeSynonyms: true, IncludeDocumentation: true},
746 )
747 require.NoError(t, err)
748 require.Len(t, documented, 1)
749 require.NotEmpty(t, documented[0].Configs)
750
751 var typed, hasDoc bool
752 for _, entry := range documented[0].Configs {
753 if entry.Type != UnknownConfigType {
754 typed = true
755 }
756 if entry.Documentation != nil && *entry.Documentation != "" {
757 hasDoc = true
758 }
759 }
760 assert.True(t, typed, "expected at least one config with a known ConfigType")
761 assert.True(t, hasDoc, "expected at least one config with Documentation")
762 }
763}
764

Callers

nothing calls this directly

Calls 11

DescribeConfigsMethod · 0.95
checkKafkaVersionFunction · 0.85
setupFunctionalTestFunction · 0.85
teardownFunctionalTestFunction · 0.85
ParseKafkaVersionFunction · 0.85
NewFunctionalTestConfigFunction · 0.85
NewClusterAdminFunction · 0.85
FatalMethod · 0.80
IsAtLeastMethod · 0.80
safeCloseFunction · 0.70
LenMethod · 0.45

Tested by

no test coverage detected