4
4
package vm
5
5
6
6
import (
7
+ "fmt"
7
8
"os"
8
9
"os/exec"
9
10
"path/filepath"
@@ -12,11 +13,15 @@ import (
12
13
"github.com/onsi/ginkgo/v2"
13
14
"github.com/onsi/gomega"
14
15
"github.com/runfinch/common-tests/command"
16
+ "github.com/runfinch/common-tests/ffs"
17
+ "github.com/runfinch/common-tests/fnet"
15
18
"github.com/runfinch/common-tests/option"
16
19
)
17
20
18
21
const (
19
22
ffmpegSociImage = "public.ecr.aws/soci-workshop-examples/ffmpeg:latest"
23
+ registryImage = "public.ecr.aws/docker/library/registry:latest"
24
+ ubuntuImage = "public.ecr.aws/docker/library/ubuntu:23.10"
20
25
sociMountString = "fuse.rawBridge"
21
26
)
22
27
@@ -25,6 +30,7 @@ var testSoci = func(o *option.Option, installed bool) {
25
30
var limactlO * option.Option
26
31
var fpath , realFinchPath , limactlPath , limaHomePathEnv , wd string
27
32
var err error
33
+ var port int
28
34
29
35
ginkgo .BeforeEach (func () {
30
36
// Find lima paths. limactl is used to shell into the Finch VM and verify
@@ -54,7 +60,7 @@ var testSoci = func(o *option.Option, installed bool) {
54
60
writeFile (finchConfigFilePath , []byte ("cpus: 6\n memory: 4GiB\n snapshotters:\n " +
55
61
"- soci\n vmType: qemu\n rosetta: false" ))
56
62
command .New (o , virtualMachineRootCmd , "init" ).WithTimeoutInSeconds (600 ).Run ()
57
- command .New (o , "pull" , ffmpegSociImage ).WithTimeoutInSeconds (30 ).Run ()
63
+ command .New (o , "pull" , "--snapshotter=soci" , ffmpegSociImage ).WithTimeoutInSeconds (30 ).Run ()
58
64
finchPullMounts := countMounts (limactlO )
59
65
command .Run (o , "rmi" , "-f" , ffmpegSociImage )
60
66
command .New (limactlO , "shell" , "finch" ,
@@ -70,7 +76,7 @@ var testSoci = func(o *option.Option, installed bool) {
70
76
writeFile (finchConfigFilePath , []byte ("cpus: 6\n memory: 4GiB\n snapshotters:\n " +
71
77
"- soci\n vmType: qemu\n rosetta: false" ))
72
78
command .New (o , virtualMachineRootCmd , "init" ).WithTimeoutInSeconds (600 ).Run ()
73
- command .New (o , "run" , ffmpegSociImage ).WithTimeoutInSeconds (30 ).Run ()
79
+ command .New (o , "run" , "--snapshotter=soci" , ffmpegSociImage ).WithTimeoutInSeconds (30 ).Run ()
74
80
finchPullMounts := countMounts (limactlO )
75
81
command .Run (o , "rmi" , "-f" , ffmpegSociImage )
76
82
command .New (limactlO , "shell" , "finch" ,
@@ -79,6 +85,28 @@ var testSoci = func(o *option.Option, installed bool) {
79
85
command .Run (o , "rmi" , "-f" , ffmpegSociImage )
80
86
gomega .Expect (finchPullMounts ).Should (gomega .Equal (nerdctlPullMounts ))
81
87
})
88
+ ginkgo .It ("finch push should work" , func () {
89
+ resetVM (o , installed )
90
+ resetDisks (o , installed )
91
+ writeFile (finchConfigFilePath , []byte ("cpus: 6\n memory: 4GiB\n snapshotters:\n " +
92
+ "- soci\n vmType: qemu\n rosetta: false" ))
93
+ command .New (o , virtualMachineRootCmd , "init" ).WithTimeoutInSeconds (600 ).Run ()
94
+ port = fnet .GetFreePort ()
95
+ command .New (o , "run" , "-dp" , fmt .Sprintf ("%d:5000" , port ), "--name" , "registry" , registryImage ).
96
+ WithTimeoutInSeconds (30 ).Run ()
97
+ buildContext := ffs .CreateBuildContext (fmt .Sprintf (`FROM %s
98
+ CMD ["echo", "bar"]
99
+ ` , ubuntuImage ))
100
+ ginkgo .DeferCleanup (os .RemoveAll , buildContext )
101
+ targetTag := fmt .Sprintf (`localhost:%d/test-push-soci:tag` , port )
102
+ command .New (o , "build" , "-t" , targetTag , buildContext ).WithTimeoutInSeconds (30 ).Run ()
103
+ testSociSpanSize := 2097152 // 2MiB
104
+ testSociMinLayerSize := 20971520 // 20MiB
105
+ command .New (o , "push" , "--insecure-registry" , "--snapshotter=soci" , fmt .Sprintf ("--soci-span-size=%d" , testSociSpanSize ),
106
+ fmt .Sprintf ("--soci-min-layer-size=%d" , testSociMinLayerSize ), targetTag ).WithTimeoutInSeconds (30 ).Run ()
107
+ indexOutput := command .StdoutStr (limactlO , "shell" , "finch" , "sudo" , "soci" , "index" , "list" )
108
+ gomega .Expect (indexOutput ).Should (gomega .ContainSubstring (targetTag ))
109
+ })
82
110
})
83
111
}
84
112
0 commit comments