MCPcopy Index your code
hub / github.com/coder/envbox / RunEnvbox

Function RunEnvbox

integration/integrationtest/docker.go:86–124  ·  view source on GitHub ↗

RunEnvbox runs envbox, it returns once the inner container has finished spinning up.

(t *testing.T, pool *dockertest.Pool, conf *CreateDockerCVMConfig)

Source from the content-addressed store, hash-verified

84// RunEnvbox runs envbox, it returns once the inner container has finished
85// spinning up.
86func RunEnvbox(t *testing.T, pool *dockertest.Pool, conf *CreateDockerCVMConfig) *dockertest.Resource {
87 t.Helper()
88
89 conf.validate(t)
90
91 // If binds aren't passed then we'll just create the minimum amount.
92 // If someone is passing them we'll assume they know what they're doing.
93 if conf.OuterMounts == nil {
94 tmpdir := TmpDir(t)
95 conf.OuterMounts = DefaultBinds(t, tmpdir)
96 }
97
98 conf.Envs = append(conf.Envs, cmdLineEnvs(conf)...)
99
100 resource, err := pool.RunWithOptions(&dockertest.RunOptions{
101 Repository: "envbox",
102 Tag: "latest",
103 Entrypoint: []string{"/envbox", "docker"},
104 Env: conf.Envs,
105 }, func(host *docker.HostConfig) {
106 host.Mounts = conf.OuterMounts
107 host.Privileged = true
108 host.CPUPeriod = int64(dockerutil.DefaultCPUPeriod)
109 host.CPUQuota = int64(conf.CPUs) * int64(dockerutil.DefaultCPUPeriod)
110 host.ExtraHosts = []string{"host.docker.internal:host-gateway"}
111 })
112 require.NoError(t, err)
113
114 t.Cleanup(func() {
115 if !t.Failed() {
116 _ = pool.Purge(resource)
117 }
118 })
119
120 success := waitForCVM(t, pool, resource)
121 require.Equal(t, !conf.ExpectFailure, success, "expected success=%v but detected %v", !conf.ExpectFailure, success)
122
123 return resource
124}
125
126// DefaultBinds returns the minimum amount of mounts necessary to spawn
127// envbox successfully. Since envbox will chown some of these directories

Callers 1

TestDockerFunction · 0.92

Calls 5

TmpDirFunction · 0.85
DefaultBindsFunction · 0.85
cmdLineEnvsFunction · 0.85
waitForCVMFunction · 0.85
validateMethod · 0.80

Tested by 1

TestDockerFunction · 0.74