Skip to content

Commit c53d1d8

Browse files
committed
wait for elasticsearch to be ready in travis
If the prereq installation happens fast enough, such as if it is pulling from cache, Elasticsearch may not be fully started by the time the tests start running. Do a simple check for if it is up, waiting up to 30 seconds, before proceeding.
1 parent 679d550 commit c53d1d8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ install:
7171

7272
before_script:
7373
- "perl -i -pe 's/(servers :)9900/localhost:9200/' metacpan_server_testing.conf"
74+
- bin/wait-for-open http://localhost:9200/
7475
- coverage-setup
7576

7677
script:

bin/wait-for-open

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env perl
2+
use strict;
3+
use warnings;
4+
5+
my $server = shift;
6+
7+
my $timeout = 30;
8+
while ($timeout--) {
9+
if (!system "curl -s '$server' 2>/dev/null 1>&2") {
10+
exit 0;
11+
}
12+
sleep 1;
13+
}
14+
15+
print STDERR "Timed out starting elasticsearch!\n";
16+
exit 1;

0 commit comments

Comments
 (0)