@@ -67,10 +67,11 @@ func TestNewFactoryChroot(t *testing.T) {
6767
6868 // Create container configuration
6969 containerConfig := & container.Config {
70- Image : imageName ,
71- Cmd : []string {"go" , "test" , "-v" , "-count=1" , "-run=TestInDockerNewFactory" },
72- Tty : true ,
73- WorkingDir : "/workspace/filebeat/input/journald/pkg/journalctl" ,
70+ Image : imageName ,
71+ Cmd : []string {"go" , "test" , "-v" , "-count=1" , "-run=TestInDockerNewFactory" },
72+ Tty : true ,
73+ AttachStdin : false ,
74+ WorkingDir : "/workspace/filebeat/input/journald/pkg/journalctl" ,
7475 Env : []string {
7576 "IN_DOCKER_CONTAINER=true" ,
7677 fmt .Sprintf ("JOURNALCTL_PATH=%s" , journalctlPath ),
@@ -149,20 +150,21 @@ func TestInDockerNewFactory(t *testing.T) {
149150 require .NotEmpty (t , chrootPath , "CHROOT_PATH must be set" )
150151
151152 tempDir := os .Getenv ("TEST_TEMP_DIR" )
152- require .NotEmpty (t , chrootPath , "TEST_TEMP_DIR be set" )
153+ require .NotEmpty (t , tempDir , "TEST_TEMP_DIR be set" )
153154
154- testCtx , cancel := context .WithCancel (t .Context ())
155+ jctlCtx , cancel := context .WithCancel (t .Context ())
155156 t .Cleanup (cancel )
156157
157158 logger := logptest .NewFileLogger (t , tempDir )
158159 factory := NewFactory (chrootPath , journalctlPath )
159160
160- jctl , err := factory (testCtx , logger .Logger , "--version" )
161+ // Try to read version output, this ensures we can call journalctl
162+ // without the need of any messages in the journal
163+ jctl , err := factory (jctlCtx , logger .Logger , "--version" )
161164 require .NoError (t , err , "failed to create journalctl with chroot" )
162165 defer jctl .Kill ()
163166
164- // Try to read version output
165- data , err := jctl .Next (testCtx )
167+ data , err := jctl .Next (jctlCtx )
166168 require .NoError (t , err , "failed to read from journalctl" )
167169 require .NotEmpty (t , data , "expected output from journalctl --version" )
168170}
0 commit comments