MCPcopy
hub / github.com/slimtoolkit/slim / TestSimpleSensorRun_Standalone_Service

Function TestSimpleSensorRun_Standalone_Service

pkg/app/sensor/app_test.go:150–188  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

148}
149
150func 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
190func TestSensorLogsGoToFile(t *testing.T) {
191 runID := newTestRun(t)

Callers

nothing calls this directly

Calls 10

newTestRunFunction · 0.85
StartStandaloneOrFailMethod · 0.80
SignalOrFailMethod · 0.80
WaitOrFailMethod · 0.80
CleanupMethod · 0.45

Tested by

no test coverage detected