MCPcopy Index your code
hub / github.com/dagger/dagger / testContainer

Method testContainer

toolchains/engine-dev/test.go:242–324  ·  view source on GitHub ↗

Build an ephemeral test environment ready to run core engine tests Also return the URL of a pprof debug endpoint, to dump profiling data from the tested engine (FIXME: do this more cleanly, and reuse the standard Go toolchain)

(ctx context.Context, ebpfProgs []string)

Source from the content-addressed store, hash-verified

240// Also return the URL of a pprof debug endpoint, to dump profiling data from the tested engine
241// (FIXME: do this more cleanly, and reuse the standard Go toolchain)
242func (dev *EngineDev) testContainer(ctx context.Context, ebpfProgs []string) (*dagger.Container, string, error) {
243 devEngine, err := dev.
244 WithEBPFProgs(ebpfProgs).
245 WithEngineConfig(`registry."registry:5000"`, `http = true`).
246 WithEngineConfig(`registry."privateregistry:5000"`, `http = true`).
247 WithEngineConfig(`registry."docker.io"`, `mirrors = ["mirror.gcr.io"]`).
248 Container(
249 ctx,
250 "", // platform
251 false, // gpuSupport
252 "", // version
253 "", // tag
254 )
255 if err != nil {
256 return nil, "", err
257 }
258
259 // TODO: mitigation for https://github.com/dagger/dagger/issues/8031
260 // during our test suite
261 devEngine = devEngine.
262 WithEnvVariable("_DAGGER_ENGINE_SYSTEMENV_GODEBUG", "goindex=0")
263
264 devBinary := dag.DaggerCli().Binary()
265 // This creates an engine.tar container file that can be used by the integration tests.
266 // In particular, it is used by core/integration/remotecache_test.go to create a
267 // dev engine that can be used to test remote caching.
268 // I also load the dagger binary, so that the remote cache tests can use it to
269 // run dagger queries.
270
271 // These are used by core/integration/remotecache_test.go
272 testEngineUtils := dag.Directory().
273 WithFile("engine.tar", devEngine.AsTarball()).
274 WithFile("dagger", devBinary, dagger.DirectoryWithFileOpts{
275 Permissions: 0755,
276 })
277
278 engineRunVol := dag.CacheVolume("dagger-dev-engine-test-varrun" + rand.Text())
279 registrySvc := registry()
280 devEngineSvc := devEngine.
281 WithServiceBinding("registry", registrySvc).
282 WithServiceBinding("privateregistry", privateRegistry()).
283 WithExposedPort(1234, dagger.ContainerWithExposedPortOpts{Protocol: dagger.NetworkProtocolTcp}).
284 WithMountedCache(distconsts.EngineDefaultStateDir, dag.CacheVolume("dagger-dev-engine-test-state"+rand.Text())).
285 WithMountedCache("/run", engineRunVol).
286 AsService(dagger.ContainerAsServiceOpts{
287 Args: []string{
288 "--addr", "unix:///run/dagger-engine.sock",
289 "--addr", "tcp://0.0.0.0:1234",
290 "--network-name", "dagger-dev",
291 "--network-cidr", "10.88.0.0/16",
292 "--debugaddr", "0.0.0.0:6060",
293 },
294 UseEntrypoint: true,
295 InsecureRootCapabilities: true,
296 })
297
298 // manually starting service to ensure it's not reaped between benchmark prewarm & run
299 // FIXME: just persist the dev engine into a field of the object... cleaner

Callers 5

TestMethod · 0.95
TestTelemetryMethod · 0.95
benchDumpMethod · 0.95
benchMethod · 0.95
TestDumpMethod · 0.95

Calls 15

WithEBPFProgsMethod · 0.95
InstallClientMethod · 0.95
registryFunction · 0.85
privateRegistryFunction · 0.85
DirectoryMethod · 0.65
StartMethod · 0.65
ContainerMethod · 0.45
WithEngineConfigMethod · 0.45
WithEnvVariableMethod · 0.45
BinaryMethod · 0.45
DaggerCliMethod · 0.45
WithFileMethod · 0.45

Tested by

no test coverage detected