Merge lp:~michihenning/unity-scopes-api/fix-dns-timeout into lp:unity-scopes-api

Proposed by Michi Henning
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 312
Merged at revision: 313
Proposed branch: lp:~michihenning/unity-scopes-api/fix-dns-timeout
Merge into: lp:unity-scopes-api
Diff against target: 104 lines (+19/-16)
2 files modified
test/gtest/scopes/qt/JsonAsyncReader/JsonAsyncReader_test.cpp (+15/-12)
test/gtest/scopes/qt/XmlAsyncReader/XmlAsyncReader_test.cpp (+4/-4)
To merge this branch: bzr merge lp:~michihenning/unity-scopes-api/fix-dns-timeout
Reviewer Review Type Date Requested Status
Paweł Stołowski (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+249432@code.launchpad.net

Commit message

Fixed sporadic failure in JsonAsyncReader test caused by slow DNS.
Improved tests to report exception details if an exception other than
the expected one is thrown.

Description of the change

Fixed sporadic failure in JsonAsyncReader test caused by slow DNS.
Improved tests to report exception details if an exception other than
the expected one is thrown.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Paweł Stołowski (stolowski) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'test/gtest/scopes/qt/JsonAsyncReader/JsonAsyncReader_test.cpp'
2--- test/gtest/scopes/qt/JsonAsyncReader/JsonAsyncReader_test.cpp 2014-12-18 09:44:25 +0000
3+++ test/gtest/scopes/qt/JsonAsyncReader/JsonAsyncReader_test.cpp 2015-02-12 00:22:37 +0000
4@@ -35,8 +35,7 @@
5
6 class ExceptionsTest : public ::testing::Test
7 {
8-protected:
9- virtual void SetUp()
10+protected: virtual void SetUp()
11 {
12 fake_server_ = posix::exec(FAKE_SERVER, {}, {}, posix::StandardStream::stdout);
13
14@@ -104,14 +103,14 @@
15 auto items = HttpAsyncReader::get_or_throw(reader_future);
16 FAIL();
17 }
18- catch (unity::LogicException& e)
19+ catch (unity::LogicException const& e)
20 {
21 std::string error_msg = e.what();
22 EXPECT_EQ(error_msg.find("<title>404 Not Found</title>") != std::string::npos, true);
23 }
24- catch (...)
25+ catch (std::exception const& e)
26 {
27- FAIL();
28+ FAIL() << e.what();
29 }
30 }
31 TEST(BadUrlException, state)
32@@ -125,14 +124,18 @@
33 auto items = HttpAsyncReader::get_or_throw(reader_future);
34 FAIL();
35 }
36- catch (unity::LogicException& e)
37+ catch (unity::LogicException const& e)
38 {
39 std::string error_msg = e.what();
40 EXPECT_EQ(error_msg.find("Couldn't resolve host name") != std::string::npos, true);
41 }
42- catch (...)
43- {
44- FAIL();
45+ catch (unity::scopes::TimeoutException const&)
46+ {
47+ // This can happen occasionally when DNS is slow
48+ }
49+ catch (std::exception const& e)
50+ {
51+ FAIL() << e.what();
52 }
53 }
54
55@@ -179,15 +182,15 @@
56 JsonReader::QJsonDocumentSptr doc = reader.read(QString(fake_server_host.c_str()), parameters);
57 FAIL();
58 }
59- catch (unity::LogicException& e)
60+ catch (unity::LogicException const& e)
61 {
62 std::string error_msg = e.what();
63 EXPECT_EQ(error_msg.find("error obtaining parser: JsonAsyncReader::create_parser_with_data: illegal value") !=
64 std::string::npos,
65 true);
66 }
67- catch (...)
68+ catch (std::exception const& e)
69 {
70- FAIL();
71+ FAIL() << e.what();
72 }
73 }
74
75=== modified file 'test/gtest/scopes/qt/XmlAsyncReader/XmlAsyncReader_test.cpp'
76--- test/gtest/scopes/qt/XmlAsyncReader/XmlAsyncReader_test.cpp 2015-02-04 20:57:38 +0000
77+++ test/gtest/scopes/qt/XmlAsyncReader/XmlAsyncReader_test.cpp 2015-02-12 00:22:37 +0000
78@@ -117,14 +117,14 @@
79 auto items = HttpAsyncReader::get_or_throw(reader_future);
80 FAIL();
81 }
82- catch (unity::LogicException& e)
83+ catch (unity::LogicException const& e)
84 {
85 std::string error_msg = e.what();
86 EXPECT_EQ(error_msg.find("Couldn't resolve host name") != std::string::npos, true);
87 }
88- catch (...)
89+ catch (std::exception const& e)
90 {
91- FAIL();
92+ FAIL() << e.what();
93 }
94 }
95
96@@ -205,7 +205,7 @@
97 auto reader_future = reader.async_get<Client::Result>(fake_server_host.c_str(), parameters, "track");
98 auto items = HttpAsyncReader::get_or_throw(reader_future, 10);
99 }
100- catch (unity::LogicException& e)
101+ catch (unity::LogicException const& e)
102 {
103 EXPECT_STREQ(e.what(),
104 "unity::LogicException: AsyncReader::async_get: error parsing data: get_results: ERROR: Opening "

Subscribers

People subscribed via source and target branches

to all changes: