MCPcopy
hub / github.com/prometheus/prometheus / commandWithLogging

Function commandWithLogging

cmd/prometheus/reload_test.go:201–233  ·  view source on GitHub ↗
(t *testing.T, logProcessor func(*testing.T, io.Reader), name string, args ...string)

Source from the content-addressed store, hash-verified

199}
200
201func commandWithLogging(t *testing.T, logProcessor func(*testing.T, io.Reader), name string, args ...string) *exec.Cmd {
202 if logProcessor == nil {
203 logProcessor = captureLogsToTLog
204 }
205
206 stdoutPipe, stdoutWriter := io.Pipe()
207 stderrPipe, stderrWriter := io.Pipe()
208
209 var wg sync.WaitGroup
210 wg.Add(2)
211
212 cmd := exec.Command(name, args...)
213 cmd.Stdout = stdoutWriter
214 cmd.Stderr = stderrWriter
215
216 go func() {
217 defer wg.Done()
218 logProcessor(t, stdoutPipe)
219 }()
220 go func() {
221 defer wg.Done()
222 logProcessor(t, stderrPipe)
223 }()
224
225 t.Cleanup(func() {
226 cmd.Process.Kill()
227 cmd.Wait()
228 stdoutWriter.Close()
229 stderrWriter.Close()
230 wg.Wait()
231 })
232 return cmd
233}
234
235func prometheusCommandWithLogging(t *testing.T, configFilePath string, port int, extraArgs ...string) *exec.Cmd {
236 args := []string{

Callers 2

testUpgradeDowngradeLTSFunction · 0.85

Calls 3

AddMethod · 0.65
DoneMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…