Cumulative improvements for CI troubleshooting (#2996)

* feat: show more error information in zb output

Signed-off-by: Andrei Aaron <aaaron@luxoft.com>

* chore(ci): gc stress tests to save logs as artifacts

Signed-off-by: Andrei Aaron <aaaron@luxoft.com>

* chore: add benchmark results to job summaries

Signed-off-by: Andrei Aaron <aaaron@luxoft.com>

* fix: count and show zb errors

Signed-off-by: Andrei Aaron <aaaron@luxoft.com>

* ci: fix the flaky coverage of the redis logger

Signed-off-by: Andrei Aaron <aaaron@luxoft.com>

---------

Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
This commit is contained in:
Andrei Aaron
2025-03-01 01:04:09 +02:00
committed by GitHub
parent 3893eec714
commit 983dc7f8d5
7 changed files with 110 additions and 27 deletions
+5 -5
View File
@@ -16,16 +16,16 @@ import (
var once sync.Once //nolint: gochecknoglobals // redis.SetLogger modifies an unprotected global variable
type redisLogger struct {
log log.Logger
type RedisLogger struct {
Log log.Logger
}
func (r redisLogger) Printf(ctx context.Context, format string, v ...interface{}) {
r.log.Debug().Msgf(format, v...)
func (r RedisLogger) Printf(ctx context.Context, format string, v ...interface{}) {
r.Log.Debug().Msgf(format, v...)
}
func GetRedisClient(redisConfig map[string]interface{}, log log.Logger) (redis.UniversalClient, error) {
once.Do(func() { redis.SetLogger(redisLogger{log}) }) // call redis.SetLogger only once
once.Do(func() { redis.SetLogger(RedisLogger{log}) }) // call redis.SetLogger only once
// go-redis supports connecting via the redis uri specification (more convenient than parameter parsing)
// Note failover/Sentinel cannot be configured via URL parsing at the moment
+21
View File
@@ -1,6 +1,8 @@
package rediscfg_test
import (
"context"
"io"
"os"
"path"
"testing"
@@ -15,6 +17,25 @@ import (
"zotregistry.dev/zot/pkg/log"
)
func TestRedisLogger(t *testing.T) {
Convey("Print using Redis logger", t, func() {
logFile, err := os.CreateTemp(t.TempDir(), "zot-log*.txt")
So(err, ShouldBeNil)
logger := log.NewLogger("debug", logFile.Name())
writers := io.MultiWriter(os.Stdout, logFile)
logger.Logger = logger.Output(writers)
rlog := rediscfg.RedisLogger{logger}
rlog.Printf(context.Background(), "this is a rest string")
content, err := os.ReadFile(logFile.Name())
So(err, ShouldBeNil)
So(string(content), ShouldContainSubstring, "this is a rest string")
})
}
func TestRedisOptions(t *testing.T) {
Convey("Test redis initialization", t, func() {
log := log.NewLogger("debug", "")