Skip to content

Commit

Permalink
fix: update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ravisuhag committed Jul 1, 2023
1 parent 02d816d commit 9c98299
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
13 changes: 8 additions & 5 deletions test/e2e_test/cortex_alerting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ type CortexAlertingTestSuite struct {
}

func (s *CortexAlertingTestSuite) SetupTest() {
apiPort, err := getFreePort()
httpPort, err := getFreePort()
s.Require().Nil(err)

grpcPort, err := getFreePort()
s.Require().Nil(err)

s.appConfig = &config.Config{}
Expand All @@ -46,9 +49,9 @@ func (s *CortexAlertingTestSuite) SetupTest() {

s.appConfig.Log.Level = "error"
s.appConfig.Service = server.Config{
Port: apiPort,
Port: httpPort,
GRPC: server.GRPCConfig{
Port: 8081,
Port: grpcPort,
},
EncryptionKey: testEncryptionKey,
}
Expand All @@ -69,7 +72,7 @@ func (s *CortexAlertingTestSuite) SetupTest() {

// setup custom cortex config
// TODO host.docker.internal only works for docker-desktop to call a service in host (siren)
s.appConfig.Providers.Cortex.WebhookBaseAPI = fmt.Sprintf("http://test:%d/v1beta1/alerts/cortex", apiPort)
s.appConfig.Providers.Cortex.WebhookBaseAPI = fmt.Sprintf("http://test:%d/v1beta1/alerts/cortex", httpPort)
s.appConfig.Providers.Cortex.GroupWaitDuration = "1s"
s.appConfig.Providers.Cortex.GroupIntervalDuration = "1s"
s.appConfig.Providers.Cortex.RepeatIntervalDuration = "1s"
Expand All @@ -81,7 +84,7 @@ func (s *CortexAlertingTestSuite) SetupTest() {
StartSirenServer(*s.appConfig)

ctx := context.Background()
s.client, s.cancelClient, err = CreateClient(ctx, fmt.Sprintf("localhost:%d", apiPort))
s.client, s.cancelClient, err = CreateClient(ctx, fmt.Sprintf("localhost:%d", grpcPort))
s.Require().NoError(err)

_, err = s.client.CreateProvider(ctx, &sirenv1beta1.CreateProviderRequest{
Expand Down
7 changes: 5 additions & 2 deletions test/e2e_test/cortex_namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ func (s *CortexNamespaceTestSuite) SetupTest() {
apiPort, err := getFreePort()
s.Require().Nil(err)

grpcPort, err := getFreePort()
s.Require().Nil(err)

s.appConfig = &config.Config{}

defaults.SetDefaults(s.appConfig)
Expand All @@ -35,7 +38,7 @@ func (s *CortexNamespaceTestSuite) SetupTest() {
s.appConfig.Service = server.Config{
Port: apiPort,
GRPC: server.GRPCConfig{
Port: 8081,
Port: grpcPort,
},
EncryptionKey: testEncryptionKey,
}
Expand All @@ -59,7 +62,7 @@ func (s *CortexNamespaceTestSuite) SetupTest() {
StartSirenServer(*s.appConfig)

ctx := context.Background()
s.client, s.cancelClient, err = CreateClient(ctx, fmt.Sprintf("localhost:%d", apiPort))
s.client, s.cancelClient, err = CreateClient(ctx, fmt.Sprintf("localhost:%d", grpcPort))
s.Require().NoError(err)

_, err = s.client.CreateProvider(ctx, &sirenv1beta1.CreateProviderRequest{
Expand Down
6 changes: 5 additions & 1 deletion test/e2e_test/cortex_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ func (s *CortexRuleTestSuite) SetupTest() {
apiPort, err := getFreePort()
s.Require().Nil(err)

grpcPort, err := getFreePort()
s.Require().Nil(err)

s.appConfig = &config.Config{}

defaults.SetDefaults(s.appConfig)

s.appConfig.Log.Level = "error"
s.appConfig.Service = server.Config{
Port: apiPort,
GRPC: server.GRPCConfig{Port: grpcPort},
EncryptionKey: testEncryptionKey,
}
s.appConfig.Notification = notification.Config{
Expand All @@ -59,7 +63,7 @@ func (s *CortexRuleTestSuite) SetupTest() {
StartSirenServer(*s.appConfig)

ctx := context.Background()
s.client, s.cancelClient, err = CreateClient(ctx, fmt.Sprintf("localhost:%d", apiPort))
s.client, s.cancelClient, err = CreateClient(ctx, fmt.Sprintf("localhost:%d", grpcPort))
s.Require().NoError(err)

bootstrapCortexTestData(&s.Suite, ctx, s.client, s.testBench.NginxHost)
Expand Down
3 changes: 2 additions & 1 deletion test/e2e_test/notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (s *NotificationTestSuite) SetupTest() {

apiPort, err := getFreePort()
s.Require().Nil(err)

grpcPort, err := getFreePort()
s.Require().Nil(err)

Expand Down Expand Up @@ -77,7 +78,7 @@ func (s *NotificationTestSuite) SetupTest() {
StartSirenMessageWorker(*s.appConfig, s.closeWorkerChannel)

ctx := context.Background()
s.client, s.cancelClient, err = CreateClient(ctx, fmt.Sprintf("localhost:%d", apiPort))
s.client, s.cancelClient, err = CreateClient(ctx, fmt.Sprintf("localhost:%d", grpcPort))
s.Require().NoError(err)

bootstrapCortexTestData(&s.Suite, ctx, s.client, s.testBench.NginxHost)
Expand Down

0 comments on commit 9c98299

Please sign in to comment.