Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #540 from silvestre/unflake-tests
Browse files Browse the repository at this point in the history
Fix ratelimiter config in tests
  • Loading branch information
cdlliuy authored Nov 17, 2019
2 parents 1d06c24 + 299783d commit d21bcb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
9 changes: 3 additions & 6 deletions src/autoscaler/api/publicapiserver/public_api_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ var _ = Describe("PublicApiServer", func() {
BeforeEach(func() {
fakeRateLimiter.ExceedsLimitReturns(true)
})
AfterEach(func() {
fakeRateLimiter.ExceedsLimitReturns(false)
})

Context("when calling scaling_histories endpoint", func() {
It("should fail with 429", func() {
Expand Down Expand Up @@ -147,10 +150,6 @@ var _ = Describe("PublicApiServer", func() {
})

Describe("Without AuthorizatioToken", func() {
BeforeEach(func() {
fakeRateLimiter.ExceedsLimitReturns(false)
})

Context("when calling scaling_histories endpoint", func() {
It("should fail with 401", func() {
verifyResponse(httpClient, serverUrl, "/v1/apps/"+TEST_APP_ID+"/scaling_histories",
Expand Down Expand Up @@ -215,7 +214,6 @@ var _ = Describe("PublicApiServer", func() {
Describe("With Invalid Authorization Token", func() {
BeforeEach(func() {
fakeCFClient.IsUserSpaceDeveloperReturns(false, nil)
fakeRateLimiter.ExceedsLimitReturns(false)
})

Context("when calling scaling_histories endpoint", func() {
Expand Down Expand Up @@ -299,7 +297,6 @@ var _ = Describe("PublicApiServer", func() {
Describe("With valid authorization token", func() {
BeforeEach(func() {
fakeCFClient.IsUserSpaceDeveloperReturns(true, nil)
fakeRateLimiter.ExceedsLimitReturns(false)
})

Context("when calling scaling_histories endpoint", func() {
Expand Down
10 changes: 4 additions & 6 deletions src/autoscaler/metricsforwarder/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var _ = Describe("CustomMetrics Server", func() {

Context("when a request to forward custom metrics comes", func() {
BeforeEach(func() {
rateLimiter.ExceedsLimitReturns(false)
credentials = &models.Credential{}
scalingPolicy = &models.ScalingPolicy{
InstanceMin: 1,
Expand Down Expand Up @@ -66,7 +65,6 @@ var _ = Describe("CustomMetrics Server", func() {

Context("when a request to forward custom metrics comes without Authorization header", func() {
BeforeEach(func() {
rateLimiter.ExceedsLimitReturns(false)
credentials = &models.Credential{}
credentials.Username = "$2a$10$YnQNQYcvl/Q2BKtThOKFZ.KB0nTIZwhKr5q1pWTTwC/PUAHsbcpFu"
credentials.Password = "$2a$10$6nZ73cm7IV26wxRnmm5E1.nbk9G.0a4MrbzBFPChkm5fPftsUwj9G"
Expand All @@ -89,7 +87,6 @@ var _ = Describe("CustomMetrics Server", func() {

Context("when a request to forward custom metrics comes without 'Basic'", func() {
BeforeEach(func() {
rateLimiter.ExceedsLimitReturns(false)
credentials = &models.Credential{}
credentials.Username = "$2a$10$YnQNQYcvl/Q2BKtThOKFZ.KB0nTIZwhKr5q1pWTTwC/PUAHsbcpFu"
credentials.Password = "$2a$10$6nZ73cm7IV26wxRnmm5E1.nbk9G.0a4MrbzBFPChkm5fPftsUwj9G"
Expand All @@ -113,7 +110,6 @@ var _ = Describe("CustomMetrics Server", func() {

Context("when a request to forward custom metrics comes with wrong user credentials", func() {
BeforeEach(func() {
rateLimiter.ExceedsLimitReturns(false)
credentials = &models.Credential{}
credentials.Username = "$2a$10$YnQNQYcvl/Q2BKtThOKFZ.KB0nTIZwhKr5q1pWTTwC/PUAHsbcpFu"
credentials.Password = "$2a$10$6nZ73cm7IV26wxRnmm5E1.nbk9G.0a4MrbzBFPChkm5fPftsUwj9G"
Expand All @@ -138,7 +134,6 @@ var _ = Describe("CustomMetrics Server", func() {

Context("when a request to forward custom metrics comes with unmatched metric types", func() {
BeforeEach(func() {
rateLimiter.ExceedsLimitReturns(false)
credentials = &models.Credential{}
credentials.Username = "$2a$10$YnQNQYcvl/Q2BKtThOKFZ.KB0nTIZwhKr5q1pWTTwC/PUAHsbcpFu"
credentials.Password = "$2a$10$6nZ73cm7IV26wxRnmm5E1.nbk9G.0a4MrbzBFPChkm5fPftsUwj9G"
Expand Down Expand Up @@ -192,6 +187,9 @@ var _ = Describe("CustomMetrics Server", func() {
resp, err = client.Do(req)
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
rateLimiter.ExceedsLimitReturns(false)
})

It("returns status code 429", func() {
Expect(err).NotTo(HaveOccurred())
Expand All @@ -200,4 +198,4 @@ var _ = Describe("CustomMetrics Server", func() {
})
})

})
})

0 comments on commit d21bcb7

Please sign in to comment.