Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore, tests] configuration_switching tests improvements #1593

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions functional_tests/configuration_switching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,15 @@ func testIndexSwitch(t *testing.T) {
var indices []string
logs := agentLogsConsumer.AllLogs()
sourcetypes, indices = getLogsIndexAndSourceType(logs)
assert.True(t, len(sourcetypes) > 1) // we are also receiving logs from other kind containers
assert.Contains(t, sourcetypes, "kube:container:kindnet-cni")
assert.Greater(t, len(sourcetypes), 1) // we are receiving logs from different containers
// check sourcetypes have same prefix
prefix := "kube:container:"
for _, element := range sourcetypes {
if !strings.HasPrefix(element, prefix) {
t.Errorf("Element does not start with the prefix %q: %s", prefix, element)
}
}
assert.NotContains(t, sourcetypes, nonDefaultSourcetype)
assert.True(t, len(indices) == 1)
assert.True(t, indices[0] == logsIndex)

Expand All @@ -290,7 +297,6 @@ func testIndexSwitch(t *testing.T) {
resetLogsSink(t, agentLogsConsumer)
resetMetricsSink(t, hecMetricsConsumer)

waitForMetrics(t, 3, hecMetricsConsumer)
waitForLogs(t, 3, agentLogsConsumer)
logs = agentLogsConsumer.AllLogs()
sourcetypes, indices = getLogsIndexAndSourceType(logs)
Expand All @@ -299,6 +305,8 @@ func testIndexSwitch(t *testing.T) {
assert.Contains(t, sourcetypes, nonDefaultSourcetype)
assert.True(t, len(indices) == 1)
assert.True(t, len(sourcetypes) == 1)

waitForMetrics(t, 3, hecMetricsConsumer)
mIndices = getMetricsIndex(hecMetricsConsumer.AllMetrics())
assert.True(t, len(mIndices) == 1)
assert.True(t, mIndices[0] == newMetricsIndex)
Expand All @@ -319,6 +327,7 @@ func testClusterReceiverEnabledOrDisabled(t *testing.T) {
logsObjectsHecEndpoint := fmt.Sprintf("http://%s:%d/services/collector", hostEp, hecLogsObjectsReceiverPort)

t.Run("check cluster receiver enabled", func(t *testing.T) {
resetLogsSink(t, logsObjectsConsumer)
replacements := map[string]interface{}{
"ClusterReceiverEnabled": false,
"LogObjectsHecEndpoint": logsObjectsHecEndpoint,
Expand Down
Loading