(t *testing.T)
| 705 | } |
| 706 | |
| 707 | func 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 |
nothing calls this directly
no test coverage detected