(t *testing.T)
| 148 | } |
| 149 | |
| 150 | func TestSimpleSensorRun_Standalone_Service(t *testing.T) { |
| 151 | runID := newTestRun(t) |
| 152 | ctx := context.Background() |
| 153 | |
| 154 | sensor := testsensor.NewSensorOrFail(t, ctx, t.TempDir(), runID, imageSimpleService) |
| 155 | defer sensor.Cleanup(t, ctx) |
| 156 | |
| 157 | sensor.StartStandaloneOrFail(t, ctx, nil) |
| 158 | go testutil.Delayed(ctx, 5*time.Second, func() { |
| 159 | sensor.SignalOrFail(t, ctx, syscall.SIGTERM) |
| 160 | }) |
| 161 | sensor.WaitOrFail(t, ctx) |
| 162 | |
| 163 | sensor.AssertSensorLogsContain(t, ctx, sensorFullLifecycleSequence...) |
| 164 | sensor.AssertTargetAppLogsContain(t, ctx, |
| 165 | "nginx/1.21", |
| 166 | "start worker processes", |
| 167 | "(SIGTERM) received from 1, exiting", |
| 168 | ) |
| 169 | |
| 170 | sensor.DownloadArtifactsOrFail(t, ctx) |
| 171 | sensor.AssertReportIncludesFiles(t, |
| 172 | "/bin/sh", |
| 173 | "/etc/nginx/nginx.conf", |
| 174 | "/etc/nginx/conf.d/default.conf", |
| 175 | "/var/cache/nginx", |
| 176 | "/var/run", |
| 177 | ) |
| 178 | sensor.AssertReportNotIncludesFiles(t, |
| 179 | "/bin/bash", |
| 180 | "/bin/cat", |
| 181 | "/etc/apt/sources.list", |
| 182 | // Here is an interesting one - in the standalone mode sensor |
| 183 | // tries gracefully terminate the target process by forwarding |
| 184 | // it the StopSignal from it receives from the runtime. Nginx |
| 185 | // exits and cleans up its pid file. |
| 186 | "/run/nginx.pid", |
| 187 | ) |
| 188 | } |
| 189 | |
| 190 | func TestSensorLogsGoToFile(t *testing.T) { |
| 191 | runID := newTestRun(t) |
nothing calls this directly
no test coverage detected