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

Fix a broken Windows test #6985

Merged
merged 1 commit into from
Jul 18, 2024
Merged
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
13 changes: 10 additions & 3 deletions static/logs/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,17 @@ configs:
// We expect the config reload log line to not be printed.
checkConfigReloadLog(t, logBuffer.String(), 0)

// Windows file paths contain `\` characters.
// Those are not allowed in Prometheus label values:
// https://prometheus.io/docs/instrumenting/exposition_formats/#text-format-details
// `label_value` can be any sequence of UTF-8 characters, but the backslash (\), double-quote ("),
// and line feed (\n) characters have to be escaped as \\, \", and \n, respectively.
tmpFileLabelVal := strings.ReplaceAll(tmpFile.Name(), `\`, `\\`)

require.NoError(t, testutil.GatherAndCompare(reg, strings.NewReader(`
# HELP my_promtail_custom_log_lines_total total number of log lines
# TYPE my_promtail_custom_log_lines_total counter
my_promtail_custom_log_lines_total{filename="`+tmpFile.Name()+`",job="test",logs_config="default"} 1
my_promtail_custom_log_lines_total{filename="`+tmpFileLabelVal+`",job="test",logs_config="default"} 1
`), "my_promtail_custom_log_lines_total"))

//
Expand All @@ -150,7 +157,7 @@ my_promtail_custom_log_lines_total{filename="`+tmpFile.Name()+`",job="test",logs
require.NoError(t, testutil.GatherAndCompare(reg, strings.NewReader(`
# HELP my_promtail_custom_log_lines_total total number of log lines
# TYPE my_promtail_custom_log_lines_total counter
my_promtail_custom_log_lines_total{filename="`+tmpFile.Name()+`",job="test",logs_config="default"} 1
my_promtail_custom_log_lines_total{filename="`+tmpFileLabelVal+`",job="test",logs_config="default"} 1
`), "my_promtail_custom_log_lines_total"))

//
Expand Down Expand Up @@ -209,7 +216,7 @@ configs:
require.NoError(t, testutil.GatherAndCompare(reg, strings.NewReader(`
# HELP my_promtail_custom2_log_lines_total2 total number of log lines
# TYPE my_promtail_custom2_log_lines_total2 counter
my_promtail_custom2_log_lines_total2{filename="`+tmpFile.Name()+`",job="test-2",logs_config="default"} 1
my_promtail_custom2_log_lines_total2{filename="`+tmpFileLabelVal+`",job="test-2",logs_config="default"} 1
`), "my_promtail_custom_log_lines_total", "my_promtail_custom2_log_lines_total2"))

t.Run("update to nil", func(t *testing.T) {
Expand Down
Loading