Skip to content

Commit

Permalink
WIP progress on test-suite metricsforwarder; integration still in pro…
Browse files Browse the repository at this point in the history
…gress as well;
  • Loading branch information
joergdw committed Mar 9, 2023
1 parent d556e63 commit fda104a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ test-autoscaler: check-db_type init init-db test-certs
@make -C src/autoscaler test DBURL="${DBURL}" OPTS="${OPTS}"

# ⚠ The target dependencies "autoscaler" and "scheduler" are needed by the integration tests.
# TODO: Introduce make-target for the .war-file and the needed autoscaler-files instead?
test-autoscaler-suite: check-db_type init init-db test-certs autoscaler scheduler
@echo " - using DBURL=${DBURL} TEST=${TEST} OPTS=${OPTS}"
@make -C src/autoscaler testsuite TEST=${TEST} DBURL="${DBURL}" OPTS="${OPTS}"
Expand Down
3 changes: 2 additions & 1 deletion src/autoscaler/integration/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ func deleteSchedule(appId string) (*http.Response, error) {

func getActiveSchedule(appId string) (*http.Response, error) {
By("getActiveSchedule")
req, err := http.NewRequest("GET", fmt.Sprintf("https://127.0.0.1:%d/v1/apps/%s/active_schedules", components.Ports[ScalingEngine], appId), strings.NewReader(""))
url := fmt.Sprintf("https://127.0.0.1:%d/v1/apps/%s/active_schedules", components.Ports[ScalingEngine], appId)
req, err := http.NewRequest("GET", url, strings.NewReader(""))
Expect(err).NotTo(HaveOccurred())
req.Header.Set("Content-Type", "application/json")
return httpClient.Do(req)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

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

. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"
Expand Down Expand Up @@ -139,14 +140,12 @@ var _ = Describe("Metricsforwarder", func() {

Describe("when Health server is ready to serve RESTful API", func() {
BeforeEach(func() {

basicAuthConfig := cfg
basicAuthConfig.Health.HealthCheckUsername = ""
basicAuthConfig.Health.HealthCheckPassword = ""
runner.configPath = writeConfig(&basicAuthConfig).Name()

runner.Start()

})
Context("when a request to query health comes", func() {
It("returns with a 200", func() {
Expand Down Expand Up @@ -174,9 +173,9 @@ var _ = Describe("Metricsforwarder", func() {
})

Context("when username and password are incorrect for basic authentication during health check", func() {
It("should return 401", func() {

req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("http://127.0.0.1:%d/health", healthport), nil)
It("should return 401 for liveness-path", func() {
url := fmt.Sprintf("http://127.0.0.1:%d%s", healthport, routes.LivenessPath)
req, err := http.NewRequest(http.MethodGet, url, nil)
Expect(err).NotTo(HaveOccurred())

req.SetBasicAuth("wrongusername", "wrongpassword")
Expand All @@ -188,9 +187,9 @@ var _ = Describe("Metricsforwarder", func() {
})

Context("when username and password are correct for basic authentication during health check", func() {
It("should return 200 for /health", func() {

req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("http://127.0.0.1:%d/health", healthport), nil)
It("should return 200 for liveness-path", func() {
url := fmt.Sprintf("http://127.0.0.1:%d%s", healthport, routes.LivenessPath)
req, err := http.NewRequest(http.MethodGet, url, nil)
Expect(err).NotTo(HaveOccurred())

req.SetBasicAuth(cfg.Health.HealthCheckUsername, cfg.Health.HealthCheckPassword)
Expand All @@ -200,7 +199,8 @@ var _ = Describe("Metricsforwarder", func() {
Expect(rsp.StatusCode).To(Equal(http.StatusOK))
})
It("should return 200 for /health/readiness", func() {
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("http://127.0.0.1:%d/health/readiness", healthport), nil)
url := fmt.Sprintf("http://127.0.0.1:%d%s", healthport, routes.ReadinessPath)
req, err := http.NewRequest(http.MethodGet, url, nil)
Expect(err).NotTo(HaveOccurred())
rsp, err := healthHttpClient.Do(req)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -223,8 +223,8 @@ var _ = Describe("Metricsforwarder", func() {

Context("when username and password are incorrect for basic authentication during health check", func() {
It("should return 401", func() {

req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("http://127.0.0.1:%d/health", healthport), nil)
url := fmt.Sprintf("http://127.0.0.1:%d%s", healthport, routes.LivenessPath)
req, err := http.NewRequest(http.MethodGet, url, nil)
Expect(err).NotTo(HaveOccurred())

req.SetBasicAuth("wrongusername", "wrongpassword")
Expand All @@ -237,8 +237,8 @@ var _ = Describe("Metricsforwarder", func() {

Context("when username and password are correct for basic authentication during health check", func() {
It("should return 200", func() {

req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("http://127.0.0.1:%d/health", healthport), nil)
url := fmt.Sprintf("http://127.0.0.1:%d%s", healthport, routes.LivenessPath)
req, err := http.NewRequest(http.MethodGet, url, nil)
Expect(err).NotTo(HaveOccurred())

req.SetBasicAuth(cfg.Health.HealthCheckUsername, cfg.Health.HealthCheckPassword)
Expand Down

0 comments on commit fda104a

Please sign in to comment.