Skip to content

Commit

Permalink
Fix some health-configs in the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joergdw committed Mar 17, 2023
1 parent 7084138 commit 8498b9b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/autoscaler/api/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ var _ = Describe("Config", func() {
},
))
Expect(conf.CredHelperImpl).To(Equal("default"))
})
})
Expect(conf.Health.UnprotectedEndpoints).To(
ContainElements("/", "/health/liveness", "/health/prometheus", "/debug/pprof"))
}) // It
}) // Context

Context("with partial config", func() {
BeforeEach(func() {
Expand Down
2 changes: 2 additions & 0 deletions src/autoscaler/api/config/testdata/valid_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ db:
catalog_schema_path: '../schemas/catalog.schema.json'
catalog_path: '../exampleconfig/catalog-example.json'
policy_schema_path: '../exampleconfig/policy.schema.json'
health:
unprotected_endpoints: ["/", "/health/liveness", "/health/prometheus", "/debug/pprof"]
scheduler:
scheduler_url: https://localhost:8083
tls:
Expand Down
16 changes: 7 additions & 9 deletions src/autoscaler/integration/integration_operator_others_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ var _ = Describe("Integration_Operator_Others", func() {
tmpDir)
startGolangApiServer()

scalingEngineConfPath = components.PrepareScalingEngineConfig(dbUrl, components.Ports[ScalingEngine], fakeCCNOAAUAA.URL(), defaultHttpClientTimeout, tmpDir)
scalingEngineConfPath = components.PrepareScalingEngineConfig(
dbUrl, components.Ports[ScalingEngine], fakeCCNOAAUAA.URL(), defaultHttpClientTimeout,
tmpDir)
startScalingEngine()

schedulerConfPath = components.PrepareSchedulerConfig(dbUrl, fmt.Sprintf("https://127.0.0.1:%d", components.Ports[ScalingEngine]), tmpDir, defaultHttpClientTimeout)
schedulerConfPath = components.PrepareSchedulerConfig(
dbUrl, fmt.Sprintf("https://127.0.0.1:%d", components.Ports[ScalingEngine]), tmpDir,
defaultHttpClientTimeout)
startScheduler()

})

JustBeforeEach(func() {
Expand All @@ -69,9 +72,7 @@ var _ = Describe("Integration_Operator_Others", func() {
})

Describe("Synchronizer", func() {

Describe("Synchronize the active schedules to scaling engine", func() {

Context("ScalingEngine Server is down when active_schedule changes", func() {
JustBeforeEach(func() {
stopScalingEngine()
Expand Down Expand Up @@ -111,11 +112,9 @@ var _ = Describe("Integration_Operator_Others", func() {
Consistently(func() bool { return activeScheduleExists(testAppId) }).
WithTimeout(10 * time.Second).
WithPolling(1 * time.Second).Should(BeTrue())

})

It("should delete an active schedule in scaling engine after restart", func() {

By("ensure scaling server is down when the active schedule is deleted from scheduler")
//TODO there is a better check than waiting 80 seconds for consecutive errors.
Consistently(func() error {
Expand All @@ -132,7 +131,6 @@ var _ = Describe("Integration_Operator_Others", func() {
WithPolling(5*time.Second).
ShouldNot(BeTrue(), "Active schedule should be removed after restart")
})

})
})
})
Expand Down Expand Up @@ -248,7 +246,7 @@ var _ = Describe("Integration_Operator_Others", func() {

})

It("opeator should remove the staled records ", func() {
It("operator should remove the staled records ", func() {
Eventually(func() bool {
return getAppInstanceMetricTotalCount(testAppId) == 0 &&
getScalingHistoryTotalCount(testAppId) == 0 && getScalingHistoryTotalCount(testAppId) == 0
Expand Down
7 changes: 7 additions & 0 deletions src/autoscaler/metricsforwarder/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/db"
. "code.cloudfoundry.org/app-autoscaler/src/autoscaler/metricsforwarder/config"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/routes"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -67,6 +68,7 @@ db:
connection_max_lifetime: 60s
health:
port: 9999
unprotected_endpoints: ["/", "/health/liveness", "/health/prometheus", "/debug/pprof"]
cred_helper_impl: default
`)
})
Expand All @@ -75,6 +77,8 @@ cred_helper_impl: default
Expect(conf.Server.Port).To(Equal(8081))
Expect(conf.Logging.Level).To(Equal("debug"))
Expect(conf.Health.Port).To(Equal(9999))
Expect(conf.Health.UnprotectedEndpoints).To(
ContainElements("/", "/health/liveness", "/health/prometheus", "/debug/pprof"))
Expect(conf.LoggregatorConfig.MetronAddress).To(Equal("127.0.0.1:3457"))
Expect(conf.Db[db.PolicyDb]).To(Equal(
db.DatabaseConfig{
Expand Down Expand Up @@ -288,6 +292,9 @@ rate_limit:
conf.Server.Port = 8081
conf.Logging.Level = "debug"
conf.Health.Port = 8081
conf.Health.UnprotectedEndpoints = []string{"/", routes.LivenessPath,
routes.ReadinessPath, routes.PrometheusPath, routes.PprofPath}

conf.LoggregatorConfig.MetronAddress = "127.0.0.1:3458"
conf.LoggregatorConfig.TLS.CACertFile = "../testcerts/ca.crt"
conf.LoggregatorConfig.TLS.CertFile = "../testcerts/client.crt"
Expand Down
3 changes: 3 additions & 0 deletions src/autoscaler/metricsgateway/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/helpers"
. "code.cloudfoundry.org/app-autoscaler/src/autoscaler/metricsgateway/config"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/routes"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -844,6 +845,8 @@ health:
},
Health: models.HealthConfig{
Port: 8081,
UnprotectedEndpoints: []string{"/", routes.LivenessPath, routes.PrometheusPath,
routes.PprofPath},
},
}
})
Expand Down
3 changes: 3 additions & 0 deletions src/autoscaler/metricsserver/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/db"
. "code.cloudfoundry.org/app-autoscaler/src/autoscaler/metricsserver/config"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/routes"
)

var _ = Describe("Config", func() {
Expand Down Expand Up @@ -212,6 +213,8 @@ db:
conf.Collector.EnvelopeChannelSize = 300
conf.Collector.MetricChannelSize = 300
conf.Health.Port = 8081
conf.Health.UnprotectedEndpoints = []string{
"/", routes.LivenessPath, routes.PrometheusPath, routes.PprofPath}
})

JustBeforeEach(func() {
Expand Down
5 changes: 4 additions & 1 deletion src/autoscaler/operator/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"time"

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/routes"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/testhelpers"

"code.cloudfoundry.org/app-autoscaler/src/autoscaler/db"
Expand Down Expand Up @@ -241,8 +242,10 @@ scheduler:
conf.AppSyncer.DB.URL = "postgres://pqgotest:[email protected]/pqgotest"
conf.DBLock.DB.URL = "postgres://pqgotest:[email protected]/pqgotest"
conf.HttpClientTimeout = 10 * time.Second
conf.Health.Port = 8081

conf.Health.Port = 8081
conf.Health.UnprotectedEndpoints = []string{"/", routes.LivenessPath,
routes.PrometheusPath, routes.PprofPath}
})

JustBeforeEach(func() {
Expand Down
4 changes: 4 additions & 0 deletions src/autoscaler/scalingengine/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config_test

import (
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/db"
"code.cloudfoundry.org/app-autoscaler/src/autoscaler/routes"
. "code.cloudfoundry.org/app-autoscaler/src/autoscaler/scalingengine/config"
. "code.cloudfoundry.org/app-autoscaler/src/autoscaler/testhelpers"

Expand Down Expand Up @@ -201,6 +202,9 @@ health:
conf.DefaultCoolDownSecs = 300
conf.LockSize = 32
conf.HttpClientTimeout = 10 * time.Second
conf.Health.UnprotectedEndpoints = []string{
"/", routes.LivenessPath, routes.ReadinessPath, routes.PrometheusPath, routes.PprofPath,
}
})

JustBeforeEach(func() {
Expand Down

0 comments on commit 8498b9b

Please sign in to comment.