Skip to content

Commit

Permalink
monitoring: fix unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Jun 9, 2020
1 parent 70ecfbb commit 3a1430d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/3scale/amp/operator/apicast_options_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ func testApicastProductionPodLabels() map[string]string {
}
}

func testApicastStagingMonitoringLabels() map[string]string {
return map[string]string{
"app": appLabel,
"threescale_component": "apicast",
"threescale_component_element": "staging",
"monitoring-key": "middleware",
}
}

func testApicastProductionMonitoringLabels() map[string]string {
return map[string]string{
"app": appLabel,
"threescale_component": "apicast",
"threescale_component_element": "production",
"monitoring-key": "middleware",
}
}

func basicApimanagerTestApicastOptions() *appsv1alpha1.APIManager {
tmpApicastManagementAPI := apicastManagementAPI
tmpOpenSSLVerify := openSSLVerify
Expand Down Expand Up @@ -110,6 +128,8 @@ func defaultApicastOptions() *component.ApicastOptions {
CommonProductionLabels: testApicastProductionLabels(),
StagingPodTemplateLabels: testApicastStagingPodLabels(),
ProductionPodTemplateLabels: testApicastProductionPodLabels(),
StagingMonitoringLabels: testApicastStagingMonitoringLabels(),
ProductionMonitoringLabels: testApicastProductionMonitoringLabels(),
}
}

Expand Down
20 changes: 20 additions & 0 deletions pkg/3scale/amp/operator/backend_options_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@ func testBackendCronPodLabels() map[string]string {
}
}

func testBackendMonitoringListenerLabels() map[string]string {
return map[string]string{
"app": appLabel,
"threescale_component": "backend",
"threescale_component_element": "listener",
"monitoring-key": "middleware",
}
}

func testBackendMonitoringWorkerLabels() map[string]string {
return map[string]string{
"app": appLabel,
"threescale_component": "backend",
"threescale_component_element": "worker",
"monitoring-key": "middleware",
}
}

func getInternalSecret() *v1.Secret {
data := map[string]string{
component.BackendSecretInternalApiUsernameFieldName: "someUserName",
Expand Down Expand Up @@ -164,6 +182,8 @@ func defaultBackendOptions(opts *component.BackendOptions) *component.BackendOpt
ListenerPodTemplateLabels: testBackendListenerPodLabels(),
WorkerPodTemplateLabels: testBackendWorkerPodLabels(),
CronPodTemplateLabels: testBackendCronPodLabels(),
ListenerMonitoringLabels: testBackendMonitoringListenerLabels(),
WorkerMonitoringLabels: testBackendMonitoringWorkerLabels(),
}
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/3scale/amp/operator/system_options_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ func testSystemSMTPLabels() map[string]string {
"threescale_component_element": "smtp",
}
}
func testSystemSidekiqMonitoringLabels() map[string]string {
return map[string]string{
"app": appLabel,
"threescale_component": "system",
"threescale_component_element": "sidekiq",
"monitoring-key": "middleware",
}
}

func basicApimanagerSpecTestSystemOptions() *appsv1alpha1.APIManager {
tmpSystemAppReplicas := systemAppReplicas
Expand Down Expand Up @@ -294,6 +302,7 @@ func defaultSystemOptions(opts *component.SystemOptions) *component.SystemOption
SphinxPodTemplateLabels: testSystemSphinxPodTemplateLabels(),
MemcachedLabels: testSystemMemcachedLabels(),
SMTPLabels: testSystemSMTPLabels(),
SidekiqMonitoringLabels: testSystemSidekiqMonitoringLabels(),
}

expectedOpts.ApicastSystemMasterProxyConfigEndpoint = component.DefaultApicastSystemMasterProxyConfigEndpoint(opts.ApicastAccessToken)
Expand Down
20 changes: 20 additions & 0 deletions pkg/3scale/amp/operator/zync_options_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,24 @@ func testZyncDatabasePodTemplateCommonLabels() map[string]string {
}
}

func testZyncZyncMonitoringLabels() map[string]string {
return map[string]string{
"app": appLabel,
"threescale_component": "zync",
"threescale_component_element": "zync",
"monitoring-key": "middleware",
}
}

func testZyncQueMonitoringLabels() map[string]string {
return map[string]string{
"app": appLabel,
"threescale_component": "zync",
"threescale_component_element": "zync-que",
"monitoring-key": "middleware",
}
}

func getZyncSecret() *v1.Secret {
data := map[string]string{
component.ZyncSecretKeyBaseFieldName: zyncSecretKeyBasename,
Expand Down Expand Up @@ -136,6 +154,8 @@ func defaultZyncOptions(opts *component.ZyncOptions) *component.ZyncOptions {
ZyncPodTemplateLabels: testZyncPodTemplateLabels(),
ZyncQuePodTemplateLabels: testZyncQuePodTemplateCommonLabels(),
ZyncDatabasePodTemplateLabels: testZyncDatabasePodTemplateCommonLabels(),
ZyncMonitoringLabels: testZyncZyncMonitoringLabels(),
ZyncQueMonitoringLabels: testZyncQueMonitoringLabels(),
}

expectedOpts.DatabaseURL = component.DefaultZyncDatabaseURL(expectedOpts.DatabasePassword)
Expand Down

0 comments on commit 3a1430d

Please sign in to comment.