Merge lp:~mardy/ubuntuone-credentials/fix-token-tests into lp:ubuntuone-credentials

Proposed by Alberto Mardegan on 2016-08-10
Status: Rejected
Rejected by: Natalia Bidart on 2017-05-19
Proposed branch: lp:~mardy/ubuntuone-credentials/fix-token-tests
Merge into: lp:ubuntuone-credentials
Diff against target: 72 lines (+9/-16)
2 files modified
libubuntuoneauth/tests/mock_sso_server.py.in (+1/-0)
libubuntuoneauth/tests/test_token.cpp (+8/-16)
To merge this branch: bzr merge lp:~mardy/ubuntuone-credentials/fix-token-tests
Reviewer Review Type Date Requested Status
unity-api-1-bot continuous-integration Approve on 2016-08-10
Unity API Team 2016-08-10 Pending
Review via email: mp+302551@code.launchpad.net

Commit Message

Tests: make sure the mock server is running before talking to it.

Intead of arbitrarily waiting 2 seconds for the mock server to be up, we make the server write a line to stdout, and we won't start the communication with it until we have received that line in the tests.
Also, terminate the server after the test, otherwise any instance started later will find the port busy.

Description of the Change

Tests: make sure the mock server is running before talking to it.

Intead of arbitrarily waiting 2 seconds for the mock server to be up, we make the server write a line to stdout, and we won't start the communication with it until we have received that line in the tests.
Also, terminate the server after the test, otherwise any instance started later will find the port busy.

To post a comment you must log in.
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:248
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntuone-credentials-ci/14/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/338
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/344
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/268
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/268
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/268
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/198
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/198/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/198
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/198/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/198
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/198/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/198
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/198/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/198
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/198/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/198
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/198/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/198
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/198/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/198
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/198/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/198
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/198/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntuone-credentials-ci/14/rebuild

review: Approve (continuous-integration)
Natalia Bidart (nataliabidart) wrote :

Started a massive cleanup of old MPs, closing this given its age, please update and re-open if still valid.

Unmerged revisions

248. By Alberto Mardegan on 2016-08-10

Tests: make sure the mock server is running before talking to it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libubuntuoneauth/tests/mock_sso_server.py.in'
2--- libubuntuoneauth/tests/mock_sso_server.py.in 2015-12-07 21:17:00 +0000
3+++ libubuntuoneauth/tests/mock_sso_server.py.in 2016-08-10 13:40:39 +0000
4@@ -45,6 +45,7 @@
5 def run_server():
6 server_address = ('', 8000)
7 httpd = HTTPServer(server_address, MyHandler)
8+ print('Ready', flush=True)
9 while True:
10 httpd.handle_request()
11
12
13=== modified file 'libubuntuoneauth/tests/test_token.cpp'
14--- libubuntuoneauth/tests/test_token.cpp 2016-04-27 08:12:44 +0000
15+++ libubuntuoneauth/tests/test_token.cpp 2016-08-10 13:40:39 +0000
16@@ -141,24 +141,20 @@
17 QDateTime result;
18 QTimer::singleShot(0, [this, &result, &_app](){
19 process = new QProcess(this);
20- QSignalSpy spy(process, SIGNAL(started()));
21 QString program = "python3";
22 QString script = QDir::currentPath() + "/mock_sso_server.py";
23 process->start(program, QStringList() << script);
24- QTRY_COMPARE(spy.count(), 1);
25+ QVERIFY(process->waitForStarted());
26
27 // Wait for server to start
28- QTimer timer;
29- QSignalSpy spy2(&timer, SIGNAL(timeout()));
30- timer.setInterval(2000);
31- timer.setSingleShot(true);
32- timer.start();
33- QTRY_COMPARE(spy2.count(), 1);
34+ QVERIFY(process->waitForReadyRead());
35+ QCOMPARE(process->readLine(), QByteArrayLiteral("Ready\n"));
36
37 Token *token = new Token("a", "b", "c", "d");
38 result = token->getServerTimestamp();
39 delete token;
40
41+ process->terminate();
42 _app->quit();
43 });
44
45@@ -178,24 +174,20 @@
46 QDateTime result;
47 QTimer::singleShot(0, [this, &result, &_app](){
48 process = new QProcess(this);
49- QSignalSpy spy(process, SIGNAL(started()));
50 QString program = "python3";
51 QString script = QDir::currentPath() + "/mock_sso_server.py";
52 process->start(program, QStringList() << script);
53- QTRY_COMPARE(spy.count(), 1);
54+ QVERIFY(process->waitForStarted());
55
56 // Wait for server to start
57- QTimer timer;
58- QSignalSpy spy2(&timer, SIGNAL(timeout()));
59- timer.setInterval(2000);
60- timer.setSingleShot(true);
61- timer.start();
62- QTRY_COMPARE(spy2.count(), 1);
63+ QVERIFY(process->waitForReadyRead());
64+ QCOMPARE(process->readLine(), QByteArrayLiteral("Ready\n"));
65
66 Token *token = new Token("a", "b", "c", "d");
67 result = token->getServerTimestamp();
68 delete token;
69
70+ process->terminate();
71 _app->quit();
72 });
73

Subscribers

People subscribed via source and target branches