@@ -26,6 +26,7 @@ import (
26
26
)
27
27
28
28
func TestGenerateStaticScrapeConfigConfig (t * testing.T ) {
29
+ HTTPS := "HTTPS"
29
30
suite := []struct {
30
31
name string
31
32
m * promopv1alpha1.ScrapeConfig
@@ -84,6 +85,56 @@ func TestGenerateStaticScrapeConfigConfig(t *testing.T) {
84
85
},
85
86
},
86
87
},
88
+ {
89
+ name : "lowercase schema" ,
90
+ m : & promopv1alpha1.ScrapeConfig {
91
+ ObjectMeta : metav1.ObjectMeta {
92
+ Namespace : "operator" ,
93
+ Name : "scrapeconfig" ,
94
+ },
95
+ Spec : promopv1alpha1.ScrapeConfigSpec {
96
+ Scheme : & HTTPS ,
97
+ },
98
+ },
99
+ ep : promopv1alpha1.StaticConfig {
100
+ Targets : []promopv1alpha1.Target {"foo" , "bar" },
101
+ },
102
+ expectedRelabels : util .Untab (`
103
+ - target_label: __meta_foo
104
+ replacement: bar
105
+ - source_labels: [job]
106
+ target_label: __tmp_prometheus_job_name
107
+ - replacement: operator
108
+ target_label: __meta_kubernetes_scrapeconfig_namespace
109
+ - replacement: scrapeconfig
110
+ target_label: __meta_kubernetes_scrapeconfig_name
111
+ - source_labels: [__address__]
112
+ target_label: instance
113
+ ` ),
114
+ expected : & config.ScrapeConfig {
115
+ JobName : "scrapeConfig/operator/scrapeconfig/static/1" ,
116
+ HonorTimestamps : true ,
117
+ ScrapeInterval : model .Duration (time .Hour ),
118
+ ScrapeTimeout : model .Duration (42 * time .Second ),
119
+ ScrapeProtocols : config .DefaultScrapeProtocols ,
120
+ EnableCompression : true ,
121
+ MetricsPath : "/metrics" ,
122
+ Scheme : "https" ,
123
+ HTTPClientConfig : commonConfig.HTTPClientConfig {
124
+ FollowRedirects : true ,
125
+ EnableHTTP2 : true ,
126
+ },
127
+ ServiceDiscoveryConfigs : discovery.Configs {
128
+ discovery.StaticConfig {
129
+ & targetgroup.Group {
130
+ Targets : []model.LabelSet {{model .AddressLabel : model .LabelValue ("foo" )}, {model .AddressLabel : model .LabelValue ("bar" )}},
131
+ Labels : model.LabelSet {},
132
+ Source : "scrapeConfig/operator/scrapeconfig/static/1" ,
133
+ },
134
+ },
135
+ },
136
+ },
137
+ },
87
138
}
88
139
for _ , tc := range suite {
89
140
t .Run (tc .name , func (t * testing.T ) {
0 commit comments