-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove other node exporter references
- Loading branch information
Showing
14 changed files
with
79 additions
and
292 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,55 @@ | ||
package config_test | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
"os" | ||
"testing" | ||
|
||
"github.com/cloudzero/cloudzero-agent-validator/pkg/config" | ||
"github.com/pkg/errors" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/cloudzero/cloudzero-agent-validator/pkg/config" | ||
"github.com/pkg/errors" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestPrometheus_Validate(t *testing.T) { | ||
wd, err := os.Getwd() | ||
assert.NoError(t, err) | ||
scrapeConfigFile := wd + "/testdata/prometheus.yml" | ||
tests := []struct { | ||
name string | ||
prom config.Prometheus | ||
expected error | ||
}{ | ||
{ | ||
name: "ValidPrometheus", | ||
prom: config.Prometheus{ | ||
KubeStateMetricsServiceEndpoint: kmsServiceEndpoint, | ||
PrometheusNodeExporterServiceEndpoint: promNodeExporterServiceEndpoint, | ||
Configurations: []string{scrapeConfigFile}, | ||
}, | ||
expected: nil, | ||
}, | ||
{ | ||
name: "MissingKubeStateMetricsServiceEndpoint", | ||
prom: config.Prometheus{ | ||
PrometheusNodeExporterServiceEndpoint: promNodeExporterServiceEndpoint, | ||
Configurations: []string{scrapeConfigFile}, | ||
}, | ||
expected: errors.New(config.ErrNoKubeStateMetricsServiceEndpointMsg), | ||
}, | ||
{ | ||
name: "MissingPrometheusNodeExporterServiceEndpoint", | ||
prom: config.Prometheus{ | ||
KubeStateMetricsServiceEndpoint: kmsServiceEndpoint, | ||
Configurations: []string{scrapeConfigFile}, | ||
}, | ||
expected: errors.New(config.ErrNoPrometheusNodeExporterServiceEndpointMsg), | ||
}, | ||
{ | ||
name: "MissingScrapeConfigLocation", | ||
prom: config.Prometheus{ | ||
KubeStateMetricsServiceEndpoint: kmsServiceEndpoint, | ||
PrometheusNodeExporterServiceEndpoint: promNodeExporterServiceEndpoint, | ||
}, | ||
expected: nil, | ||
}, | ||
} | ||
wd, err := os.Getwd() | ||
assert.NoError(t, err) | ||
scrapeConfigFile := wd + "/testdata/prometheus.yml" | ||
tests := []struct { | ||
name string | ||
prom config.Prometheus | ||
expected error | ||
}{ | ||
{ | ||
name: "ValidPrometheus", | ||
prom: config.Prometheus{ | ||
KubeStateMetricsServiceEndpoint: kmsServiceEndpoint, | ||
Configurations: []string{scrapeConfigFile}, | ||
}, | ||
expected: nil, | ||
}, | ||
{ | ||
name: "MissingKubeStateMetricsServiceEndpoint", | ||
prom: config.Prometheus{ | ||
Configurations: []string{scrapeConfigFile}, | ||
}, | ||
expected: errors.New(config.ErrNoKubeStateMetricsServiceEndpointMsg), | ||
}, | ||
{ | ||
name: "MissingScrapeConfigLocation", | ||
prom: config.Prometheus{ | ||
KubeStateMetricsServiceEndpoint: kmsServiceEndpoint, | ||
}, | ||
expected: nil, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
err := tt.prom.Validate() | ||
if tt.expected == nil { | ||
assert.NoError(t, err) | ||
return | ||
} | ||
assert.Equal(t, tt.expected.Error(), err.Error()) | ||
}) | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
err := tt.prom.Validate() | ||
if tt.expected == nil { | ||
assert.NoError(t, err) | ||
return | ||
} | ||
assert.Equal(t, tt.expected.Error(), err.Error()) | ||
}) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,52 @@ | ||
package catalog_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"context" | ||
"testing" | ||
|
||
"github.com/cloudzero/cloudzero-agent-validator/pkg/config" | ||
"github.com/cloudzero/cloudzero-agent-validator/pkg/diagnostic/catalog" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/cloudzero/cloudzero-agent-validator/pkg/config" | ||
"github.com/cloudzero/cloudzero-agent-validator/pkg/diagnostic/catalog" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRegistry_Get(t *testing.T) { | ||
ctx := context.Background() | ||
c := &config.Settings{} | ||
r := catalog.NewCatalog(ctx, c) | ||
ctx := context.Background() | ||
c := &config.Settings{} | ||
r := catalog.NewCatalog(ctx, c) | ||
|
||
// Test getting providers with existing IDs | ||
providers := r.Get(config.DiagnosticAPIKey, config.DiagnosticK8sVersion) | ||
assert.Len(t, providers, 2) | ||
// Test getting providers with existing IDs | ||
providers := r.Get(config.DiagnosticAPIKey, config.DiagnosticK8sVersion) | ||
assert.Len(t, providers, 2) | ||
|
||
// Test getting providers with non-existing IDs | ||
providers = r.Get("non-existing-id") | ||
assert.Empty(t, providers) | ||
// Test getting providers with non-existing IDs | ||
providers = r.Get("non-existing-id") | ||
assert.Empty(t, providers) | ||
|
||
// Test getting providers with empty IDs | ||
providers = r.Get() | ||
assert.Empty(t, providers) | ||
// Test getting providers with empty IDs | ||
providers = r.Get() | ||
assert.Empty(t, providers) | ||
} | ||
|
||
func TestRegistry_Has(t *testing.T) { | ||
ctx := context.Background() | ||
c := &config.Settings{} | ||
r := catalog.NewCatalog(ctx, c) | ||
ctx := context.Background() | ||
c := &config.Settings{} | ||
r := catalog.NewCatalog(ctx, c) | ||
|
||
// Test checking for existing ID | ||
has := r.Has(config.DiagnosticAPIKey) | ||
assert.True(t, has) | ||
// Test checking for existing ID | ||
has := r.Has(config.DiagnosticAPIKey) | ||
assert.True(t, has) | ||
|
||
// Test checking for non-existing ID | ||
has = r.Has("non-existing-id") | ||
assert.False(t, has) | ||
// Test checking for non-existing ID | ||
has = r.Has("non-existing-id") | ||
assert.False(t, has) | ||
} | ||
|
||
func TestRegistry_List(t *testing.T) { | ||
ctx := context.Background() | ||
c := &config.Settings{} | ||
r := catalog.NewCatalog(ctx, c) | ||
ctx := context.Background() | ||
c := &config.Settings{} | ||
r := catalog.NewCatalog(ctx, c) | ||
|
||
// Test listing providers | ||
providers := r.List() | ||
assert.Len(t, providers, 7) | ||
// Test listing providers | ||
providers := r.List() | ||
assert.Len(t, providers, 6) // Update the expected length to 6 | ||
} |
Oops, something went wrong.