mirror of
https://github.com/coreos/prometheus-operator.git
synced 2026-02-05 06:45:27 +01:00
refactor http sd
This commit is contained in:
@@ -511,6 +511,9 @@ func testScrapeConfigCRDValidations(t *testing.T) {
|
||||
t.Run("FileSD", func(t *testing.T) {
|
||||
runScrapeConfigCRDValidation(t, FileSDTestCases)
|
||||
})
|
||||
t.Run("HTTPSD", func(t *testing.T) {
|
||||
runScrapeConfigCRDValidation(t, HTTPSDTestCases)
|
||||
})
|
||||
}
|
||||
|
||||
func runScrapeConfigCRDValidation(t *testing.T, testCases []scrapeCRDTestCase) {
|
||||
@@ -540,6 +543,62 @@ func runScrapeConfigCRDValidation(t *testing.T, testCases []scrapeCRDTestCase) {
|
||||
}
|
||||
}
|
||||
|
||||
var HTTPSDTestCases = []scrapeCRDTestCase{
|
||||
{
|
||||
name: "Invalid URL",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
HTTPSDConfigs: []monitoringv1alpha1.HTTPSDConfig{
|
||||
{
|
||||
URL: "valid-server",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid empty URL",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
HTTPSDConfigs: []monitoringv1alpha1.HTTPSDConfig{
|
||||
{
|
||||
URL: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid absent URL",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
HTTPSDConfigs: []monitoringv1alpha1.HTTPSDConfig{
|
||||
{},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "Valid URL with http scheme",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
HTTPSDConfigs: []monitoringv1alpha1.HTTPSDConfig{
|
||||
{
|
||||
URL: "http://valid.test",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
name: "Valid URL with https scheme",
|
||||
scrapeConfigSpec: monitoringv1alpha1.ScrapeConfigSpec{
|
||||
HTTPSDConfigs: []monitoringv1alpha1.HTTPSDConfig{
|
||||
{
|
||||
URL: "https://valid-url",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedError: false,
|
||||
},
|
||||
}
|
||||
|
||||
var K8STestCases = []scrapeCRDTestCase{
|
||||
{
|
||||
name: "APIServer with empty value",
|
||||
|
||||
Reference in New Issue
Block a user