Skip to content

Commit e3d3ed2

Browse files
committed
Merge pull request #386 from opdemand/fix-example-tests
Integration suite for example apps
2 parents 83af0a4 + 030d0de commit e3d3ed2

2 files changed

Lines changed: 34 additions & 19 deletions

File tree

client/tests/test_examples.py

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from uuid import uuid4
1111

1212
import pexpect
13+
import time
14+
1315
from .utils import DEIS
1416
from .utils import DEIS_TEST_FLAVOR
1517
from .utils import EXAMPLES
@@ -53,15 +55,15 @@ def tearDownClass(cls):
5355
child.expect(pexpect.EOF)
5456
purge(cls.username, cls.password)
5557

56-
def _test_example(self, repo_name):
58+
def _test_example(self, repo_name, build_timeout=120, run_timeout=60):
5759
# `git clone` the example app repository
58-
repo_type, repo_url = EXAMPLES[repo_name]
60+
_repo_type, repo_url = EXAMPLES[repo_name]
5961
# print repo_name, repo_type, repo_url
6062
clone(repo_url, repo_name)
6163
# create an App
6264
child = pexpect.spawn("{} create --formation={}".format(
6365
DEIS, self.formation))
64-
child.expect('done, created (?P<name>[-_\w]+)', timeout=3 * 60)
66+
child.expect('done, created (?P<name>[-_\w]+)', timeout=60)
6567
app = child.match.group('name')
6668
try:
6769
child.expect('Git remote deis added')
@@ -70,23 +72,35 @@ def _test_example(self, repo_name):
7072
# check git output for repo_type, e.g. "Clojure app detected"
7173
# TODO: for some reason, the next regex times out...
7274
# child.expect("{} app detected".format(repo_type), timeout=5 * 60)
73-
child.expect('Launching... ', timeout=10 * 60)
74-
child.expect('deployed to Deis(?P<url>.+)To learn more', timeout=3 * 60)
75+
child.expect('Launching... ', timeout=build_timeout)
76+
child.expect('deployed to Deis(?P<url>.+)To learn more', timeout=run_timeout)
7577
url = child.match.group('url')
7678
child.expect(' -> master')
77-
child.expect(pexpect.EOF, timeout=2 * 60)
78-
# fetch the URL with curl and check the output
79-
child = pexpect.spawn("curl -s {}".format(url))
80-
child.expect('Powered by Deis')
81-
child.expect(pexpect.EOF)
79+
child.expect(pexpect.EOF, timeout=10)
80+
# try to fetch the URL with curl a few times, ignoring 502's
81+
for _ in range(6):
82+
child = pexpect.spawn("curl -s {}".format(url))
83+
i = child.expect(['Powered by Deis', '502 Bad Gateway'], timeout=5)
84+
child.expect(pexpect.EOF)
85+
if i == 0:
86+
break
87+
time.sleep(10)
88+
else:
89+
raise RuntimeError('Persistent 502 Bad Gateway')
8290
# `deis config:set POWERED_BY="Automated Testing"`
8391
child = pexpect.spawn(
8492
"{} config:set POWERED_BY='Automated Testing'".format(DEIS))
8593
child.expect(pexpect.EOF, timeout=3 * 60)
8694
# then re-fetch the URL with curl and recheck the output
87-
child = pexpect.spawn("curl -s {}".format(url))
88-
child.expect('Powered by Automated Testing')
89-
child.expect(pexpect.EOF)
95+
for _ in range(6):
96+
child = pexpect.spawn("curl -s {}".format(url))
97+
child.expect(['Powered by Automated Testing', '502 Bad Gateway'], timeout=5)
98+
child.expect(pexpect.EOF)
99+
if i == 0:
100+
break
101+
time.sleep(10)
102+
else:
103+
raise RuntimeError('Config:set not working')
90104
finally:
91105
# destroy the app
92106
child = pexpect.spawn(
@@ -98,7 +112,8 @@ def _test_example(self, repo_name):
98112
def test_clojure_ring(self):
99113
self._test_example('example-clojure-ring')
100114

101-
def test_dart(self):
115+
def _test_dart(self):
116+
# TODO: fix broken buildpack / example app
102117
self._test_example('example-dart')
103118

104119
def test_go(self):
@@ -111,13 +126,14 @@ def test_nodejs_express(self):
111126
self._test_example('example-nodejs-express')
112127

113128
def test_perl(self):
114-
self._test_example('example-perl')
129+
self._test_example('example-perl', build_timeout=600)
115130

116131
def test_php(self):
117132
self._test_example('example-php')
118133

119-
def test_play(self):
120-
self._test_example('example-play')
134+
def _test_play(self):
135+
# TODO: fix broken buildpack / example app
136+
self._test_example('example-play', build_timeout=720)
121137

122138
def test_python_flask(self):
123139
self._test_example('example-python-flask')
@@ -126,4 +142,4 @@ def test_ruby_sinatra(self):
126142
self._test_example('example-ruby-sinatra')
127143

128144
def test_scala(self):
129-
self._test_example('example-scala')
145+
self._test_example('example-scala', build_timeout=720)

client/tests/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44

55
from __future__ import unicode_literals
6-
import os
76
import os.path
87
import random
98
import re

0 commit comments

Comments
 (0)