-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix config drop passed from configuration file
- add info logs when cron gets scheduled - fix yaml tags for DiskCron - update gocd-prometheus-exporter.sample.yaml with more values
- Loading branch information
1 parent
7c58140
commit b612c23
Showing
15 changed files
with
133 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
--- | ||
gocd-username: "admin" | ||
gocd-password: "admin" | ||
log-level: info | ||
port: 9995 | ||
api-cron-schedule: "@every 20s" | ||
disk-cron-schedule: "@every 20s" | ||
metric-cron: | ||
agent_down: "@every 60s" | ||
metric-endpoint: "/new-metrics" | ||
skip-metrics: | ||
- "backup_configured" | ||
- "admin_count" | ||
gocd-pipelines-path: | ||
- /path/to/pipeline/directory1 | ||
- /path/to/pipeline/directory2 | ||
- /path/to/pipeline/directory3 | ||
metric-cron: | ||
agent_down: "@every 60s" |
16 changes: 16 additions & 0 deletions
16
infrastructure/gocd-prometheus-exporter.fixture.malformed.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
gocd-username: "testing" | ||
gocd-password: "password" | ||
gocd-pipelines-path: | ||
- /path/to/pipeline/directory1 | ||
- /path/to/pipeline/directory2 | ||
- /path/to/pipeline/directory3 | ||
log-level: debug | ||
port: 9995 | ||
api-cron-schedule: "@every @2m" | ||
disk-cron-schedule: "@every @2m" | ||
metric-cron | ||
agent_down: "@every 60s" | ||
skip-metrics: | ||
- "backup_configured" | ||
- "admin_count" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
gocd-username: "testing" | ||
gocd-password: "password" | ||
gocd-pipelines-path: | ||
- /path/to/pipeline/directory1 | ||
- /path/to/pipeline/directory2 | ||
- /path/to/pipeline/directory3 | ||
log-level: debug | ||
port: 9995 | ||
api-cron-schedule: "@every @2m" | ||
disk-cron-schedule: "@every @2m" | ||
metric-cron: | ||
agent_down: "@every 60s" | ||
skip-metrics: | ||
- "backup_configured" | ||
- "admin_count" | ||
metric-endpoint: "/new-metrics" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package app_test | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/nikhilsbhat/gocd-prometheus-exporter/pkg/app" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetConfig(t *testing.T) { | ||
config := app.Config{ | ||
Port: 8090, | ||
GoCdUserName: "test", | ||
GoCdPassword: "password", | ||
DiskCron: "@every 1m", | ||
APICron: "@every 1m", | ||
Endpoint: "/metrics", | ||
} | ||
t.Run("Should fetch config successfully, by merging both config", func(t *testing.T) { | ||
expected := app.Config{ | ||
GoCdUserName: "testing", | ||
GoCdPassword: "password", | ||
InsecureTLS: false, | ||
GoCdPipelinesPath: []string{"/path/to/pipeline/directory1", "/path/to/pipeline/directory2", "/path/to/pipeline/directory3"}, | ||
Port: 9995, | ||
LogLevel: "debug", | ||
SkipMetrics: []string{"backup_configured", "admin_count"}, | ||
APICron: "@every @2m", | ||
DiskCron: "@every @2m", | ||
MetricCron: map[string]string{"agent_down": "@every 60s"}, | ||
Endpoint: "/new-metrics", | ||
} | ||
|
||
path, err := filepath.Abs("../../infrastructure/gocd-prometheus-exporter.fixture.yaml") | ||
assert.NoError(t, err) | ||
|
||
actual, err := app.GetConfig(config, path) | ||
assert.NoError(t, err) | ||
assert.Equal(t, &expected, actual) | ||
}) | ||
|
||
t.Run("Should error out while fetching config due to wrong config file path", func(t *testing.T) { | ||
actual, err := app.GetConfig(config, "gocd-prometheus-exporter.fixture.yaml") | ||
assert.EqualError(t, err, "fetching config file information failed with: "+ | ||
"stat gocd-prometheus-exporter.fixture.yaml: no such file or directory") | ||
assert.Equal(t, actual, &config) | ||
}) | ||
|
||
t.Run("Should error out while decoding config from malformed config file", func(t *testing.T) { | ||
path, err := filepath.Abs("../../infrastructure/gocd-prometheus-exporter.fixture.malformed.yaml") | ||
assert.NoError(t, err) | ||
|
||
actual, err := app.GetConfig(config, path) | ||
assert.EqualError(t, err, "parsing config file errored with: yaml: line 13: could not find expected ':'") | ||
assert.Equal(t, actual, &config) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters