compliance: turn off cereal-service based managers in test mode
Until we integrate cereal-service into compliance's test setup, having
these turned on means we get constant spamming of errors in the logs,
making it harder to debug problems.
@@ -166,6 +166,9 @@ func serveGrpc(ctx context.Context, db *pgdb.DB, connFactory *secureconn.Factory
s := connFactory.NewServer(tracing.GlobalServerInterceptor())
+ if os.Getenv("RUN_MODE") == "test" {
+ logrus.Warn(`Skipping project-update manager setup due to RUN_MODE env var being set to "test"`)
+ } else {
cerealProjectUpdateManager, err := createProjectUpdateCerealManager(connFactory, conf.CerealConfig.Endpoint)
if err != nil {
logrus.WithError(err).Fatal("could not create cereal manager")
@@ -177,6 +180,7 @@ func serveGrpc(ctx context.Context, db *pgdb.DB, connFactory *secureconn.Factory
if err := cerealProjectUpdateManager.Start(ctx); err != nil {
logrus.WithError(err).Fatal("could not start cereal manager")
}
+ }
// needs to be the first one, since it creates the es indices
ingest.RegisterComplianceIngesterServer(s,
@@ -195,11 +199,15 @@ func serveGrpc(ctx context.Context, db *pgdb.DB, connFactory *secureconn.Factory
version.RegisterVersionServiceServer(s, versionserver.New())
status.RegisterComplianceStatusServer(s, statusSrv)
+ if os.Getenv("RUN_MODE") == "test" {
+ logrus.Warn(`Skipping data-lifecycle setup due to RUN_MODE env var being set to "test"`)
+ } else {
purgeServer, err := setupDataLifecyclePurgeInterface(ctx, connFactory, conf, cerealManager)
if err != nil {
logrus.Fatalf("serveGrpc aborting, can't setup purge server: %s", err)
}
data_lifecycle.RegisterPurgeServer(s, purgeServer)
+ }
// Register reflection service on gRPC server.
reflection.Register(s)
@@ -429,16 +437,9 @@ func setupDataLifecyclePurgeInterface(ctx context.Context, connFactory *secureco
addr := conf.ElasticSearchSidecar.Address
logrus.WithField("address", addr).Info("Connecting to Elasticsearch Sidecar")
- dialOpts := []grpc.DialOption{}
-
- if os.Getenv("RUN_MODE") == "test" {
- logrus.Info(`RUN_MODE is set to "test", not requiring block dial to es-sidecar-service`)
- } else {
- dialOpts = append(dialOpts, grpc.WithBlock())
- }
esSidecarConn, err = connFactory.DialContext(timeoutCtx, "es-sidecar-service",
- addr, dialOpts...)
+ addr, grpc.WithBlock())
if err != nil || esSidecarConn == nil {
logrus.WithFields(logrus.Fields{"error": err}).Fatal("Failed to create ES Sidecar connection")
return nil, err
