2
2
// or more contributor license agreements. Licensed under the Elastic License;
3
3
// you may not use this file except in compliance with the Elastic License.
4
4
5
- // FIXME(ml): test suite is disabled by additional build flag.
6
- // we do not want to rely on agent builds in our pipeline.
7
-
8
- //go:build e2e && ignore
5
+ //go:build e2e
9
6
10
7
package e2e
11
8
@@ -15,10 +12,14 @@ import (
15
12
"os"
16
13
"os/exec"
17
14
"path/filepath"
15
+ "strings"
18
16
"testing"
19
17
"time"
20
18
21
19
"github.com/elastic/fleet-server/testing/e2e/scaffold"
20
+
21
+ "github.com/docker/docker/api/types/container"
22
+ "github.com/docker/docker/api/types/mount"
22
23
"github.com/stretchr/testify/suite"
23
24
"github.com/testcontainers/testcontainers-go"
24
25
)
@@ -115,11 +116,15 @@ func (suite *AgentContainerSuite) TestHTTP() {
115
116
},
116
117
ExposedPorts : []string {"8220/tcp" },
117
118
Networks : []string {"integration_default" },
118
- Mounts : testcontainers.ContainerMounts {
119
- testcontainers.ContainerMount {
120
- Source : & testcontainers.GenericBindMountSource {suite .CoverPath },
119
+ HostConfigModifier : func (cfg * container.HostConfig ) {
120
+ if cfg .Mounts == nil {
121
+ cfg .Mounts = make ([]mount.Mount , 0 )
122
+ }
123
+ cfg .Mounts = append (cfg .Mounts , mount.Mount {
124
+ Type : mount .TypeBind ,
125
+ Source : suite .CoverPath ,
121
126
Target : "/cover" ,
122
- },
127
+ })
123
128
},
124
129
WaitingFor : containerWaitForHealthyStatus (),
125
130
}
@@ -138,11 +143,6 @@ func (suite *AgentContainerSuite) TestHTTP() {
138
143
}
139
144
140
145
func (suite * AgentContainerSuite ) TestWithSecretFiles () {
141
- // Create a service token file in the temp test dir
142
- dir := suite .T ().TempDir ()
143
- err := os .WriteFile (filepath .Join (dir , "service-token" ), []byte (suite .ServiceToken ), 0644 )
144
- suite .Require ().NoError (err )
145
-
146
146
ctx , cancel := context .WithTimeout (context .Background (), time .Minute )
147
147
defer cancel ()
148
148
@@ -180,17 +180,20 @@ func (suite *AgentContainerSuite) TestWithSecretFiles() {
180
180
HostFilePath : filepath .Join (suite .CertPath , "passphrase" ),
181
181
ContainerFilePath : "/tmp/passphrase" ,
182
182
FileMode : 0644 ,
183
+ }, {
184
+ Reader : strings .NewReader (suite .ServiceToken ),
185
+ ContainerFilePath : "/token/service-token" ,
186
+ FileMode : 0644 ,
183
187
}},
184
- Mounts : testcontainers.ContainerMounts {
185
- testcontainers.ContainerMount {
186
- Source : & testcontainers.GenericBindMountSource {dir },
187
- Target : "/token" ,
188
- ReadOnly : true ,
189
- },
190
- testcontainers.ContainerMount {
191
- Source : & testcontainers.GenericBindMountSource {suite .CoverPath },
188
+ HostConfigModifier : func (cfg * container.HostConfig ) {
189
+ if cfg .Mounts == nil {
190
+ cfg .Mounts = make ([]mount.Mount , 0 )
191
+ }
192
+ cfg .Mounts = append (cfg .Mounts , mount.Mount {
193
+ Type : mount .TypeBind ,
194
+ Source : suite .CoverPath ,
192
195
Target : "/cover" ,
193
- },
196
+ })
194
197
},
195
198
WaitingFor : containerWaitForHealthyStatus ().WithTLS (true , nil ),
196
199
}
@@ -252,11 +255,15 @@ func (suite *AgentContainerSuite) TestSleep10m() {
252
255
ContainerFilePath : "/tmp/passphrase" ,
253
256
FileMode : 0644 ,
254
257
}},
255
- Mounts : testcontainers.ContainerMounts {
256
- testcontainers.ContainerMount {
257
- Source : & testcontainers.GenericBindMountSource {suite .CoverPath },
258
+ HostConfigModifier : func (cfg * container.HostConfig ) {
259
+ if cfg .Mounts == nil {
260
+ cfg .Mounts = make ([]mount.Mount , 0 )
261
+ }
262
+ cfg .Mounts = append (cfg .Mounts , mount.Mount {
263
+ Type : mount .TypeBind ,
264
+ Source : suite .CoverPath ,
258
265
Target : "/cover" ,
259
- },
266
+ })
260
267
},
261
268
WaitingFor : containerWaitForHealthyStatus ().WithTLS (true , nil ),
262
269
}
@@ -323,11 +330,15 @@ func (suite *AgentContainerSuite) TestDockerAgent() {
323
330
ContainerFilePath : "/tmp/passphrase" ,
324
331
FileMode : 0644 ,
325
332
}},
326
- Mounts : testcontainers.ContainerMounts {
327
- testcontainers.ContainerMount {
328
- Source : & testcontainers.GenericBindMountSource {suite .CoverPath },
333
+ HostConfigModifier : func (cfg * container.HostConfig ) {
334
+ if cfg .Mounts == nil {
335
+ cfg .Mounts = make ([]mount.Mount , 0 )
336
+ }
337
+ cfg .Mounts = append (cfg .Mounts , mount.Mount {
338
+ Type : mount .TypeBind ,
339
+ Source : suite .CoverPath ,
329
340
Target : "/cover" ,
330
- },
341
+ })
331
342
},
332
343
WaitingFor : containerWaitForHealthyStatus ().WithTLS (true , nil ),
333
344
}
0 commit comments