-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpatrol_server_test.go
611 lines (532 loc) · 19 KB
/
patrol_server_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
package patrol
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"os/exec"
"sabey.co/unittest"
"syscall"
"testing"
"time"
)
func TestServerExecHTTP(t *testing.T) {
log.Println("TestServerExecHTTP")
done := make(chan struct{})
defer close(done)
go func() {
select {
case <-time.After(time.Second * 45):
log.Fatalln("failed to complete TestServerExecHTTP")
case <-done:
return
}
}()
wd, err := os.Getwd()
unittest.IsNil(t, err)
unittest.Equals(t, wd != "", true)
wd += "/unittest/"
dir := fmt.Sprintf("%stestapp/", wd)
x := fmt.Sprintf("%stestapp", dir)
log.Printf("executing %s", x)
cmd_app := exec.Command(x)
cmd_app.Env = []string{
fmt.Sprintf("%s=%s", PATROL_ENV_UNITTEST_KEY, PATROL_ENV_UNITTEST_VALUE),
fmt.Sprintf("%s=http-testapp", APP_ENV_APP_ID),
fmt.Sprintf("%s=%d", APP_ENV_KEEPALIVE, APP_KEEPALIVE_HTTP),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_HTTP, LISTEN_HTTP_PORT_DEFAULT),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_UDP, LISTEN_UDP_PORT_DEFAULT),
}
cmd_app.Dir = dir
cmd_app.Stdout = os.Stdout
cmd_app.Stderr = os.Stderr
cmd_app.Start()
defer cmd_app.Process.Kill()
go func() {
cmd_app.Wait()
}()
<-time.After(time.Second * 2)
dir = fmt.Sprintf("%stestserver/", wd)
x = fmt.Sprintf("%stestserver", dir)
log.Printf("executing %s", x)
cmd_server := exec.Command(x, "-config", "config-http.json")
cmd_server.Env = []string{
fmt.Sprintf("%s=%s", PATROL_ENV_UNITTEST_KEY, PATROL_ENV_UNITTEST_VALUE),
fmt.Sprintf("%s=testserver", APP_ENV_APP_ID),
fmt.Sprintf("%s=%d", APP_ENV_KEEPALIVE, APP_KEEPALIVE_HTTP),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_HTTP, LISTEN_HTTP_PORT_DEFAULT),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_UDP, LISTEN_UDP_PORT_DEFAULT),
}
cmd_server.Dir = dir
cmd_server.Stdout = os.Stdout
cmd_server.Stderr = os.Stderr
cmd_server.Start()
defer cmd_server.Process.Kill()
go func() {
cmd_server.Wait()
}()
// we have to wait at least PingTimeout
<-time.After(time.Second * 3)
// check that we're running
log.Println("checking that we're running")
// hit API
body, err := httpGET("http-testapp", "")
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result := &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// check response
unittest.Equals(t, result.Started.IsZero(), false)
unittest.Equals(t, result.PID > 0, true)
unittest.Equals(t, result.RunOnce, true)
log.Println("closing testapp")
cmd_app.Process.Kill()
// we need to wait longer than PingTimeout!
<-time.After(time.Second * 5)
// check that we're closed
log.Println("checking that we're closed")
// hit API
body, err = httpGET("http-testapp", "")
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result = &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// check response
unittest.Equals(t, result.Started.IsZero(), true)
unittest.Equals(t, result.Disabled, true)
unittest.Equals(t, len(result.History) > 0, true)
unittest.Equals(t, result.History[0].Started.IsZero(), false)
unittest.Equals(t, result.History[0].PID > 0, true)
unittest.Equals(t, result.History[0].RunOnce, true)
log.Println("enabling app")
body, err = httpGET("http-testapp", fmt.Sprintf("toggle=%d", API_TOGGLE_STATE_ENABLE_RUNONCE_ENABLE))
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result = &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// wait to be restarted
log.Println("waiting for app to be restarted")
// we have to wait at least PingTimeout + wait for a Ping (we pause 2 seconds)
<-time.After(time.Second * 7)
// check that we're running
log.Println("checking that we're running")
// hit API
body, err = httpGET("http-testapp", "")
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result = &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// check response
unittest.Equals(t, result.Started.IsZero(), false)
unittest.Equals(t, result.PID > 0, true)
unittest.Equals(t, result.RunOnce, true)
log.Println("killing patrol")
cmd_server.Process.Kill()
log.Println("checking that we're running")
<-time.After(time.Second * 3)
// we can't PING our API anymore, we have to `kill -0 PID`
process, err := os.FindProcess(int(result.PID))
unittest.IsNil(t, err)
unittest.NotNil(t, process)
unittest.IsNil(t, process.Signal(syscall.Signal(0)))
log.Println("still running! closing app")
process.Signal(syscall.SIGKILL)
}
func TestServerExecUDP(t *testing.T) {
log.Println("TestServerExecUDP")
done := make(chan struct{})
defer close(done)
go func() {
select {
case <-time.After(time.Second * 45):
log.Fatalln("failed to complete TestServerExecUDP")
case <-done:
return
}
}()
wd, err := os.Getwd()
unittest.IsNil(t, err)
unittest.Equals(t, wd != "", true)
wd += "/unittest/"
dir := fmt.Sprintf("%stestapp/", wd)
x := fmt.Sprintf("%stestapp", dir)
log.Printf("executing %s", x)
cmd_app := exec.Command(x)
cmd_app.Env = []string{
fmt.Sprintf("%s=%s", PATROL_ENV_UNITTEST_KEY, PATROL_ENV_UNITTEST_VALUE),
fmt.Sprintf("%s=udp-testapp", APP_ENV_APP_ID),
fmt.Sprintf("%s=%d", APP_ENV_KEEPALIVE, APP_KEEPALIVE_UDP),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_HTTP, LISTEN_HTTP_PORT_DEFAULT),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_UDP, LISTEN_UDP_PORT_DEFAULT),
}
cmd_app.Dir = dir
cmd_app.Stdout = os.Stdout
cmd_app.Stderr = os.Stderr
cmd_app.Start()
defer cmd_app.Process.Kill()
go func() {
cmd_app.Wait()
}()
<-time.After(time.Second * 2)
dir = fmt.Sprintf("%stestserver/", wd)
x = fmt.Sprintf("%stestserver", dir)
log.Printf("executing %s", x)
cmd_server := exec.Command(x, "-config", "config-udp.json")
cmd_server.Env = []string{
fmt.Sprintf("%s=%s", PATROL_ENV_UNITTEST_KEY, PATROL_ENV_UNITTEST_VALUE),
fmt.Sprintf("%s=testserver", APP_ENV_APP_ID),
fmt.Sprintf("%s=%d", APP_ENV_KEEPALIVE, APP_KEEPALIVE_UDP),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_HTTP, LISTEN_HTTP_PORT_DEFAULT),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_UDP, LISTEN_UDP_PORT_DEFAULT),
}
cmd_server.Dir = dir
cmd_server.Stdout = os.Stdout
cmd_server.Stderr = os.Stderr
cmd_server.Start()
defer cmd_server.Process.Kill()
go func() {
cmd_server.Wait()
}()
// we have to wait at least PingTimeout
<-time.After(time.Second * 3)
// check that we're running
log.Println("checking that we're running")
// hit API
body, err := httpGET("udp-testapp", "")
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result := &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// check response
unittest.Equals(t, result.Started.IsZero(), false)
unittest.Equals(t, result.PID > 0, true)
unittest.Equals(t, result.RunOnce, true)
log.Println("closing testapp")
cmd_app.Process.Kill()
// we need to wait longer than PingTimeout!
<-time.After(time.Second * 5)
// check that we're closed
log.Println("checking that we're closed")
// hit API
body, err = httpGET("udp-testapp", "")
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result = &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// check response
unittest.Equals(t, result.Started.IsZero(), true)
unittest.Equals(t, result.Disabled, true)
unittest.Equals(t, len(result.History) > 0, true)
unittest.Equals(t, result.History[0].Started.IsZero(), false)
unittest.Equals(t, result.History[0].PID > 0, true)
unittest.Equals(t, result.History[0].RunOnce, true)
log.Println("enabling app")
body, err = httpGET("udp-testapp", fmt.Sprintf("toggle=%d", API_TOGGLE_STATE_ENABLE_RUNONCE_ENABLE))
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result = &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// wait to be restarted
log.Println("waiting for app to be restarted")
// we have to wait at least PingTimeout + wait for a Ping (we pause 2 seconds)
<-time.After(time.Second * 7)
// check that we're running
log.Println("checking that we're running")
// hit API
body, err = httpGET("udp-testapp", "")
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result = &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// check response
unittest.Equals(t, result.Started.IsZero(), false)
unittest.Equals(t, result.PID > 0, true)
unittest.Equals(t, result.RunOnce, true)
log.Println("killing patrol")
cmd_server.Process.Kill()
log.Println("checking that we're running")
<-time.After(time.Second * 3)
// we can't PING our API anymore, we have to `kill -0 PID`
process, err := os.FindProcess(int(result.PID))
unittest.IsNil(t, err)
unittest.NotNil(t, process)
unittest.IsNil(t, process.Signal(syscall.Signal(0)))
log.Println("still running! closing app")
process.Signal(syscall.SIGKILL)
}
func TestServerExecPIDAPP(t *testing.T) {
log.Println("TestServerExecPIDAPP")
done := make(chan struct{})
defer close(done)
go func() {
select {
case <-time.After(time.Second * 45):
log.Fatalln("failed to complete TestServerExecPIDAPP")
case <-done:
return
}
}()
wd, err := os.Getwd()
unittest.IsNil(t, err)
unittest.Equals(t, wd != "", true)
wd += "/unittest/"
dir := fmt.Sprintf("%stestapp/", wd)
x := fmt.Sprintf("%stestapp", dir)
log.Printf("executing %s", x)
cmd_app := exec.Command(x)
cmd_app.Env = []string{
fmt.Sprintf("%s=%s", PATROL_ENV_UNITTEST_KEY, PATROL_ENV_UNITTEST_VALUE),
fmt.Sprintf("%s=pid-app-testapp", APP_ENV_APP_ID),
fmt.Sprintf("%s=%d", APP_ENV_KEEPALIVE, APP_KEEPALIVE_PID_APP),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_HTTP, LISTEN_HTTP_PORT_DEFAULT),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_UDP, LISTEN_UDP_PORT_DEFAULT),
}
cmd_app.Dir = dir
cmd_app.Stdout = os.Stdout
cmd_app.Stderr = os.Stderr
cmd_app.Start()
defer cmd_app.Process.Kill()
go func() {
cmd_app.Wait()
}()
<-time.After(time.Second * 2)
dir = fmt.Sprintf("%stestserver/", wd)
x = fmt.Sprintf("%stestserver", dir)
log.Printf("executing %s", x)
cmd_server := exec.Command(x, "-config", "config-pid-app.json")
cmd_server.Env = []string{
fmt.Sprintf("%s=%s", PATROL_ENV_UNITTEST_KEY, PATROL_ENV_UNITTEST_VALUE),
fmt.Sprintf("%s=testserver", APP_ENV_APP_ID),
fmt.Sprintf("%s=%d", APP_ENV_KEEPALIVE, APP_KEEPALIVE_PID_APP),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_HTTP, LISTEN_HTTP_PORT_DEFAULT),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_UDP, LISTEN_UDP_PORT_DEFAULT),
}
cmd_server.Dir = dir
cmd_server.Stdout = os.Stdout
cmd_server.Stderr = os.Stderr
cmd_server.Start()
defer cmd_server.Process.Kill()
go func() {
cmd_server.Wait()
}()
// we have to wait at least PingTimeout
<-time.After(time.Second * 3)
// check that we're running
log.Println("checking that we're running")
// hit API - mark as run once as well
body, err := httpGET("pid-app-testapp", fmt.Sprintf("toggle=%d", API_TOGGLE_STATE_RUNONCE_ENABLE))
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result := &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// check response
unittest.Equals(t, result.Started.IsZero(), false)
unittest.Equals(t, result.PID > 0, true)
unittest.Equals(t, result.RunOnce, false)
log.Println("closing testapp")
cmd_app.Process.Kill()
// we need to wait longer than PingTimeout!
<-time.After(time.Second * 5)
// check that we're closed
log.Println("checking that we're closed")
// hit API
body, err = httpGET("pid-app-testapp", "")
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result = &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// check response
unittest.Equals(t, result.Started.IsZero(), true)
unittest.Equals(t, result.Disabled, true)
unittest.Equals(t, len(result.History) > 0, true)
unittest.Equals(t, result.History[0].Started.IsZero(), false)
unittest.Equals(t, result.History[0].PID > 0, true)
unittest.Equals(t, result.History[0].RunOnce, true)
log.Println("enabling app")
body, err = httpGET("pid-app-testapp", fmt.Sprintf("toggle=%d", API_TOGGLE_STATE_ENABLE_RUNONCE_ENABLE))
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result = &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// wait to be restarted
log.Println("waiting for app to be restarted")
// we have to wait at least PingTimeout + wait for a Ping (we pause 2 seconds)
<-time.After(time.Second * 7)
// check that we're running
log.Println("checking that we're running")
// hit API
body, err = httpGET("pid-app-testapp", "")
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result = &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// check response
unittest.Equals(t, result.Started.IsZero(), false)
unittest.Equals(t, result.PID > 0, true)
unittest.Equals(t, result.RunOnce, true)
log.Println("killing patrol")
cmd_server.Process.Kill()
log.Println("checking that we're running")
<-time.After(time.Second * 3)
// we can't PING our API anymore, we have to `kill -0 PID`
process, err := os.FindProcess(int(result.PID))
unittest.IsNil(t, err)
unittest.NotNil(t, process)
unittest.IsNil(t, process.Signal(syscall.Signal(0)))
log.Println("still running! closing app")
process.Signal(syscall.SIGKILL)
}
func TestServerExecPIDPatrol(t *testing.T) {
log.Println("TestServerExecPIDPatrol")
done := make(chan struct{})
defer close(done)
go func() {
select {
case <-time.After(time.Second * 45):
log.Fatalln("failed to complete TestServerExecPIDPatrol")
case <-done:
return
}
}()
wd, err := os.Getwd()
unittest.IsNil(t, err)
unittest.Equals(t, wd != "", true)
wd += "/unittest/"
dir := fmt.Sprintf("%stestserver/", wd)
x := fmt.Sprintf("%stestserver", dir)
log.Printf("executing %s", x)
cmd_server := exec.Command(x, "-config", "config-pid-patrol.json")
cmd_server.Env = []string{
fmt.Sprintf("%s=%s", PATROL_ENV_UNITTEST_KEY, PATROL_ENV_UNITTEST_VALUE),
fmt.Sprintf("%s=testserver", APP_ENV_APP_ID),
fmt.Sprintf("%s=%d", APP_ENV_KEEPALIVE, APP_KEEPALIVE_PID_PATROL),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_HTTP, LISTEN_HTTP_PORT_DEFAULT),
fmt.Sprintf("%s=[\":%d\"]", APP_ENV_LISTEN_UDP, LISTEN_UDP_PORT_DEFAULT),
}
cmd_server.Dir = dir
cmd_server.Stdout = os.Stdout
cmd_server.Stderr = os.Stderr
cmd_server.Start()
defer cmd_server.Process.Kill()
go func() {
cmd_server.Wait()
}()
// we have to wait at least PingTimeout
<-time.After(time.Second * 3)
// check that we're running
log.Println("checking that we're running")
// hit API - mark as run once as well
body, err := httpGET("pid-patrol-testapp", fmt.Sprintf("toggle=%d", API_TOGGLE_STATE_RUNONCE_ENABLE))
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result := &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// check response
unittest.Equals(t, result.Started.IsZero(), false)
unittest.Equals(t, result.PID > 0, true)
unittest.Equals(t, result.RunOnce, false)
log.Println("closing testapp")
process, err := os.FindProcess(int(result.PID))
unittest.IsNil(t, err)
unittest.NotNil(t, process)
unittest.IsNil(t, process.Signal(syscall.SIGKILL))
// we need to wait longer than PingTimeout!
<-time.After(time.Second * 5)
// check that we're closed
log.Println("checking that we're closed")
// hit API
body, err = httpGET("pid-patrol-testapp", "")
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result = &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// check response
unittest.Equals(t, result.Started.IsZero(), true)
unittest.Equals(t, result.Disabled, true)
unittest.Equals(t, len(result.History) > 0, true)
unittest.Equals(t, result.History[0].Started.IsZero(), false)
unittest.Equals(t, result.History[0].PID > 0, true)
unittest.Equals(t, result.History[0].RunOnce, true)
log.Println("enabling app")
body, err = httpGET("pid-patrol-testapp", fmt.Sprintf("toggle=%d", API_TOGGLE_STATE_ENABLE_RUNONCE_ENABLE))
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result = &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// wait to be restarted
log.Println("waiting for app to be restarted")
// we have to wait at least PingTimeout + wait for a Ping (we pause 2 seconds)
<-time.After(time.Second * 7)
// check that we're running
log.Println("checking that we're running")
// hit API
body, err = httpGET("pid-patrol-testapp", "")
unittest.IsNil(t, err)
log.Printf("body: \"%s\"\n", body)
result = &API_Response{}
unittest.IsNil(t, json.Unmarshal(body, result))
// check response
unittest.Equals(t, result.Started.IsZero(), false)
unittest.Equals(t, result.PID > 0, true)
unittest.Equals(t, result.RunOnce, true)
log.Println("killing patrol")
cmd_server.Process.Kill()
log.Println("checking that we're running")
<-time.After(time.Second * 2)
// our process should still be running!!!
// the reason it is still running is that we sent our signal to our patrol process and not patrol process group id
// we have also disabled all forms of having patrol signal children to stop on shutdown
// this is the downside of APP_KEEPALIVE_PID_PATROL, there is no way to tie a child to the life of a parent process?
// we can't PING our API anymore, we have to `kill -0 PID`
process, err = os.FindProcess(int(result.PID))
unittest.IsNil(t, err)
unittest.NotNil(t, process)
unittest.IsNil(t, process.Signal(syscall.Signal(0)))
log.Println("still running! closing app")
unittest.IsNil(t, process.Signal(syscall.SIGKILL))
}
func httpGET(
id string,
extra string,
) (
[]byte,
error,
) {
response, err := http.Get(fmt.Sprintf("http://127.0.0.1:%d/api/?id=%s&group=app&%s", LISTEN_HTTP_PORT_DEFAULT, id, extra))
if err != nil {
return nil, err
}
if response.StatusCode != 200 {
log.Fatalf("httpGET failed - StatusCode: %d != 200\n", response.StatusCode)
return nil, nil
}
// read body
body, err := ioutil.ReadAll(response.Body)
if err != nil {
response.Body.Close()
return nil, err
}
response.Body.Close()
return body, nil
}
// APP_KEEPALIVE_PID_PATROL, APP_KEEPALIVE_HTTP, APP_KEEPALIVE_UDP
//
// processes created by unittests:
//
// PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND
// 4543 8092 8092 4543 pts/0 8092 Sl+ 1000 0:00 | | \_ go test -test.run=TestServerExecHTTP -race
// 8092 8268 8092 4543 pts/0 8092 Sl+ 1000 0:00 | | \_ /tmp/go-build905010232/b001/patrol.test -test.run=TestServerExecHTTP
// 8268 8274 8092 4543 pts/0 8092 Sl+ 1000 0:00 | | \_ /home/jackson/go/src/sabey.co/patrol/unittest/testapp/testapp
// 7388 8284 8283 7388 pts/14 8283 S+ 1000 0:00 | \_ grep --color=auto -i test
//
//
// processes created by patrol:
//
// PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND
// 4543 8092 8092 4543 pts/0 8092 Sl+ 1000 0:00 | | \_ go test -test.run=TestServerExecHTTP -race
// 8092 8268 8092 4543 pts/0 8092 Sl+ 1000 0:00 | | \_ /tmp/go-build905010232/b001/patrol.test -test.run=TestServerExecHTTP
// 8268 8285 8092 4543 pts/0 8092 Sl+ 1000 0:00 | | \_ /home/jackson/go/src/sabey.co/patrol/unittest/testserver/testserver -config config-http.json
// 8285 8313 8313 4543 pts/0 8092 Sl 1000 0:00 | | \_ /home/jackson/go/src/sabey.co/patrol/unittest/testapp/testapp
// 7388 8328 8327 7388 pts/14 8327 S+ 1000 0:00 | \_ grep --color=auto -i test