Skip to content

Commit

Permalink
Fix issue playframework#1463 by restoring behavior --timeout parameter
Browse files Browse the repository at this point in the history
The upgrade to python3 broke the processing of the --timeout parameter
due to a type mismatch (a string was compared to an integer).  The fix
is to always treat the --timeout parameter as a string, deferring to the
test runner to parse it and report errors.

This also fixes a typo in the name of a variable "webclient_timeout"
(it was named "weblcient_timeout").

It also adds some new regression tests for the auto-test functionality.
  • Loading branch information
David Costanzo committed Mar 11, 2024
1 parent 6a07327 commit e4df911
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ samples-and-tests/test-scala/tmp
samples-and-tests/test-scala/logs
samples-and-tests/i-am-a-developer/i-am-working-here
samples-and-tests/i-am-a-developer/i-am-creating-jobs-here
samples-and-tests/i-am-a-developer/i-am-testing-auto-test-here
samples-and-tests/i-am-a-developer/i-am-testing-log-levels-here
samples-and-tests/i-am-a-developer/i-am-testing-ssl-config-here
samples-and-tests/just-test-cases/attachments
Expand Down
10 changes: 5 additions & 5 deletions framework/pym/play/commands/autotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ def autotest(app, args):
add_options.append('-DrunSeleniumTests')

# Handle timeout parameter
weblcient_timeout = -1
webclient_timeout = None
if app.readConf('webclient.timeout'):
weblcient_timeout = app.readConf('webclient.timeout')
webclient_timeout = app.readConf('webclient.timeout')

for arg in args:
if arg.startswith('--timeout='):
args.remove(arg)
weblcient_timeout = arg[10:]
webclient_timeout = arg[10:]

if weblcient_timeout >= 0:
add_options.append('-DwebclientTimeout=' + weblcient_timeout)
if webclient_timeout is not None:
add_options.append('-DwebclientTimeout=' + webclient_timeout)

# Run app
test_result = os.path.join(app.path, 'test-result')
Expand Down
71 changes: 71 additions & 0 deletions samples-and-tests/i-am-a-developer/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,77 @@
class IamADeveloper(unittest.TestCase):
play = None

def testAutoTest(self):
step('Hello, I am testing "play auto-test"')

self.working_directory = bootstrap_working_directory('i-am-testing-auto-test-here')

# play new app
step('Create a new project')

app = '%s/testable-app' % self.working_directory

with call_play(self, ['new', app, '--name=TESTABLEAPP']) as self.play:
self.assertTrue(wait_for(self.play, 'The new application will be created'))
self.assertTrue(wait_for(self.play, 'OK, the application is created'))
self.assertTrue(wait_for(self.play, 'Have fun!'))
self.play.wait()
self.assertEqual(self.play.returncode, 0)

# configure to run on the test port
edit(app, "conf/application.conf", 32, 'http.port=' + DEFAULTS['http.port'])

# play auto-test
step('run with auto-test (the normal way)')

with call_play(self, ['auto-test', app]) as self.play:
# wait for play to be ready
self.assertTrue(wait_for(self.play, 'BasicTest... PASSED '))
self.assertTrue(wait_for(self.play, 'ApplicationTest... PASSED '))
self.assertTrue(wait_for(self.play, 'Application... PASSED '))
self.assertTrue(wait_for(self.play, 'All tests passed'))
self.play.wait()
self.assertEqual(self.play.returncode, 0)

# play autotest is also accepted
step('run with autotest (also accepted)')

with call_play(self, ['autotest', app]) as self.play:
# wait for play to be ready
self.assertTrue(wait_for(self.play, 'BasicTest... PASSED '))
self.assertTrue(wait_for(self.play, 'ApplicationTest... PASSED '))
self.assertTrue(wait_for(self.play, 'Application... PASSED '))
self.assertTrue(wait_for(self.play, 'All tests passed'))
self.play.wait()
self.assertEqual(self.play.returncode, 0)

# Run with a --timeout that is longer than the tests take
step('run with auto-test --timeout=60000')

with call_play(self, ['auto-test', app, "--timeout=60000"]) as self.play:
# wait for play to be ready
self.assertTrue(wait_for(self.play, 'BasicTest... PASSED '))
self.assertTrue(wait_for(self.play, 'ApplicationTest... PASSED '))
self.assertTrue(wait_for(self.play, 'Application... PASSED '))
self.assertTrue(wait_for(self.play, 'All tests passed'))
self.play.wait()
self.assertEqual(self.play.returncode, 0)

# Run with a --timeout that is shorter than the tests take
step('run with auto-test --timeout=1')

with call_play(self, ['auto-test', app, "--timeout=1"]) as self.play:
# wait for play to be ready
self.assertTrue(wait_for(self.play, 'BasicTest... ERROR '))
self.assertTrue(wait_for(self.play, 'ApplicationTest... ERROR '))
self.assertTrue(wait_for(self.play, 'Application... ERROR '))
self.assertTrue(wait_for(self.play, 'Tests did not successfully complete.'))
self.play.wait()
self.assertNotEqual(self.play.returncode, 0)

step("done testing auto-test")
self.play = None

# FIXME
def skipTest_testSSLConfig(self):

Expand Down

0 comments on commit e4df911

Please sign in to comment.