mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
ada21ed842
Files were added to be built whether an extension is on or off. New build tags were added for each extension, while minimal and extended disappeared. added custom binary naming depending on extensions used and changed references from binary to binary-extended added automated blackbox tests for sync, search, scrub, metrics added contributor guidelines Signed-off-by: Alex Stan <alexandrustan96@yahoo.ro>
71 lines
1.7 KiB
Go
71 lines
1.7 KiB
Go
//go:build !sync
|
|
// +build !sync
|
|
|
|
package sync_test
|
|
|
|
import (
|
|
"context"
|
|
"io/ioutil"
|
|
"os"
|
|
"testing"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
"gopkg.in/resty.v1"
|
|
"zotregistry.io/zot/pkg/api"
|
|
"zotregistry.io/zot/pkg/api/config"
|
|
extconf "zotregistry.io/zot/pkg/extensions/config"
|
|
"zotregistry.io/zot/pkg/extensions/sync"
|
|
"zotregistry.io/zot/pkg/test"
|
|
)
|
|
|
|
func TestSyncExtension(t *testing.T) {
|
|
Convey("Make a new controller", t, func() {
|
|
conf := config.New()
|
|
port := test.GetFreePort()
|
|
|
|
baseURL := test.GetBaseURL(port)
|
|
globalDir := t.TempDir()
|
|
defaultValue := true
|
|
|
|
logFile, err := ioutil.TempFile(globalDir, "zot-log*.txt")
|
|
So(err, ShouldBeNil)
|
|
defer os.Remove(logFile.Name())
|
|
|
|
conf.HTTP.Port = port
|
|
conf.Storage.RootDirectory = globalDir
|
|
conf.Storage.Commit = true
|
|
conf.Extensions = &extconf.ExtensionConfig{}
|
|
conf.Extensions.Sync = &sync.Config{
|
|
Enable: &defaultValue,
|
|
}
|
|
conf.Log.Level = "warn"
|
|
conf.Log.Output = logFile.Name()
|
|
|
|
ctlr := api.NewController(conf)
|
|
|
|
go func() {
|
|
if err := ctlr.Run(context.Background()); err != nil {
|
|
return
|
|
}
|
|
}()
|
|
|
|
defer func() {
|
|
_ = ctlr.Server.Shutdown(context.Background())
|
|
}()
|
|
test.WaitTillServerReady(baseURL)
|
|
|
|
Convey("verify sync is skipped when binary doesn't include it", func() {
|
|
resp, err := resty.R().
|
|
Head(baseURL + "/v2/" + "invalid" + "/manifests/invalid:0.0.2")
|
|
So(err, ShouldBeNil)
|
|
So(resp, ShouldNotBeNil)
|
|
|
|
data, err := os.ReadFile(logFile.Name())
|
|
So(err, ShouldBeNil)
|
|
|
|
So(string(data), ShouldContainSubstring,
|
|
"skipping syncing on demand because given zot binary doesn't include "+
|
|
"this feature,please build a binary that does so")
|
|
})
|
|
})
|
|
}
|