@@ -120,7 +120,27 @@ func (d *CliDeployer) Deploy(ctx context.Context) error {
120
120
return err
121
121
}
122
122
123
- var urlRegex = regexp .MustCompile (`will be available at:\s*.*?(https://[^\s]+)` )
123
+ var urlRegex = regexp .MustCompile (`DEPLOYMENT_COMPLETED\s*([^\s]+)` )
124
+ var internalURLRegex = regexp .MustCompile (`\.internal:\d+$` )
125
+
126
+ func findUrlsInOutput (output string ) []string {
127
+ var urls []string
128
+ match := urlRegex .FindAllStringSubmatch (output , - 1 )
129
+ for _ , m := range match {
130
+ if m [1 ] == "" {
131
+ continue
132
+ }
133
+ if internalURLRegex .MatchString (m [1 ]) {
134
+ log .Printf ("Skipping internal URL %v" , m [1 ])
135
+ continue
136
+ }
137
+ // Check if the URL starts with a scheme (http, https, etc.)
138
+ if strings .HasPrefix (m [1 ], "https://" ) {
139
+ urls = append (urls , m [1 ])
140
+ }
141
+ }
142
+ return urls
143
+ }
124
144
125
145
func (d * CliDeployer ) RunDeployTest (ctx context.Context , t test.TestInfo ) (* test.ItemResult , error ) {
126
146
log := d .Logger
@@ -155,22 +175,6 @@ func (d *CliDeployer) RunDeployTest(ctx context.Context, t test.TestInfo) (*test
155
175
},
156
176
}
157
177
158
- d .RunCommand (cmdCtx , func (cmd * exec.Cmd ) {
159
- if t .Stdout != nil {
160
- cmd .Stdout = io .MultiWriter (& d .Stdout , t .Stdout , detector )
161
- } else {
162
- cmd .Stdout = io .MultiWriter (& d .Stdout , detector )
163
- }
164
- if t .Stderr != nil {
165
- cmd .Stderr = io .MultiWriter (& d .Stderr , t .Stderr , detector )
166
- } else {
167
- cmd .Stderr = io .MultiWriter (& d .Stderr , detector )
168
- }
169
- cmd .Cancel = func () error {
170
- return cmd .Process .Signal (os .Interrupt ) // Use interrupt signal to stop the command when context is cancelled
171
- }
172
- }, "defang" , "-C" , "/tmp/" , "compose" , "down" , "--detach" )
173
-
174
178
d .HasDeployed = true
175
179
start := time .Now ()
176
180
cmd , err := d .RunCommand (cmdCtx , func (cmd * exec.Cmd ) {
@@ -204,10 +208,11 @@ func (d *CliDeployer) RunDeployTest(ctx context.Context, t test.TestInfo) (*test
204
208
result .DeploySucceeded = cmd .ProcessState .Success ()
205
209
}
206
210
207
- var urls []string
208
- match := urlRegex .FindAllStringSubmatch (d .Stdout .String (), - 1 )
209
- for _ , m := range match {
210
- urls = append (urls , m [1 ])
211
+ urls := findUrlsInOutput (d .Stdout .String ())
212
+ if len (urls ) == 0 {
213
+ result .Message = "No service URLs found in deployment output"
214
+ log .Printf (result .Message )
215
+ return result , fmt .Errorf (result .Message )
211
216
}
212
217
213
218
result .TotalServices = len (urls )
0 commit comments