Merge lp:~jonas-drange/ubuntu-system-settings/harden-clickclient-test into lp:ubuntu-system-settings

Proposed by Jonas G. Drange
Status: Needs review
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/harden-clickclient-test
Merge into: lp:ubuntu-system-settings
Diff against target: 118 lines (+15/-10)
3 files modified
tests/plugins/system-update/CMakeLists.txt (+2/-2)
tests/plugins/system-update/mockclickserver.h (+5/-0)
tests/plugins/system-update/tst_clickclient.cpp (+8/-8)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/harden-clickclient-test
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing
Ken VanDine Approve
Review via email: mp+303931@code.launchpad.net

Commit message

* allow tests to use the server spawned by the test case
* drop unnecessary environment variables, use guiless test main()

Description of the change

a server spawned at e.g. port 9010 was never used by the tests, and would cause test failures

To post a comment you must log in.
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks good

review: Approve
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1702
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/136/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1313/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1313
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1177
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1177
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1177
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1157
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1157/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1157/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1157
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1157/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1157
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1157/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1157
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1157/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1157
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1157/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1157
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1157/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1157
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1157/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1157
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1157/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/136/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1702
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/138/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1316/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1316
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1180
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1180
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1180
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1160
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1160/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1160
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1160/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1160/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1160
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1160/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1160
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1160/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1160
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1160/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1160
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1160/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1160
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1160/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1160
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1160/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/138/rebuild

review: Needs Fixing (continuous-integration)
1703. By Jonas G. Drange

sync trunk

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1703
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/141/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1393/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1393
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1252
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1252
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1252
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1248
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1248/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1248
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1248/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1248
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1248/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1248
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1248/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1248
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1248/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1248
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1248/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1248/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1248/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1248
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1248/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/141/rebuild

review: Needs Fixing (continuous-integration)

Unmerged revisions

1703. By Jonas G. Drange

sync trunk

1702. By Jonas G. Drange

make servers at 9010 actually have tests pass

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/plugins/system-update/CMakeLists.txt'
2--- tests/plugins/system-update/CMakeLists.txt 2016-08-11 13:05:45 +0000
3+++ tests/plugins/system-update/CMakeLists.txt 2016-08-31 19:10:48 +0000
4@@ -27,7 +27,7 @@
5 set_tests_properties(
6 tst-clickclient
7 PROPERTIES
8- ENVIRONMENT "IGNORE_CREDENTIALS=1;URL_APPS=http://127.0.0.1:9009/metadata;QT_QPA_PLATFORM=minimal"
9+ ENVIRONMENT "IGNORE_CREDENTIALS=1"
10 )
11
12 add_executable(tst-tokendownloader tst_tokendownloader.cpp)
13@@ -36,7 +36,7 @@
14 set_tests_properties(
15 tst-tokendownloader
16 PROPERTIES
17- ENVIRONMENT "IGNORE_CREDENTIALS=1;URL_APPS=http://127.0.0.1:9009/metadata;"
18+ ENVIRONMENT "IGNORE_CREDENTIALS=1"
19 )
20
21 add_executable(tst-clickmanager tst_clickmanager.cpp)
22
23=== modified file 'tests/plugins/system-update/mockclickserver.h'
24--- tests/plugins/system-update/mockclickserver.h 2016-08-11 12:18:32 +0000
25+++ tests/plugins/system-update/mockclickserver.h 2016-08-31 19:10:48 +0000
26@@ -25,6 +25,10 @@
27 for (int i = 0; i < 5; i++) {
28 QString out(m_mockclickserver.readAllStandardOutput());
29 if (out.contains("Started")) {
30+ m_url = QString("http://127.0.0.1:%1").arg(m_port);
31+ if (!qputenv("URL_APPS", m_url.toLatin1())) {
32+ QFAIL("Could not set URL_APPS.");
33+ }
34 return;
35 }
36 QTest::qWait(1000);
37@@ -50,6 +54,7 @@
38 }
39
40 QProcess m_mockclickserver;
41+ QString m_url = QString::null;
42 uint m_port = 9009;
43 uint m_retries = 0;
44 };
45
46=== modified file 'tests/plugins/system-update/tst_clickclient.cpp'
47--- tests/plugins/system-update/tst_clickclient.cpp 2016-08-01 12:48:08 +0000
48+++ tests/plugins/system-update/tst_clickclient.cpp 2016-08-31 19:10:48 +0000
49@@ -63,7 +63,7 @@
50 void testTokenRequestSuccess()
51 {
52 QSignalSpy tokenRequestSucceededSpy(m_instance, SIGNAL(tokenRequestSucceeded(const QString)));
53- QUrl query("http://localhost:9009/download");
54+ QUrl query(QString("%1/download").arg(m_url));
55 m_instance->requestToken(query);
56 QVERIFY(tokenRequestSucceededSpy.wait());
57 QList<QVariant> args = tokenRequestSucceededSpy.takeFirst();
58@@ -72,7 +72,7 @@
59 void testTokenRequestFailure()
60 {
61 QSignalSpy credentialErrorSpy(m_instance, SIGNAL(tokenRequestSucceeded(const QString)));
62- QUrl query("http://localhost:9009/403");
63+ QUrl query(QString("%1/403").arg(m_url));
64 m_instance->requestToken(query);
65 QVERIFY(credentialErrorSpy.wait());
66 QCOMPARE(credentialErrorSpy.count(), 1);
67@@ -96,7 +96,7 @@
68 QSignalSpy metadataRequestSucceededSpy(
69 m_instance, SIGNAL(metadataRequestSucceeded(const QJsonArray&))
70 );
71- QUrl query("http://localhost:9009/metadata");
72+ QUrl query(QString("%1/metadata").arg(m_url));
73 m_instance->requestMetadata(query, names);
74 QVERIFY(metadataRequestSucceededSpy.wait());
75 QCOMPARE(metadataRequestSucceededSpy.count(), 1);
76@@ -104,7 +104,7 @@
77 void testMetadataRequestAuthFailure()
78 {
79 QSignalSpy credentialErrorSpy(m_instance, SIGNAL(credentialError()));
80- QUrl query("http://localhost:9009/403");
81+ QUrl query(QString("%1/403").arg(m_url));
82 m_instance->requestMetadata(query, QList<QString>());
83 QVERIFY(credentialErrorSpy.wait());
84 QCOMPARE(credentialErrorSpy.count(), 1);
85@@ -112,7 +112,7 @@
86 void testMetadataRequestNotFoundFailure()
87 {
88 QSignalSpy serverErrorSpy(m_instance, SIGNAL(serverError()));
89- QUrl query("http://localhost:9009/404");
90+ QUrl query(QString("%1/404").arg(m_url));
91 m_instance->requestMetadata(query, QList<QString>());
92 QVERIFY(serverErrorSpy.wait());
93 QCOMPARE(serverErrorSpy.count(), 1);
94@@ -125,7 +125,7 @@
95 // We only want “a” to receive a signal.
96 QSignalSpy aSuccessSpy(a, SIGNAL(tokenRequestSucceeded(const QString)));
97 QSignalSpy bSuccessSpy(b, SIGNAL(tokenRequestSucceeded(const QString)));
98- QUrl query("http://localhost:9009/download");
99+ QUrl query(QString("%1/download").arg(m_url));
100 a->requestToken(query);
101 QVERIFY(aSuccessSpy.wait());
102 QCOMPARE(aSuccessSpy.count(), 1);
103@@ -146,7 +146,7 @@
104 QSignalSpy bSuccessSpy(
105 b, SIGNAL(metadataRequestSucceeded(const QJsonArray&))
106 );
107- QUrl query("http://localhost:9009/metadata");
108+ QUrl query(QString("%1/metadata").arg(m_url));
109 a->requestMetadata(query, QList<QString>());
110 QVERIFY(aSuccessSpy.wait());
111 QCOMPARE(aSuccessSpy.count(), 1);
112@@ -160,6 +160,6 @@
113 Network::Manager *m_nam = nullptr;
114 };
115
116-QTEST_MAIN(TstClickApiClient)
117+QTEST_GUILESS_MAIN(TstClickApiClient)
118 #include "tst_clickclient.moc"
119

Subscribers

People subscribed via source and target branches