* Add an integration test to reproduce #2892 * Fix go compilation * Fix docker run cmd * Fixing entrypoint * Test warmer with cache in a volume. * Add missing comma * Fix imports * Fix dir * Add logs * fix * Use test framework to log * Fix warmer failing if image already in cache. * Fix format.
This commit is contained in:
parent
60aa11e0a6
commit
df488dac40
|
|
@ -28,6 +28,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -636,6 +637,36 @@ func TestCache(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Attempt to warm an image two times : first time should populate the cache, second time should find the image in the cache.
|
||||
func TestWarmerTwice(t *testing.T) {
|
||||
_, ex, _, _ := runtime.Caller(0)
|
||||
cwd := filepath.Dir(ex) + "/tmpCache"
|
||||
|
||||
// Start a sleeping warmer container
|
||||
dockerRunFlags := []string{"run", "--net=host"}
|
||||
dockerRunFlags = addServiceAccountFlags(dockerRunFlags, config.serviceAccount)
|
||||
dockerRunFlags = append(dockerRunFlags,
|
||||
"--memory=16m",
|
||||
"-v", cwd+":/cache",
|
||||
WarmerImage,
|
||||
"--cache-dir=/cache",
|
||||
"-i", "debian:trixie-slim")
|
||||
|
||||
warmCmd := exec.Command("docker", dockerRunFlags...)
|
||||
out, err := RunCommandWithoutTest(warmCmd)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to perform first warming: %s", err)
|
||||
}
|
||||
t.Logf("First warm output: %s", out)
|
||||
|
||||
warmCmd = exec.Command("docker", dockerRunFlags...)
|
||||
out, err = RunCommandWithoutTest(warmCmd)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to perform second warming: %s", err)
|
||||
}
|
||||
t.Logf("Second warm output: %s", out)
|
||||
}
|
||||
|
||||
func verifyBuildWith(t *testing.T, cache, dockerfile string) {
|
||||
args := []string{}
|
||||
if strings.HasPrefix(dockerfile, "Dockerfile_test_cache_copy") {
|
||||
|
|
|
|||
|
|
@ -97,10 +97,11 @@ func warmToFile(cacheDir, img string, opts *config.WarmerOptions) error {
|
|||
|
||||
digest, err := cw.Warm(img, opts)
|
||||
if err != nil {
|
||||
if !IsAlreadyCached(err) {
|
||||
logrus.Warnf("Error while trying to warm image: %v %v", img, err)
|
||||
if IsAlreadyCached(err) {
|
||||
logrus.Infof("Image already in cache: %v", img)
|
||||
return nil
|
||||
}
|
||||
|
||||
logrus.Warnf("Error while trying to warm image: %v %v", img, err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue