@@ -63,19 +63,54 @@ func getNamespaceName(t *testing.T) string {
63
63
return namespaces [0 ]
64
64
}
65
65
66
+ //func getChildProcessPID(t *testing.T) int {
67
+ // // Option 1: Look for processes with CHILD=true
68
+ // cmd := exec.Command("pgrep", "-f", "CHILD=true")
69
+ // output, err := cmd.CombinedOutput()
70
+ // require.NoError(t, err, "output: %v", output)
71
+ //
72
+ // pidStr := strings.TrimSpace(string(output))
73
+ // pid, err := strconv.Atoi(pidStr)
74
+ // require.NoError(t, err)
75
+ // return pid
76
+ //
77
+ // // Option 2: Use the boundary process's child PID
78
+ // // This would require modifying boundary to expose the child PID
79
+ //}
80
+
81
+ //func getBoundaryProcessPID(t *testing.T) int {
82
+ // cmd := exec.Command("pgrep", "-f", "boundary-test")
83
+ // output, err := cmd.Output()
84
+ // require.NoError(t, err)
85
+ //
86
+ // pidStr := strings.TrimSpace(string(output))
87
+ // pid, err := strconv.Atoi(pidStr)
88
+ // require.NoError(t, err)
89
+ // return pid
90
+ //}
91
+ //
92
+ //func getChildProcessPID(t *testing.T) int {
93
+ // boundaryPID := getBoundaryProcessPID(t)
94
+ //
95
+ // cmd := exec.Command("pgrep", "-P", fmt.Sprintf("%d", boundaryPID))
96
+ // output, err := cmd.Output()
97
+ // require.NoError(t, err)
98
+ //
99
+ // pidStr := strings.TrimSpace(string(output))
100
+ // pid, err := strconv.Atoi(pidStr)
101
+ // require.NoError(t, err)
102
+ // return pid
103
+ //}
104
+
66
105
func getChildProcessPID (t * testing.T ) int {
67
- // Option 1: Look for processes with CHILD=true
68
- cmd := exec .Command ("pgrep" , "-f" , "CHILD=true" )
69
- output , err := cmd .CombinedOutput ()
70
- require .NoError (t , err , "output: %v" , output )
106
+ cmd := exec .Command ("pgrep" , "-f" , "boundary-test" , "-n" )
107
+ output , err := cmd .Output ()
108
+ require .NoError (t , err )
71
109
72
110
pidStr := strings .TrimSpace (string (output ))
73
111
pid , err := strconv .Atoi (pidStr )
74
112
require .NoError (t , err )
75
113
return pid
76
-
77
- // Option 2: Use the boundary process's child PID
78
- // This would require modifying boundary to expose the child PID
79
114
}
80
115
81
116
func TestBoundaryIntegration (t * testing.T ) {
@@ -89,34 +124,37 @@ func TestBoundaryIntegration(t *testing.T) {
89
124
require .NoError (t , err , "Failed to build boundary binary" )
90
125
91
126
// Create context for boundary process
92
- ctx , cancel := context .WithTimeout (context .Background (), 15 * time .Second )
127
+ ctx , cancel := context .WithTimeout (context .Background (), 1500 * time .Second )
93
128
defer cancel ()
94
129
95
130
// Start boundary process with sudo
96
131
boundaryCmd := exec .CommandContext (ctx , "/tmp/boundary-test" ,
97
132
"--allow" , "dev.coder.com" ,
98
133
"--allow" , "jsonplaceholder.typicode.com" ,
99
134
"--log-level" , "debug" ,
100
- "--" , "/bin/bash" )
101
- // "--", "/bin/bash", "-c", "/usr/bin/sleep 10 && /usr/bin/echo 'Test completed'")
135
+ // "--", "/bin/bash")
136
+ "--" , "/bin/bash" , "-c" , "/usr/bin/sleep 45 && /usr/bin/echo 'Test completed'" )
102
137
103
- // Suppress output to prevent terminal corruption
104
- boundaryCmd .Stdout = os .Stdout // Let it go to /dev/null
138
+ boundaryCmd . Stdin = os . Stdin
139
+ boundaryCmd .Stdout = os .Stdout
105
140
boundaryCmd .Stderr = os .Stderr
106
141
107
142
// Start the process
108
143
err = boundaryCmd .Start ()
109
144
require .NoError (t , err , "Failed to start boundary process" )
110
145
111
146
// Give boundary time to start
112
- time .Sleep (200 * time .Second )
147
+ time .Sleep (2 * time .Second )
113
148
114
149
// Get the namespace name that boundary created
115
150
//namespaceName := getNamespaceName(t)
116
151
117
152
pidInt := getChildProcessPID (t )
118
153
pid := fmt .Sprintf ("%v" , pidInt )
119
154
155
+ fmt .Printf ("pidInt: %v\n " , pidInt )
156
+ //time.Sleep(200 * time.Second)
157
+
120
158
// Test HTTP request through boundary (from inside the jail)
121
159
t .Run ("HTTPRequestThroughBoundary" , func (t * testing.T ) {
122
160
// Run curl directly in the namespace using ip netns exec
0 commit comments