@@ -19,11 +19,12 @@ func TestLogdyE2E_Socket(t *testing.T) {
19
19
20
20
// Setup wait group for message sending
21
21
var wg sync.WaitGroup
22
+ var wgReady sync.WaitGroup
23
+ wgReady .Add (1 )
22
24
wg .Add (3 ) // Expect 3 messages (1 from each port)
23
25
24
26
// Start logdy process with -t flag for stdout output
25
27
cmd := exec .Command ("go" , "run" , "../main.go" , "socket" , "-t" , "8475" , "8476" , "8477" )
26
-
27
28
// Get stdout pipe for verifying messages
28
29
stdout , err := cmd .StdoutPipe ()
29
30
assert .NoError (t , err )
@@ -33,6 +34,9 @@ func TestLogdyE2E_Socket(t *testing.T) {
33
34
scanner := bufio .NewScanner (stdout )
34
35
for scanner .Scan () {
35
36
line := scanner .Text ()
37
+ if strings .Contains (line , `WebUI started` ) {
38
+ wgReady .Done ()
39
+ }
36
40
select {
37
41
case msgChan <- line :
38
42
// Message sent to channel
@@ -47,7 +51,8 @@ func TestLogdyE2E_Socket(t *testing.T) {
47
51
assert .NoError (t , err )
48
52
49
53
// Give the process more time to start up and initialize all socket servers
50
- time .Sleep (2 * time .Second )
54
+ wgReady .Wait ()
55
+ time .Sleep (1 * time .Second )
51
56
52
57
// Send test messages to each port
53
58
ports := []string {"8475" , "8476" , "8477" }
@@ -59,7 +64,7 @@ func TestLogdyE2E_Socket(t *testing.T) {
59
64
if err == nil {
60
65
break
61
66
}
62
- time .Sleep (100 * time .Millisecond )
67
+ time .Sleep (1 * time .Millisecond )
63
68
}
64
69
assert .NoError (t , err , "Failed to connect to port %s after retries" , port )
65
70
0 commit comments