Skip to content

Commit

Permalink
go reports-service: Return from kafka subscription when context is ca…
Browse files Browse the repository at this point in the history
…nceled
  • Loading branch information
XxRoloxX committed Nov 28, 2024
1 parent f7b3caa commit d10aaed
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion go/docker/logs_ingestion/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

FROM build AS tests

RUN echo "go env -w GOCACHE=/go/pkg/mod/ && go test -v ./services/logs_ingestion/..." > test.sh
RUN echo "go env -w GOCACHE=/go/pkg/mod/ && go test ./services/logs_ingestion/..." > test.sh
RUN chmod +x test.sh

ENTRYPOINT ["bash", "./test.sh"]
Expand Down
2 changes: 1 addition & 1 deletion go/docker/reports/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN --mount=type=cache,target=/go/pkg/mod/ \

FROM build AS tests

RUN echo "go env -w GOCACHE=/go/pkg/mod/ && go test ./services/reports/..." > test.sh
RUN echo "go env -w GOCACHE=/go/pkg/mod/ && go test -count=1 ./services/reports/..." > test.sh
RUN chmod +x test.sh

ENTRYPOINT ["bash", "./test.sh"]
Expand Down
2 changes: 1 addition & 1 deletion go/pkg/message-broker/json_kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (b *KafkaJsonMessageBroker[T]) Subscribe(ctx context.Context, messages chan

case <-ctx.Done():
b.logger.Info("KafkaJsonMessageBroker conext was cancelled")
break
return
}

}
Expand Down
1 change: 0 additions & 1 deletion go/pkg/repositories/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func PrefillApplicationLogs(

for index := range indexes {
applicationLogsRepository.RemoveIndex(ctx, index)
// assert.NoError(t, err, "Failed to remove index")
}

insertedLogsIds := make([]string, 0, 0)
Expand Down
2 changes: 0 additions & 2 deletions go/pkg/tests/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ func RunTest[T any](test func(dependencies T), t *testing.T, appModule fx.Option
)

app.Start(context.Background())
// app.RequireStart()
// app.RequireStop()
app.Stop(context.Background())
}
10 changes: 0 additions & 10 deletions go/services/reports/pkg/config/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"github.com/Magpie-Monitor/magpie-monitor/pkg/elasticsearch"
sharedrepositories "github.com/Magpie-Monitor/magpie-monitor/pkg/repositories"
// "github.com/Magpie-Monitor/magpie-monitor/pkg/routing"
"github.com/Magpie-Monitor/magpie-monitor/pkg/tests"
"github.com/Magpie-Monitor/magpie-monitor/services/reports/internal/brokers"
"github.com/Magpie-Monitor/magpie-monitor/services/reports/internal/database"
Expand Down Expand Up @@ -33,13 +32,9 @@ func init() {
}),
fx.Provide(

// routing.NewRootRouter,
services.NewReportsService,
// handlers.NewReportsRouter,
handlers.NewReportsHandler,

// handlers.NewIncidentsRouter,
// handlers.NewIncidentHandler,
services.NewNodeIncidentsService,
services.NewApplicationIncidentsService,

Expand Down Expand Up @@ -113,14 +108,9 @@ func init() {
}),
fx.Provide(

// insights.NewOpenAiInsightsGenerator,
// routing.NewRootRouter,
services.NewReportsService,
// handlers.NewReportsRouter,
handlers.NewReportsHandler,

// handlers.NewIncidentsRouter,
// handlers.NewIncidentHandler,
services.NewNodeIncidentsService,
services.NewApplicationIncidentsService,

Expand Down
2 changes: 1 addition & 1 deletion go/services/reports/pkg/openai/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestClientSplitCompletionReqestsByBatchSize(t *testing.T) {
dependencies.Client.BatchSizeBytes = tc.batchSizeBytes
splitted, err := dependencies.Client.SplitCompletionReqestsByBatchSize(tc.completionRequests)
assert.NoError(t, err, "Failed to split completion requests")
assert.Equal(t, tc.expectedSplittedCompletionRequests, splitted)
assert.ElementsMatch(t, tc.expectedSplittedCompletionRequests, splitted)

}
}
Expand Down

0 comments on commit d10aaed

Please sign in to comment.