@@ -41,7 +41,7 @@ func TestProfileFlag(t *testing.T) {
41
41
hclContent := `
42
42
job "dummy" {
43
43
command = "/bin/sh"
44
- args = ["-c", "echo dummy job running; sleep 30"] // Increased sleep to 30s
44
+ args = ["-c", "echo dummy job running; sleep 10"]
45
45
}
46
46
`
47
47
if err := os .WriteFile (filepath .Join (jobsDir , "dummy.hcl" ), []byte (hclContent ), 0644 ); err != nil {
@@ -105,7 +105,7 @@ job "dummy" {
105
105
go func () {
106
106
defer wg .Done ()
107
107
reader := bufio .NewReader (stderrPipe ) // Read from stderrPipe
108
- pprofLogRegex := regexp .MustCompile (`Starting pprof server on http://localhost(?:[^:]+)? :(\d+)/debug/pprof/` )
108
+ pprofLogRegex := regexp .MustCompile (`Starting pprof server on http://127.0.0.1 :(\d+)/debug/pprof/` )
109
109
for {
110
110
line , err := reader .ReadString ('\n' )
111
111
if len (line ) > 0 {
@@ -141,11 +141,11 @@ job "dummy" {
141
141
t .Logf ("[%s] Successfully found pprof server URL: %s" , time .Since (startTime ), pprofURL )
142
142
case <- ctx .Done (): // This is the main test context
143
143
t .Logf ("[%s] Main context done while waiting for pprof URL." , time .Since (startTime ))
144
- cmd .Process .Kill () // Ensure process is killed if context times out
145
- wg .Wait () // Wait for goroutine to finish
144
+ cmd .Process .Kill () // Ensure process is killed if context times out
145
+ wg .Wait () // Wait for goroutine to finish
146
146
logContent := errBuf .String () // Use the full stderr buffer for logging
147
147
t .Fatalf ("Test timed out waiting for pprof server log. Stderr:\n %s" , logContent )
148
- case <- time .After (15 * time .Second ): // Specific timeout for finding the log line, increased slightly
148
+ case <- time .After (5 * time .Second ): // Specific timeout for finding the log line
149
149
t .Logf ("[%s] Timed out waiting for pprof log line via channel." , time .Since (startTime ))
150
150
cmd .Process .Kill () // Ensure process is killed
151
151
wg .Wait () // Wait for goroutine to finish
@@ -217,7 +217,7 @@ job "dummy" {
217
217
218
218
if ! success {
219
219
finalErrorDescriptive := "No successful HTTP GET." // Renamed to avoid conflict if needed, or ensure proper scope
220
- if httpErr != nil { // httpErr should hold the error from the last attempt
220
+ if httpErr != nil { // httpErr should hold the error from the last attempt
221
221
finalErrorDescriptive = httpErr .Error ()
222
222
}
223
223
statusCode := 0
@@ -244,7 +244,7 @@ job "dummy" {
244
244
// HTTP Check related variables (resp, httpErr, success) are already defined before this block.
245
245
// The defer func above will handle cmd.Wait() and final process state logging.
246
246
// We only need to kill the process here if the HTTP checks complete *successfully*
247
- // and the process hasn't naturally exited due to its own short lifecycle (unlikely with sleep 30 ).
247
+ // and the process hasn't naturally exited due to its own short lifecycle (unlikely with sleep 10 ).
248
248
if success { // If HTTP check was successful
249
249
if cmd .Process != nil && (cmd .ProcessState == nil || ! cmd .ProcessState .Exited ()) {
250
250
t .Logf ("[%s] HTTP check successful, ensuring mittnite process (PID: %d) is terminated." , time .Since (startTime ), cmd .Process .Pid )
0 commit comments