Skip to content

Commit

Permalink
fix up windows tests for static converter by breaking them out from l…
Browse files Browse the repository at this point in the history
…inux specific tests (#6822)

Signed-off-by: Erik Baranowski <[email protected]>
  • Loading branch information
erikbaranowski authored Apr 4, 2024
1 parent b2403fc commit 644fa14
Show file tree
Hide file tree
Showing 13 changed files with 231 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ import (
)

func TestConvert(t *testing.T) {
test_common.TestDirectory(t, "testdatawindows", ".yaml", true, []string{}, promtailconvert.Convert)
test_common.TestDirectory(t, "testdata", ".yaml", true, []string{}, promtailconvert.Convert)
test_common.TestDirectory(t, "testdata_windows", ".yaml", true, []string{}, promtailconvert.Convert)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//go:build linux

package staticconvert_test

import (
"runtime"
"testing"

"github.com/grafana/agent/internal/converter/internal/staticconvert"
Expand All @@ -12,9 +13,5 @@ import (
func TestConvert(t *testing.T) {
test_common.TestDirectory(t, "testdata", ".yaml", true, []string{"-config.expand-env"}, staticconvert.Convert)
test_common.TestDirectory(t, "testdata-v2", ".yaml", true, []string{"-enable-features", "integrations-next", "-config.expand-env"}, staticconvert.Convert)

if runtime.GOOS == "windows" {
test_common.TestDirectory(t, "testdata_windows", ".yaml", true, []string{}, staticconvert.Convert)
test_common.TestDirectory(t, "testdata-v2_windows", ".yaml", true, []string{"-enable-features", "integrations-next"}, staticconvert.Convert)
}
test_common.TestDirectory(t, "testdata_linux", ".yaml", true, []string{"-config.expand-env"}, staticconvert.Convert)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//go:build windows

package staticconvert_test

import (
"testing"

"github.com/grafana/agent/internal/converter/internal/staticconvert"
"github.com/grafana/agent/internal/converter/internal/test_common"
_ "github.com/grafana/agent/internal/static/metrics/instance" // Imported to override default values via the init function.
)

func TestConvert(t *testing.T) {
test_common.TestDirectory(t, "testdata", ".yaml", true, []string{"-config.expand-env"}, staticconvert.Convert)
test_common.TestDirectory(t, "testdata-v2_windows", ".yaml", true, []string{"-enable-features", "integrations-next"}, staticconvert.Convert)
test_common.TestDirectory(t, "testdata_windows", ".yaml", true, []string{"-config.expand-env"}, staticconvert.Convert)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(Warning) Please review your agent command line flags and ensure they are set in your Flow mode config file where necessary.
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
discovery.consul "metrics_name_jobName" {
services = ["myapp"]
}

prometheus.scrape "metrics_name_jobName" {
targets = concat(
discovery.consul.metrics_name_jobName.targets,
[{
__address__ = "localhost:9099",
}],
[{
__address__ = "localhost:9101",
}],
)
forward_to = [prometheus.remote_write.metrics_name.receiver]
job_name = "jobName"
}

prometheus.remote_write "metrics_name" {
endpoint {
name = "name-149bbd"
url = "http://localhost:9009/api/prom/push"

queue_config { }

metadata_config { }
}
}

discovery.consul "logs_name_jobName" {
datacenter = "bigdata"
tag_separator = ";"
scheme = "sketchy"
username = "toby"
password = "this_password_is_safe_innit?"
allow_stale = false
services = ["myapp"]
tags = ["better", "faster", "stronger"]
node_meta = {
what = "this",
where = "here",
}
refresh_interval = "10m0s"

basic_auth {
username = "toby"
password = "this_password_is_safe_innit?"
}
}

discovery.relabel "logs_name_jobName" {
targets = discovery.consul.logs_name_jobName.targets

rule {
source_labels = ["host"]
target_label = "hostname"
}
}

local.file_match "logs_name_jobName" {
path_targets = discovery.relabel.logs_name_jobName.output
}

loki.source.file "logs_name_jobName" {
targets = local.file_match.logs_name_jobName.targets
forward_to = [loki.write.logs_name.receiver]

file_watch {
min_poll_frequency = "1s"
max_poll_frequency = "5s"
}
legacy_positions_file = "\\path\\name.yml"
}

loki.write "logs_name" {
endpoint {
url = "http://localhost/loki/api/v1/push"
}
external_labels = {}
}

discovery.consul "logs_name2_jobName" {
datacenter = "bigdata"
tag_separator = ";"
scheme = "sketchy"
username = "toby"
password = "this_password_is_safe_innit?"
allow_stale = false
services = ["myapp"]
tags = ["better", "faster", "stronger"]
node_meta = {
what = "this",
where = "here",
}
refresh_interval = "10m0s"

basic_auth {
username = "toby"
password = "this_password_is_safe_innit?"
}
}

discovery.relabel "logs_name2_jobName" {
targets = discovery.consul.logs_name2_jobName.targets

rule {
source_labels = ["host"]
target_label = "hostname"
}
}

local.file_match "logs_name2_jobName" {
path_targets = discovery.relabel.logs_name2_jobName.output
}

loki.source.file "logs_name2_jobName" {
targets = local.file_match.logs_name2_jobName.targets
forward_to = [loki.write.logs_name2.receiver]

file_watch {
min_poll_frequency = "1s"
max_poll_frequency = "5s"
}
legacy_positions_file = "\\path\\name2.yml"
}

loki.write "logs_name2" {
endpoint {
url = "http://localhost/loki/api/v1/push"
}
external_labels = {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
metrics:
global:
remote_write:
- url: http://localhost:9009/api/prom/push
configs:
- name: name
host_filter: false
scrape_configs:
- job_name: 'jobName'
static_configs:
- targets: ['localhost:9099','localhost:9101']
consul_sd_configs:
- server: 'localhost:8500'
services: ['myapp']

logs:
global:
file_watch_config:
min_poll_frequency: 1s
max_poll_frequency: 5s
positions_directory: /path
configs:
- name: name
clients:
- url: http://localhost/loki/api/v1/push
scrape_configs:
- job_name: jobName
consul_sd_configs:
- server: 'localhost:8500'
datacenter: bigdata
scheme: sketchy
username: toby
password: this_password_is_safe_innit?
tags:
- better
- faster
- stronger
services: [ 'myapp' ]
node_meta:
where: here
what: this
tag_separator: ";"
allow_stale: false
refresh_interval: 10m

relabel_configs:
- source_labels:
- host
target_label: hostname
- name: name2
clients:
- url: http://localhost/loki/api/v1/push
scrape_configs:
- job_name: jobName
consul_sd_configs:
- server: 'localhost:8500'
datacenter: bigdata
scheme: sketchy
username: toby
password: this_password_is_safe_innit?
tags:
- better
- faster
- stronger
services: [ 'myapp' ]
node_meta:
where: here
what: this
tag_separator: ";"
allow_stale: false
refresh_interval: 10m

relabel_configs:
- source_labels:
- host
target_label: hostname

0 comments on commit 644fa14

Please sign in to comment.