blob: 1dd82809f8a33518330063c4dc87f324b1146d77 [file] [log] [blame]
Adrian Villin4677d922024-06-14 09:32:39 +02001package hst
Maros Ondrejicka11a03e92022-12-01 09:56:37 +01002
3import (
4 "fmt"
Maros Ondrejickadb823ed2022-12-14 16:30:04 +01005 "os"
Maros Ondrejickaffa3f602023-01-26 10:07:29 +01006 "os/exec"
Maros Ondrejickadb823ed2022-12-14 16:30:04 +01007 "strings"
Maros Ondrejicka85396a52023-02-28 12:49:43 +01008 "text/template"
Filip Tehlar4fa0ba62023-12-06 11:35:11 +01009 "time"
Maros Ondrejicka11a03e92022-12-01 09:56:37 +010010
11 "github.com/edwarnicke/exechelper"
Adrian Villincee15aa2024-03-14 11:42:55 -040012 . "github.com/onsi/ginkgo/v2"
Maros Ondrejicka11a03e92022-12-01 09:56:37 +010013)
14
Maros Ondrejickaa2d52622023-02-24 11:26:39 +010015const (
Filip Tehlara1bd50c2024-01-24 11:59:44 +010016 logDir string = "/tmp/hs-test/"
17 volumeDir string = "/volumes"
Maros Ondrejickaa2d52622023-02-24 11:26:39 +010018)
19
Maros Ondrejicka7550dd22023-02-07 20:40:27 +010020var (
21 workDir, _ = os.Getwd()
22)
23
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010024type Volume struct {
Adrian Villin4677d922024-06-14 09:32:39 +020025 HostDir string
26 ContainerDir string
27 IsDefaultWorkDir bool
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +010028}
29
30type Container struct {
Adrian Villin4677d922024-06-14 09:32:39 +020031 Suite *HstSuite
32 IsOptional bool
33 RunDetached bool
34 Name string
35 Image string
36 ExtraRunningArgs string
37 Volumes map[string]Volume
38 EnvVars map[string]string
39 VppInstance *VppInstance
40 AllocatedCpus []int
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010041}
42
Adrian Villincee15aa2024-03-14 11:42:55 -040043func newContainer(suite *HstSuite, yamlInput ContainerConfig) (*Container, error) {
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010044 containerName := yamlInput["name"].(string)
45 if len(containerName) == 0 {
46 err := fmt.Errorf("container name must not be blank")
47 return nil, err
48 }
49
50 var container = new(Container)
Adrian Villin4677d922024-06-14 09:32:39 +020051 container.Volumes = make(map[string]Volume)
52 container.EnvVars = make(map[string]string)
53 container.Name = containerName
54 container.Suite = suite
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010055
Adrian Villin4677d922024-06-14 09:32:39 +020056 if Image, ok := yamlInput["image"]; ok {
57 container.Image = Image.(string)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010058 } else {
Adrian Villin4677d922024-06-14 09:32:39 +020059 container.Image = "hs-test/vpp"
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010060 }
61
Filip Tehlar3f951432023-01-13 21:33:43 +010062 if args, ok := yamlInput["extra-args"]; ok {
Adrian Villin4677d922024-06-14 09:32:39 +020063 container.ExtraRunningArgs = args.(string)
Filip Tehlar3f951432023-01-13 21:33:43 +010064 } else {
Adrian Villin4677d922024-06-14 09:32:39 +020065 container.ExtraRunningArgs = ""
Filip Tehlar3f951432023-01-13 21:33:43 +010066 }
67
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010068 if isOptional, ok := yamlInput["is-optional"]; ok {
Adrian Villin4677d922024-06-14 09:32:39 +020069 container.IsOptional = isOptional.(bool)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010070 } else {
Adrian Villin4677d922024-06-14 09:32:39 +020071 container.IsOptional = false
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010072 }
73
Filip Tehlarb41b0af2023-03-20 12:39:20 +010074 if runDetached, ok := yamlInput["run-detached"]; ok {
Adrian Villin4677d922024-06-14 09:32:39 +020075 container.RunDetached = runDetached.(bool)
Filip Tehlarb41b0af2023-03-20 12:39:20 +010076 } else {
Adrian Villin4677d922024-06-14 09:32:39 +020077 container.RunDetached = true
Filip Tehlarb41b0af2023-03-20 12:39:20 +010078 }
79
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010080 if _, ok := yamlInput["volumes"]; ok {
Adrian Villin4677d922024-06-14 09:32:39 +020081 workingVolumeDir := logDir + suite.GetCurrentTestName() + volumeDir
Filip Tehlara1bd50c2024-01-24 11:59:44 +010082 workDirReplacer := strings.NewReplacer("$HST_DIR", workDir)
83 volDirReplacer := strings.NewReplacer("$HST_VOLUME_DIR", workingVolumeDir)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010084 for _, volu := range yamlInput["volumes"].([]interface{}) {
85 volumeMap := volu.(ContainerConfig)
Filip Tehlara1bd50c2024-01-24 11:59:44 +010086 hostDir := workDirReplacer.Replace(volumeMap["host-dir"].(string))
87 hostDir = volDirReplacer.Replace(hostDir)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010088 containerDir := volumeMap["container-dir"].(string)
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010089 isDefaultWorkDir := false
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010090
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010091 if isDefault, ok := volumeMap["is-default-work-dir"]; ok {
92 isDefaultWorkDir = isDefault.(bool)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010093 }
Maros Ondrejickaffa3f602023-01-26 10:07:29 +010094 container.addVolume(hostDir, containerDir, isDefaultWorkDir)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010095 }
96 }
97
98 if _, ok := yamlInput["vars"]; ok {
99 for _, envVar := range yamlInput["vars"].([]interface{}) {
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100100 envVarMap := envVar.(ContainerConfig)
101 name := envVarMap["name"].(string)
102 value := envVarMap["value"].(string)
Adrian Villin4677d922024-06-14 09:32:39 +0200103 container.AddEnvVar(name, value)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +0100104 }
105 }
106 return container, nil
Maros Ondrejicka11a03e92022-12-01 09:56:37 +0100107}
108
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100109func (c *Container) getWorkDirVolume() (res Volume, exists bool) {
Adrian Villin4677d922024-06-14 09:32:39 +0200110 for _, v := range c.Volumes {
111 if v.IsDefaultWorkDir {
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100112 res = v
113 exists = true
114 return
115 }
116 }
117 return
118}
119
Adrian Villin4677d922024-06-14 09:32:39 +0200120func (c *Container) GetHostWorkDir() (res string) {
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100121 if v, ok := c.getWorkDirVolume(); ok {
Adrian Villin4677d922024-06-14 09:32:39 +0200122 res = v.HostDir
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100123 }
124 return
125}
126
Adrian Villin4677d922024-06-14 09:32:39 +0200127func (c *Container) GetContainerWorkDir() (res string) {
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100128 if v, ok := c.getWorkDirVolume(); ok {
Adrian Villin4677d922024-06-14 09:32:39 +0200129 res = v.ContainerDir
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100130 }
131 return
132}
133
Maros Ondrejickac2f76f42023-02-27 13:22:45 +0100134func (c *Container) getContainerArguments() string {
Adrian Villineaa7d912024-06-06 04:26:30 -0400135 args := "--ulimit nofile=90000:90000 --cap-add=all --privileged --network host"
136 c.allocateCpus()
Adrian Villin4677d922024-06-14 09:32:39 +0200137 args += fmt.Sprintf(" --cpuset-cpus=\"%d-%d\"", c.AllocatedCpus[0], c.AllocatedCpus[len(c.AllocatedCpus)-1])
Maros Ondrejickac2f76f42023-02-27 13:22:45 +0100138 args += c.getVolumesAsCliOption()
139 args += c.getEnvVarsAsCliOption()
Adrian Villin4677d922024-06-14 09:32:39 +0200140 if *VppSourceFileDir != "" {
141 args += fmt.Sprintf(" -v %s:%s", *VppSourceFileDir, *VppSourceFileDir)
Filip Tehlar109f3ce2023-09-05 15:36:28 +0200142 }
Adrian Villin4677d922024-06-14 09:32:39 +0200143 args += " --name " + c.Name + " " + c.Image
144 args += " " + c.ExtraRunningArgs
Maros Ondrejickac2f76f42023-02-27 13:22:45 +0100145 return args
146}
147
Filip Tehlar4fa0ba62023-12-06 11:35:11 +0100148func (c *Container) runWithRetry(cmd string) error {
149 nTries := 5
150 for i := 0; i < nTries; i++ {
151 err := exechelper.Run(cmd)
152 if err == nil {
153 return nil
154 }
155 time.Sleep(1 * time.Second)
156 }
157 return fmt.Errorf("failed to run container command")
158}
159
Adrian Villin4677d922024-06-14 09:32:39 +0200160func (c *Container) Create() error {
Maros Ondrejickac2f76f42023-02-27 13:22:45 +0100161 cmd := "docker create " + c.getContainerArguments()
Adrian Villin4677d922024-06-14 09:32:39 +0200162 c.Suite.Log(cmd)
Filip Tehlar9abba112023-03-07 10:13:19 +0100163 return exechelper.Run(cmd)
Maros Ondrejickac2f76f42023-02-27 13:22:45 +0100164}
165
Adrian Villinb9464cd2024-05-27 09:52:59 -0400166func (c *Container) allocateCpus() {
Adrian Villin4677d922024-06-14 09:32:39 +0200167 c.Suite.StartedContainers = append(c.Suite.StartedContainers, c)
168 c.AllocatedCpus = c.Suite.AllocateCpus()
169 c.Suite.Log("Allocated CPUs " + fmt.Sprint(c.AllocatedCpus) + " to container " + c.Name)
Adrian Villinb9464cd2024-05-27 09:52:59 -0400170}
171
Adrian Villin4677d922024-06-14 09:32:39 +0200172func (c *Container) Start() error {
173 cmd := "docker start " + c.Name
174 c.Suite.Log(cmd)
Filip Tehlar4fa0ba62023-12-06 11:35:11 +0100175 return c.runWithRetry(cmd)
Maros Ondrejicka87531802022-12-19 20:35:27 +0100176}
177
Filip Tehlarb41b0af2023-03-20 12:39:20 +0100178func (c *Container) prepareCommand() (string, error) {
Adrian Villin4677d922024-06-14 09:32:39 +0200179 if c.Name == "" {
Filip Tehlarb41b0af2023-03-20 12:39:20 +0100180 return "", fmt.Errorf("run container failed: name is blank")
Maros Ondrejicka87531802022-12-19 20:35:27 +0100181 }
182
Filip Tehlarb41b0af2023-03-20 12:39:20 +0100183 cmd := "docker run "
Adrian Villin4677d922024-06-14 09:32:39 +0200184 if c.RunDetached {
Adrian Villineaa7d912024-06-06 04:26:30 -0400185 cmd += " -d"
Filip Tehlarb41b0af2023-03-20 12:39:20 +0100186 }
Adrian Villinb9464cd2024-05-27 09:52:59 -0400187
Filip Tehlarb41b0af2023-03-20 12:39:20 +0100188 cmd += " " + c.getContainerArguments()
189
Adrian Villin4677d922024-06-14 09:32:39 +0200190 c.Suite.Log(cmd)
Filip Tehlarb41b0af2023-03-20 12:39:20 +0100191 return cmd, nil
192}
193
Adrian Villin4677d922024-06-14 09:32:39 +0200194func (c *Container) CombinedOutput() (string, error) {
Filip Tehlarb41b0af2023-03-20 12:39:20 +0100195 cmd, err := c.prepareCommand()
Maros Ondrejicka11a03e92022-12-01 09:56:37 +0100196 if err != nil {
Filip Tehlarb41b0af2023-03-20 12:39:20 +0100197 return "", err
Maros Ondrejicka11a03e92022-12-01 09:56:37 +0100198 }
199
Filip Tehlarb41b0af2023-03-20 12:39:20 +0100200 byteOutput, err := exechelper.CombinedOutput(cmd)
201 return string(byteOutput), err
202}
203
Adrian Villin4677d922024-06-14 09:32:39 +0200204func (c *Container) Run() error {
Filip Tehlarb41b0af2023-03-20 12:39:20 +0100205 cmd, err := c.prepareCommand()
206 if err != nil {
207 return err
208 }
Filip Tehlar4fa0ba62023-12-06 11:35:11 +0100209 return c.runWithRetry(cmd)
Maros Ondrejicka11a03e92022-12-01 09:56:37 +0100210}
211
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100212func (c *Container) addVolume(hostDir string, containerDir string, isDefaultWorkDir bool) {
Maros Ondrejickadb823ed2022-12-14 16:30:04 +0100213 var volume Volume
Adrian Villin4677d922024-06-14 09:32:39 +0200214 volume.HostDir = hostDir
215 volume.ContainerDir = containerDir
216 volume.IsDefaultWorkDir = isDefaultWorkDir
217 c.Volumes[hostDir] = volume
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +0100218}
219
Maros Ondrejickadb823ed2022-12-14 16:30:04 +0100220func (c *Container) getVolumesAsCliOption() string {
221 cliOption := ""
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +0100222
Adrian Villin4677d922024-06-14 09:32:39 +0200223 if len(c.Volumes) > 0 {
224 for _, volume := range c.Volumes {
225 cliOption += fmt.Sprintf(" -v %s:%s", volume.HostDir, volume.ContainerDir)
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +0100226 }
227 }
228
Maros Ondrejickadb823ed2022-12-14 16:30:04 +0100229 return cliOption
230}
231
Adrian Villin4677d922024-06-14 09:32:39 +0200232func (c *Container) AddEnvVar(name string, value string) {
233 c.EnvVars[name] = value
Maros Ondrejickadb823ed2022-12-14 16:30:04 +0100234}
235
236func (c *Container) getEnvVarsAsCliOption() string {
237 cliOption := ""
Adrian Villin4677d922024-06-14 09:32:39 +0200238 if len(c.EnvVars) == 0 {
Maros Ondrejickadb823ed2022-12-14 16:30:04 +0100239 return cliOption
240 }
241
Adrian Villin4677d922024-06-14 09:32:39 +0200242 for name, value := range c.EnvVars {
Maros Ondrejickadb823ed2022-12-14 16:30:04 +0100243 cliOption += fmt.Sprintf(" -e %s=%s", name, value)
244 }
245 return cliOption
246}
247
Filip Tehlar608d0062023-04-28 10:29:47 +0200248func (c *Container) newVppInstance(cpus []int, additionalConfigs ...Stanza) (*VppInstance, error) {
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100249 vpp := new(VppInstance)
Adrian Villin4677d922024-06-14 09:32:39 +0200250 vpp.Container = c
251 vpp.Cpus = cpus
252 vpp.AdditionalConfig = append(vpp.AdditionalConfig, additionalConfigs...)
253 c.VppInstance = vpp
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100254 return vpp, nil
255}
256
257func (c *Container) copy(sourceFileName string, targetFileName string) error {
Adrian Villin4677d922024-06-14 09:32:39 +0200258 cmd := exec.Command("docker", "cp", sourceFileName, c.Name+":"+targetFileName)
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100259 return cmd.Run()
260}
261
Adrian Villin4677d922024-06-14 09:32:39 +0200262func (c *Container) CreateFile(destFileName string, content string) error {
263 f, err := os.CreateTemp("/tmp", "hst-config"+c.Suite.Ppid)
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100264 if err != nil {
265 return err
266 }
267 defer os.Remove(f.Name())
268
269 if _, err := f.Write([]byte(content)); err != nil {
270 return err
271 }
272 if err := f.Close(); err != nil {
273 return err
274 }
275 c.copy(f.Name(), destFileName)
276 return nil
277}
278
279/*
280 * Executes in detached mode so that the started application can continue to run
281 * without blocking execution of test
282 */
Adrian Villin4677d922024-06-14 09:32:39 +0200283func (c *Container) ExecServer(command string, arguments ...any) {
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +0100284 serverCommand := fmt.Sprintf(command, arguments...)
285 containerExecCommand := "docker exec -d" + c.getEnvVarsAsCliOption() +
Adrian Villin4677d922024-06-14 09:32:39 +0200286 " " + c.Name + " " + serverCommand
Adrian Villincee15aa2024-03-14 11:42:55 -0400287 GinkgoHelper()
Adrian Villin4677d922024-06-14 09:32:39 +0200288 c.Suite.Log(containerExecCommand)
289 c.Suite.AssertNil(exechelper.Run(containerExecCommand))
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100290}
291
Adrian Villin4677d922024-06-14 09:32:39 +0200292func (c *Container) Exec(command string, arguments ...any) string {
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +0100293 cliCommand := fmt.Sprintf(command, arguments...)
294 containerExecCommand := "docker exec" + c.getEnvVarsAsCliOption() +
Adrian Villin4677d922024-06-14 09:32:39 +0200295 " " + c.Name + " " + cliCommand
Adrian Villincee15aa2024-03-14 11:42:55 -0400296 GinkgoHelper()
Adrian Villin4677d922024-06-14 09:32:39 +0200297 c.Suite.Log(containerExecCommand)
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +0100298 byteOutput, err := exechelper.CombinedOutput(containerExecCommand)
Adrian Villin4677d922024-06-14 09:32:39 +0200299 c.Suite.AssertNil(err, fmt.Sprint(err))
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +0100300 return string(byteOutput)
Maros Ondrejickadb823ed2022-12-14 16:30:04 +0100301}
302
Maros Ondrejickaa2d52622023-02-24 11:26:39 +0100303func (c *Container) getLogDirPath() string {
Adrian Villin4677d922024-06-14 09:32:39 +0200304 testId := c.Suite.GetTestId()
305 testName := c.Suite.GetCurrentTestName()
Maros Ondrejickaa2d52622023-02-24 11:26:39 +0100306 logDirPath := logDir + testName + "/" + testId + "/"
307
308 cmd := exec.Command("mkdir", "-p", logDirPath)
309 if err := cmd.Run(); err != nil {
Adrian Villincee15aa2024-03-14 11:42:55 -0400310 Fail("mkdir error: " + fmt.Sprint(err))
Maros Ondrejickaa2d52622023-02-24 11:26:39 +0100311 }
312
313 return logDirPath
314}
315
316func (c *Container) saveLogs() {
Adrian Villin4677d922024-06-14 09:32:39 +0200317 testLogFilePath := c.getLogDirPath() + "container-" + c.Name + ".log"
Maros Ondrejickaa2d52622023-02-24 11:26:39 +0100318
Adrian Villin4677d922024-06-14 09:32:39 +0200319 cmd := exec.Command("docker", "logs", "--details", "-t", c.Name)
320 c.Suite.Log(cmd)
Maros Ondrejickaa2d52622023-02-24 11:26:39 +0100321 output, err := cmd.CombinedOutput()
322 if err != nil {
Adrian Villin4677d922024-06-14 09:32:39 +0200323 c.Suite.Log(err)
Maros Ondrejickaa2d52622023-02-24 11:26:39 +0100324 }
325
326 f, err := os.Create(testLogFilePath)
327 if err != nil {
Adrian Villincee15aa2024-03-14 11:42:55 -0400328 Fail("file create error: " + fmt.Sprint(err))
Maros Ondrejickaa2d52622023-02-24 11:26:39 +0100329 }
Maros Ondrejickae7625d02023-02-28 16:55:01 +0100330 fmt.Fprint(f, string(output))
Maros Ondrejickaa2d52622023-02-24 11:26:39 +0100331 f.Close()
332}
333
adrianvillin7c675472024-02-12 02:44:53 -0500334// Outputs logs from docker containers. Set 'maxLines' to 0 to output the full log.
335func (c *Container) log(maxLines int) (string, error) {
336 var cmd string
337 if maxLines == 0 {
Adrian Villin4677d922024-06-14 09:32:39 +0200338 cmd = "docker logs " + c.Name
adrianvillin7c675472024-02-12 02:44:53 -0500339 } else {
Adrian Villin4677d922024-06-14 09:32:39 +0200340 cmd = fmt.Sprintf("docker logs --tail %d %s", maxLines, c.Name)
adrianvillin7c675472024-02-12 02:44:53 -0500341 }
342
Adrian Villin4677d922024-06-14 09:32:39 +0200343 c.Suite.Log(cmd)
Maros Ondrejickac2f76f42023-02-27 13:22:45 +0100344 o, err := exechelper.CombinedOutput(cmd)
adrianvillin7c675472024-02-12 02:44:53 -0500345 return string(o), err
Maros Ondrejickac2f76f42023-02-27 13:22:45 +0100346}
347
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +0100348func (c *Container) stop() error {
Adrian Villin4677d922024-06-14 09:32:39 +0200349 if c.VppInstance != nil && c.VppInstance.ApiStream != nil {
350 c.VppInstance.saveLogs()
351 c.VppInstance.Disconnect()
Maros Ondrejickaffa3f602023-01-26 10:07:29 +0100352 }
Adrian Villin4677d922024-06-14 09:32:39 +0200353 c.VppInstance = nil
Maros Ondrejickaa2d52622023-02-24 11:26:39 +0100354 c.saveLogs()
Adrian Villin4677d922024-06-14 09:32:39 +0200355 c.Suite.Log("docker stop " + c.Name + " -t 0")
356 return exechelper.Run("docker stop " + c.Name + " -t 0")
Maros Ondrejicka0e79abb2022-12-06 19:46:24 +0100357}
Maros Ondrejicka85396a52023-02-28 12:49:43 +0100358
Adrian Villin4677d922024-06-14 09:32:39 +0200359func (c *Container) CreateConfig(targetConfigName string, templateName string, values any) {
Maros Ondrejicka85396a52023-02-28 12:49:43 +0100360 template := template.Must(template.ParseFiles(templateName))
361
Filip Tehlara1bd50c2024-01-24 11:59:44 +0100362 f, err := os.CreateTemp(logDir, "hst-config")
Adrian Villin4677d922024-06-14 09:32:39 +0200363 c.Suite.AssertNil(err, err)
Maros Ondrejicka85396a52023-02-28 12:49:43 +0100364 defer os.Remove(f.Name())
365
366 err = template.Execute(f, values)
Adrian Villin4677d922024-06-14 09:32:39 +0200367 c.Suite.AssertNil(err, err)
Maros Ondrejicka85396a52023-02-28 12:49:43 +0100368
369 err = f.Close()
Adrian Villin4677d922024-06-14 09:32:39 +0200370 c.Suite.AssertNil(err, err)
Maros Ondrejicka85396a52023-02-28 12:49:43 +0100371
372 c.copy(f.Name(), targetConfigName)
373}
Maros Ondrejickaf4ddf162023-03-08 16:01:43 +0100374
375func init() {
376 cmd := exec.Command("mkdir", "-p", logDir)
377 if err := cmd.Run(); err != nil {
378 panic(err)
379 }
380}