Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
87c6604b
Commit
87c6604b
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
misc: add test for api readiness
parent
8ef61e77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
test/api-startup/main.go
test/api-startup/main.go
+34
-0
No files found.
test/api-startup/main.go
0 → 100644
View file @
87c6604b
package
main
import
(
"fmt"
"log"
"net/http"
"sync"
"time"
)
func
main
()
{
when
:=
make
(
chan
(
time
.
Time
),
2
)
var
wg
sync
.
WaitGroup
wg
.
Add
(
2
)
for
_
,
port
:=
range
[]
string
{
"5001"
,
"8080"
}
{
go
func
(
port
string
)
{
defer
wg
.
Done
()
for
{
r
,
err
:=
http
.
Get
(
fmt
.
Sprintf
(
"http://127.0.0.1:%s"
,
port
))
if
err
!=
nil
{
continue
}
t
:=
time
.
Now
()
when
<-
t
log
.
Println
(
port
,
t
,
r
.
StatusCode
)
break
}
}(
port
)
}
wg
.
Wait
()
first
:=
<-
when
second
:=
<-
when
log
.
Println
(
second
.
Sub
(
first
))
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment