mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 20:38:08 +08:00
test: stop task scheduler between test runs (#1311)
sync: remove sync WaitGroup, it's stopped with context sync: onDemand will always try to sync newest image when a tag is used if a digest is used then onDemand will serve local image test(sync): fix flaky coverage in sync package closes #1294 Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
@@ -5,7 +5,6 @@ package extensions
|
||||
|
||||
import (
|
||||
"context"
|
||||
goSync "sync"
|
||||
|
||||
"zotregistry.io/zot/pkg/api/config"
|
||||
"zotregistry.io/zot/pkg/extensions/sync"
|
||||
@@ -14,11 +13,11 @@ import (
|
||||
"zotregistry.io/zot/pkg/storage"
|
||||
)
|
||||
|
||||
func EnableSyncExtension(ctx context.Context, config *config.Config, wg *goSync.WaitGroup,
|
||||
func EnableSyncExtension(ctx context.Context, config *config.Config,
|
||||
repoDB repodb.RepoDB, storeController storage.StoreController, log log.Logger,
|
||||
) {
|
||||
if config.Extensions.Sync != nil && *config.Extensions.Sync.Enable {
|
||||
if err := sync.Run(ctx, *config.Extensions.Sync, repoDB, storeController, wg, log); err != nil {
|
||||
if err := sync.Run(ctx, *config.Extensions.Sync, repoDB, storeController, log); err != nil {
|
||||
log.Error().Err(err).Msg("Error encountered while setting up syncing")
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -5,7 +5,6 @@ package extensions
|
||||
|
||||
import (
|
||||
"context"
|
||||
goSync "sync"
|
||||
|
||||
"zotregistry.io/zot/pkg/api/config"
|
||||
"zotregistry.io/zot/pkg/log"
|
||||
@@ -14,8 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// EnableSyncExtension ...
|
||||
func EnableSyncExtension(ctx context.Context,
|
||||
config *config.Config, wg *goSync.WaitGroup, repoDB repodb.RepoDB,
|
||||
func EnableSyncExtension(ctx context.Context, config *config.Config, repoDB repodb.RepoDB,
|
||||
storeController storage.StoreController, log log.Logger,
|
||||
) {
|
||||
log.Warn().Msg("skipping enabling sync extension because given zot binary doesn't include this feature," +
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
goSync "sync"
|
||||
"time"
|
||||
|
||||
"github.com/containers/common/pkg/retry"
|
||||
@@ -325,7 +324,7 @@ func getLocalContexts(log log.Logger) (*types.SystemContext, *signature.PolicyCo
|
||||
}
|
||||
|
||||
func Run(ctx context.Context, cfg syncconf.Config, repoDB repodb.RepoDB,
|
||||
storeController storage.StoreController, wtgrp *goSync.WaitGroup, logger log.Logger,
|
||||
storeController storage.StoreController, logger log.Logger,
|
||||
) error {
|
||||
var credentialsFile syncconf.CredentialsFile
|
||||
|
||||
@@ -376,9 +375,6 @@ func Run(ctx context.Context, cfg syncconf.Config, repoDB repodb.RepoDB,
|
||||
// schedule each registry sync
|
||||
go func(ctx context.Context, regCfg syncconf.RegistryConfig, logger log.Logger) {
|
||||
for {
|
||||
// increment reference since will be busy, so shutdown has to wait
|
||||
wtgrp.Add(1)
|
||||
|
||||
for _, upstreamURL := range regCfg.URLs {
|
||||
upstreamAddr := StripRegistryTransport(upstreamURL)
|
||||
// first try syncing main registry
|
||||
@@ -392,8 +388,6 @@ func Run(ctx context.Context, cfg syncconf.Config, repoDB repodb.RepoDB,
|
||||
break
|
||||
}
|
||||
}
|
||||
// mark as done after a single sync run
|
||||
wtgrp.Done()
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
goSync "sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -156,8 +155,7 @@ func TestSyncInternal(t *testing.T) {
|
||||
}
|
||||
ctx := context.Background()
|
||||
|
||||
So(Run(ctx, cfg, mocks.RepoDBMock{}, storage.StoreController{},
|
||||
new(goSync.WaitGroup), log.NewLogger("debug", "")), ShouldNotBeNil)
|
||||
So(Run(ctx, cfg, mocks.RepoDBMock{}, storage.StoreController{}, log.NewLogger("debug", "")), ShouldNotBeNil)
|
||||
|
||||
_, err = getFileCredentials("/invalid/path/to/file")
|
||||
So(err, ShouldNotBeNil)
|
||||
|
||||
+467
-462
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user