Merge lp:~marcustomlinson/unity-scopes-api/merge-trunk into lp:unity-scopes-api/devel
- merge-trunk
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Michal Hruby |
Approved revision: | 422 |
Merged at revision: | 421 |
Proposed branch: | lp:~marcustomlinson/unity-scopes-api/merge-trunk |
Merge into: | lp:unity-scopes-api/devel |
Diff against target: |
856 lines (+257/-86) 25 files modified
CONFIGFILES (+4/-4) debian/changelog (+24/-0) include/unity/scopes/internal/DfltConfig.h.in (+3/-3) scoperegistry/scoperegistry.cpp (+69/-2) src/scopes/internal/JsonSettingsSchema.cpp (+1/-1) src/scopes/internal/smartscopes/SSRegistryObject.cpp (+3/-2) src/scopes/internal/zmq_middleware/ZmqConfig.cpp (+2/-2) src/scopes/internal/zmq_middleware/ZmqMiddleware.cpp (+1/-1) src/scopes/internal/zmq_middleware/ZmqObject.cpp (+32/-35) test/gtest/scopes/Activation/Activation_test.cpp (+18/-1) test/gtest/scopes/Activation/Runtime.ini.in (+1/-1) test/gtest/scopes/Filters/Filters_test.cpp (+18/-1) test/gtest/scopes/Filters/Runtime.ini.in (+1/-1) test/gtest/scopes/IdleShutdown/IdleShutdown_test.cpp (+14/-0) test/gtest/scopes/IdleShutdown/Runtime.ini.in (+1/-1) test/gtest/scopes/Invocation/Invocation_test.cpp (+17/-2) test/gtest/scopes/Invocation/Runtime.ini.in (+1/-1) test/gtest/scopes/Invocation/TestScope.cpp (+1/-1) test/gtest/scopes/Registry/CMakeLists.txt (+1/-0) test/gtest/scopes/Registry/Registry_test.cpp (+4/-4) test/gtest/scopes/Registry/scopes/testscopeA/testscopeA.ini.in (+2/-2) test/gtest/scopes/Runtime/Runtime.ini.in (+1/-1) test/gtest/scopes/Runtime/Runtime_test.cpp (+22/-0) test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp (+6/-10) test/gtest/scopes/internal/zmq_middleware/RegistryI/RegistryI_test.cpp (+10/-10) |
To merge this branch: | bzr merge lp:~marcustomlinson/unity-scopes-api/merge-trunk |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Michal Hruby (community) | Approve | ||
Review via email: mp+228118@code.launchpad.net |
Commit message
Merge trunk.
Description of the change
Merge trunk.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
- 422. By Marcus Tomlinson
-
Whoops, one change that shouldn't have been reverted
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:422
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'CONFIGFILES' | |||
2 | --- CONFIGFILES 2014-07-14 06:54:43 +0000 | |||
3 | +++ CONFIGFILES 2014-07-24 15:00:51 +0000 | |||
4 | @@ -84,7 +84,7 @@ | |||
5 | 84 | or terminate correctly. If a scope does not respond | 84 | or terminate correctly. If a scope does not respond |
6 | 85 | within the allotted time, it is killed with SIGKILL. | 85 | within the allotted time, it is killed with SIGKILL. |
7 | 86 | 86 | ||
9 | 87 | The default value is 2500 milliseconds. | 87 | The default value is 4000 milliseconds. |
10 | 88 | 88 | ||
11 | 89 | Note that this value must be less than Locate.Timeout in the [<Middleware>] | 89 | Note that this value must be less than Locate.Timeout in the [<Middleware>] |
12 | 90 | config group, otherwise the middleware can prematurely conclude that | 90 | config group, otherwise the middleware can prematurely conclude that |
13 | @@ -144,7 +144,7 @@ | |||
14 | 144 | within the specified time, the invocation throws a TimeoutException, possibly | 144 | within the specified time, the invocation throws a TimeoutException, possibly |
15 | 145 | after asking the registry to start the target process first (see Locate.Timeout). | 145 | after asking the registry to start the target process first (see Locate.Timeout). |
16 | 146 | 146 | ||
18 | 147 | The default value is 300 milliseconds. | 147 | The default value is 500 milliseconds. |
19 | 148 | 148 | ||
20 | 149 | - Smartscopes.Registry.EndpointDir | 149 | - Smartscopes.Registry.EndpointDir |
21 | 150 | 150 | ||
22 | @@ -164,11 +164,11 @@ | |||
23 | 164 | in Registry.ini, otherwise invocations on a scope that needs to be activated | 164 | in Registry.ini, otherwise invocations on a scope that needs to be activated |
24 | 165 | first can fail, even though the activation succeeded. | 165 | first can fail, even though the activation succeeded. |
25 | 166 | 166 | ||
27 | 167 | Only values in the range 10 to 5000 milliseconds are accepted. (Values outside | 167 | Only values in the range 10 to 15000 milliseconds are accepted. (Values outside |
28 | 168 | this range would either cause locate() to falsely conclude that a scope | 168 | this range would either cause locate() to falsely conclude that a scope |
29 | 169 | could not be started, or cause an unacceptably long wait time.) | 169 | could not be started, or cause an unacceptably long wait time.) |
30 | 170 | 170 | ||
32 | 171 | The default value is 3000 milliseconds. | 171 | The default value is 5000 milliseconds. |
33 | 172 | 172 | ||
34 | 173 | - Registry.Timeout | 173 | - Registry.Timeout |
35 | 174 | 174 | ||
36 | 175 | 175 | ||
37 | === modified file 'debian/changelog' | |||
38 | --- debian/changelog 2014-07-23 14:12:45 +0000 | |||
39 | +++ debian/changelog 2014-07-24 15:00:51 +0000 | |||
40 | @@ -5,6 +5,30 @@ | |||
41 | 5 | 5 | ||
42 | 6 | -- Marcus Tomlinson <marcus.tomlinson@canonical.com> Mon, 21 Jul 2014 09:14:39 +0200 | 6 | -- Marcus Tomlinson <marcus.tomlinson@canonical.com> Mon, 21 Jul 2014 09:14:39 +0200 |
43 | 7 | 7 | ||
44 | 8 | unity-scopes-api (0.5.2+14.10.20140723-0ubuntu1) utopic; urgency=low | ||
45 | 9 | |||
46 | 10 | [ Pete Woods ] | ||
47 | 11 | * Normalize relative paths (LP: #1340135) | ||
48 | 12 | |||
49 | 13 | [ Marcus Tomlinson ] | ||
50 | 14 | * Call locate() before every two-way request. Increased two-way | ||
51 | 15 | invocation timeouts. | ||
52 | 16 | |||
53 | 17 | [ Michi Henning ] | ||
54 | 18 | * Normalize relative paths (LP: #1340135) | ||
55 | 19 | |||
56 | 20 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 23 Jul 2014 22:06:06 +0000 | ||
57 | 21 | |||
58 | 22 | unity-scopes-api (0.5.2+14.10.20140722-0ubuntu1) utopic; urgency=low | ||
59 | 23 | |||
60 | 24 | [ thomas-voss ] | ||
61 | 25 | * Force building with g++ 4.9 | ||
62 | 26 | |||
63 | 27 | [ Michi Henning ] | ||
64 | 28 | * Force building with g++ 4.9 | ||
65 | 29 | |||
66 | 30 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Tue, 22 Jul 2014 09:52:30 +0000 | ||
67 | 31 | |||
68 | 8 | unity-scopes-api (0.5.2+14.10.20140715-0ubuntu1) utopic; urgency=low | 32 | unity-scopes-api (0.5.2+14.10.20140715-0ubuntu1) utopic; urgency=low |
69 | 9 | 33 | ||
70 | 10 | [ Michal Hruby ] | 34 | [ Michal Hruby ] |
71 | 11 | 35 | ||
72 | === modified file 'include/unity/scopes/internal/DfltConfig.h.in' | |||
73 | --- include/unity/scopes/internal/DfltConfig.h.in 2014-07-14 06:54:43 +0000 | |||
74 | +++ include/unity/scopes/internal/DfltConfig.h.in 2014-07-24 15:00:51 +0000 | |||
75 | @@ -49,9 +49,9 @@ | |||
76 | 49 | 49 | ||
77 | 50 | static const int DFLT_REAP_EXPIRY = 45; // seconds | 50 | static const int DFLT_REAP_EXPIRY = 45; // seconds |
78 | 51 | static const int DFLT_REAP_INTERVAL = 10; // seconds | 51 | static const int DFLT_REAP_INTERVAL = 10; // seconds |
82 | 52 | static const int DFLT_PROCESS_TIMEOUT = 2500; // milliseconds | 52 | static const int DFLT_PROCESS_TIMEOUT = 4000; // milliseconds |
83 | 53 | static const int DFLT_ZMQ_TWOWAY_TIMEOUT = 300; // milliseconds | 53 | static const int DFLT_ZMQ_TWOWAY_TIMEOUT = 500; // milliseconds |
84 | 54 | static const int DFLT_ZMQ_LOCATE_TIMEOUT = 3000; // milliseconds | 54 | static const int DFLT_ZMQ_LOCATE_TIMEOUT = 5000; // milliseconds |
85 | 55 | static const int DFLT_ZMQ_REGISTRY_TIMEOUT = 5000; // milliseconds | 55 | static const int DFLT_ZMQ_REGISTRY_TIMEOUT = 5000; // milliseconds |
86 | 56 | 56 | ||
87 | 57 | } // namespace internal | 57 | } // namespace internal |
88 | 58 | 58 | ||
89 | === modified file 'scoperegistry/scoperegistry.cpp' | |||
90 | --- scoperegistry/scoperegistry.cpp 2014-07-15 05:50:10 +0000 | |||
91 | +++ scoperegistry/scoperegistry.cpp 2014-07-24 15:00:51 +0000 | |||
92 | @@ -235,6 +235,44 @@ | |||
93 | 235 | return click_scopes; | 235 | return click_scopes; |
94 | 236 | } | 236 | } |
95 | 237 | 237 | ||
96 | 238 | static bool starts_with(const string& compare, const string& prefix) | ||
97 | 239 | { | ||
98 | 240 | bool result = false; | ||
99 | 241 | if (compare.length() >= prefix.length()) | ||
100 | 242 | { | ||
101 | 243 | result = (compare.compare(0, prefix.length(), prefix) == 0); | ||
102 | 244 | } | ||
103 | 245 | return result; | ||
104 | 246 | } | ||
105 | 247 | |||
106 | 248 | static bool is_uri(const string& path) | ||
107 | 249 | { | ||
108 | 250 | return starts_with(path, "color://") | ||
109 | 251 | || starts_with(path, "file://") | ||
110 | 252 | || starts_with(path, "ftp://") | ||
111 | 253 | || starts_with(path, "gradient://") | ||
112 | 254 | || starts_with(path, "http://") | ||
113 | 255 | || starts_with(path, "https://") | ||
114 | 256 | || starts_with(path, "image://"); | ||
115 | 257 | } | ||
116 | 258 | |||
117 | 259 | void convert_relative_attribute(VariantMap& inner_map, const string& id, const filesystem::path& scope_dir) | ||
118 | 260 | { | ||
119 | 261 | auto logo_it = inner_map.find(id); | ||
120 | 262 | if (logo_it != inner_map.end() | ||
121 | 263 | && logo_it->second.which() == Variant::String) | ||
122 | 264 | { | ||
123 | 265 | auto path = logo_it->second.get_string(); | ||
124 | 266 | |||
125 | 267 | // Do not normalize supported URI schemas | ||
126 | 268 | if(!is_uri(path)) | ||
127 | 269 | { | ||
128 | 270 | logo_it->second = Variant( | ||
129 | 271 | relative_scope_path_to_abs_path(path, scope_dir).native()); | ||
130 | 272 | } | ||
131 | 273 | } | ||
132 | 274 | } | ||
133 | 275 | |||
134 | 238 | // For each scope, open the config file for the scope, create the metadata info from the config, | 276 | // For each scope, open the config file for the scope, create the metadata info from the config, |
135 | 239 | // and add an entry to the RegistryObject. | 277 | // and add an entry to the RegistryObject. |
136 | 240 | // If the scope uses settings, also parse the settings file and add the settings to the metadata. | 278 | // If the scope uses settings, also parse the settings file and add the settings to the metadata. |
137 | @@ -277,20 +315,49 @@ | |||
138 | 277 | mi->set_author(sc.author()); | 315 | mi->set_author(sc.author()); |
139 | 278 | mi->set_invisible(sc.invisible()); | 316 | mi->set_invisible(sc.invisible()); |
140 | 279 | mi->set_appearance_attributes(sc.appearance_attributes()); | 317 | mi->set_appearance_attributes(sc.appearance_attributes()); |
141 | 318 | |||
142 | 319 | // Prepend scope_dir to pageheader logo path if logo path is relative. | ||
143 | 320 | // TODO: Once we have type-safe parsing in the config files, remove | ||
144 | 321 | // the calls to which(). We should be able to rely on things | ||
145 | 322 | // having the correct type. That's the whole point of having | ||
146 | 323 | // the *Config classes. | ||
147 | 324 | auto app_attrs = sc.appearance_attributes(); | ||
148 | 325 | auto ph_it = app_attrs.find("page-header"); | ||
149 | 326 | if (ph_it != app_attrs.end() && ph_it->second.which() == Variant::Dict) | ||
150 | 327 | { | ||
151 | 328 | auto inner_map = ph_it->second.get_dict(); | ||
152 | 329 | convert_relative_attribute(inner_map, "logo", scope_dir); | ||
153 | 330 | convert_relative_attribute(inner_map, "background", scope_dir); | ||
154 | 331 | convert_relative_attribute(inner_map, "navigation-background", scope_dir); | ||
155 | 332 | app_attrs["page-header"] = Variant(inner_map); | ||
156 | 333 | } | ||
157 | 334 | convert_relative_attribute(app_attrs, "category-header-background", scope_dir); | ||
158 | 335 | mi->set_appearance_attributes(app_attrs); | ||
159 | 336 | |||
160 | 280 | mi->set_scope_directory(scope_dir.native()); | 337 | mi->set_scope_directory(scope_dir.native()); |
161 | 281 | mi->set_results_ttl_type(sc.results_ttl_type()); | 338 | mi->set_results_ttl_type(sc.results_ttl_type()); |
162 | 282 | mi->set_location_data_needed(sc.location_data_needed()); | 339 | mi->set_location_data_needed(sc.location_data_needed()); |
163 | 283 | 340 | ||
164 | 284 | try | 341 | try |
165 | 285 | { | 342 | { |
167 | 286 | mi->set_art(relative_scope_path_to_abs_path(sc.art(), scope_dir).native()); | 343 | auto art = sc.art(); |
168 | 344 | if (!is_uri(art)) | ||
169 | 345 | { | ||
170 | 346 | art = relative_scope_path_to_abs_path(art, scope_dir).native(); | ||
171 | 347 | } | ||
172 | 348 | mi->set_art(art); | ||
173 | 287 | } | 349 | } |
174 | 288 | catch (NotFoundException const&) | 350 | catch (NotFoundException const&) |
175 | 289 | { | 351 | { |
176 | 290 | } | 352 | } |
177 | 291 | try | 353 | try |
178 | 292 | { | 354 | { |
180 | 293 | mi->set_icon(relative_scope_path_to_abs_path(sc.icon(), scope_dir).native()); | 355 | auto icon = sc.icon(); |
181 | 356 | if (!is_uri(icon)) | ||
182 | 357 | { | ||
183 | 358 | icon = relative_scope_path_to_abs_path(icon, scope_dir).native(); | ||
184 | 359 | } | ||
185 | 360 | mi->set_icon(icon); | ||
186 | 294 | } | 361 | } |
187 | 295 | catch (NotFoundException const&) | 362 | catch (NotFoundException const&) |
188 | 296 | { | 363 | { |
189 | 297 | 364 | ||
190 | === modified file 'src/scopes/internal/JsonSettingsSchema.cpp' | |||
191 | --- src/scopes/internal/JsonSettingsSchema.cpp 2014-07-16 08:42:30 +0000 | |||
192 | +++ src/scopes/internal/JsonSettingsSchema.cpp 2014-07-24 15:00:51 +0000 | |||
193 | @@ -49,7 +49,7 @@ | |||
194 | 49 | public: | 49 | public: |
195 | 50 | NONCOPYABLE(Setting); | 50 | NONCOPYABLE(Setting); |
196 | 51 | 51 | ||
198 | 52 | explicit Setting(Json::Value const& v); | 52 | Setting(Json::Value const& v); |
199 | 53 | ~Setting() = default; | 53 | ~Setting() = default; |
200 | 54 | 54 | ||
201 | 55 | string id() const; | 55 | string id() const; |
202 | 56 | 56 | ||
203 | === modified file 'src/scopes/internal/smartscopes/SSRegistryObject.cpp' | |||
204 | --- src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-07-04 04:50:38 +0000 | |||
205 | +++ src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-07-24 15:00:51 +0000 | |||
206 | @@ -124,9 +124,10 @@ | |||
207 | 124 | return scopes_; | 124 | return scopes_; |
208 | 125 | } | 125 | } |
209 | 126 | 126 | ||
211 | 127 | ObjectProxy SSRegistryObject::locate(std::string const& /*identity*/) | 127 | ObjectProxy SSRegistryObject::locate(std::string const& identity) |
212 | 128 | { | 128 | { |
214 | 129 | throw internal::RegistryException("SSRegistryObject::locate(): operation not available"); | 129 | // Smart Scopes are not fork and execed, so we simply return the proxy here |
215 | 130 | return get_metadata(identity).proxy(); | ||
216 | 130 | } | 131 | } |
217 | 131 | 132 | ||
218 | 132 | bool SSRegistryObject::is_scope_running(std::string const&) | 133 | bool SSRegistryObject::is_scope_running(std::string const&) |
219 | 133 | 134 | ||
220 | === modified file 'src/scopes/internal/zmq_middleware/ZmqConfig.cpp' | |||
221 | --- src/scopes/internal/zmq_middleware/ZmqConfig.cpp 2014-07-14 06:54:43 +0000 | |||
222 | +++ src/scopes/internal/zmq_middleware/ZmqConfig.cpp 2014-07-24 15:00:51 +0000 | |||
223 | @@ -80,9 +80,9 @@ | |||
224 | 80 | } | 80 | } |
225 | 81 | 81 | ||
226 | 82 | locate_timeout_ = get_optional_int(zmq_config_group, locate_timeout_key, DFLT_ZMQ_LOCATE_TIMEOUT); | 82 | locate_timeout_ = get_optional_int(zmq_config_group, locate_timeout_key, DFLT_ZMQ_LOCATE_TIMEOUT); |
228 | 83 | if (locate_timeout_ < 10 || locate_timeout_ > 5000) | 83 | if (locate_timeout_ < 10 || locate_timeout_ > 15000) |
229 | 84 | { | 84 | { |
231 | 85 | throw_ex("Illegal value (" + to_string(locate_timeout_) + ") for " + locate_timeout_key + ": value must be 10-5000"); | 85 | throw_ex("Illegal value (" + to_string(locate_timeout_) + ") for " + locate_timeout_key + ": value must be 10-15000"); |
232 | 86 | } | 86 | } |
233 | 87 | 87 | ||
234 | 88 | registry_endpoint_dir_ = get_optional_string(zmq_config_group, registry_endpoint_dir_key); | 88 | registry_endpoint_dir_ = get_optional_string(zmq_config_group, registry_endpoint_dir_key); |
235 | 89 | 89 | ||
236 | === modified file 'src/scopes/internal/zmq_middleware/ZmqMiddleware.cpp' | |||
237 | --- src/scopes/internal/zmq_middleware/ZmqMiddleware.cpp 2014-07-16 08:46:47 +0000 | |||
238 | +++ src/scopes/internal/zmq_middleware/ZmqMiddleware.cpp 2014-07-24 15:00:51 +0000 | |||
239 | @@ -863,7 +863,7 @@ | |||
240 | 863 | endpoint = "ipc://" + endpoint_dir + "/" + name; | 863 | endpoint = "ipc://" + endpoint_dir + "/" + name; |
241 | 864 | } | 864 | } |
242 | 865 | 865 | ||
244 | 866 | auto a = make_shared<ObjectAdapter>(*this, name, endpoint, mode, pool_size, idle_timeout); | 866 | shared_ptr<ObjectAdapter> a(new ObjectAdapter(*this, name, endpoint, mode, pool_size, idle_timeout)); |
245 | 867 | a->activate(); | 867 | a->activate(); |
246 | 868 | am_[name] = a; | 868 | am_[name] = a; |
247 | 869 | return a; | 869 | return a; |
248 | 870 | 870 | ||
249 | === modified file 'src/scopes/internal/zmq_middleware/ZmqObject.cpp' | |||
250 | --- src/scopes/internal/zmq_middleware/ZmqObject.cpp 2014-05-29 15:41:42 +0000 | |||
251 | +++ src/scopes/internal/zmq_middleware/ZmqObject.cpp 2014-07-24 15:00:51 +0000 | |||
252 | @@ -208,41 +208,38 @@ | |||
253 | 208 | 208 | ||
254 | 209 | ZmqReceiver ZmqObjectProxy::invoke_twoway_(capnp::MessageBuilder& out_params, int64_t timeout) | 209 | ZmqReceiver ZmqObjectProxy::invoke_twoway_(capnp::MessageBuilder& out_params, int64_t timeout) |
255 | 210 | { | 210 | { |
291 | 211 | try | 211 | auto registry_proxy = mw_base()->registry_proxy(); |
292 | 212 | { | 212 | |
293 | 213 | return invoke_twoway__(out_params, timeout); | 213 | // If a registry is configured and this object is not the registry itself, |
294 | 214 | } | 214 | // attempt to locate the scope before invoking it. |
295 | 215 | catch (TimeoutException const&) | 215 | if (registry_proxy && identity() != registry_proxy->identity()) |
296 | 216 | { | 216 | { |
297 | 217 | auto registry_proxy = mw_base()->registry_proxy(); | 217 | try |
298 | 218 | 218 | { | |
299 | 219 | // If no registry is configured or if this object is the registry itself, rethrow the exception | 219 | ObjectProxy new_proxy = registry_proxy->locate(identity()); |
300 | 220 | if (!registry_proxy || identity() == registry_proxy->identity()) | 220 | // update our proxy with the newly received data |
301 | 221 | { | 221 | // (we need to first store values in local variables outside of the mutex, |
302 | 222 | throw; | 222 | // otherwise we will deadlock on the following ZmqObjectProxy methods) |
303 | 223 | } | 223 | std::string endpoint = new_proxy->endpoint(); |
304 | 224 | 224 | std::string identity = new_proxy->identity(); | |
305 | 225 | // rebind | 225 | std::string category = new_proxy->target_category(); |
306 | 226 | ObjectProxy new_proxy = registry_proxy->locate(identity()); | 226 | int64_t timeout = new_proxy->timeout(); |
307 | 227 | 227 | { | |
308 | 228 | // update our proxy with the newly received data | 228 | lock_guard<mutex> lock(shared_mutex); |
309 | 229 | // (we need to first store values in local variables outside of the mutex, | 229 | endpoint_ = endpoint; |
310 | 230 | // otherwise we will deadlock on the following ZmqObjectProxy methods) | 230 | identity_ = identity; |
311 | 231 | std::string endpoint = new_proxy->endpoint(); | 231 | category_ = category; |
312 | 232 | std::string identity = new_proxy->identity(); | 232 | timeout_ = timeout; |
313 | 233 | std::string category = new_proxy->target_category(); | 233 | } |
314 | 234 | int64_t timeout = new_proxy->timeout(); | 234 | } |
315 | 235 | { | 235 | catch (NotFoundException const&) |
316 | 236 | lock_guard<mutex> lock(shared_mutex); | 236 | { |
317 | 237 | endpoint_ = endpoint; | 237 | // Ignore a failed locate() for scopes unknown to the registry |
318 | 238 | identity_ = identity; | 238 | } |
319 | 239 | category_ = category; | 239 | } |
320 | 240 | timeout_ = timeout; | 240 | |
321 | 241 | } | 241 | // Try the invocation |
322 | 242 | 242 | return invoke_twoway__(out_params, timeout); | |
288 | 243 | // retry the invocation | ||
289 | 244 | return invoke_twoway__(out_params, timeout); | ||
290 | 245 | } | ||
323 | 246 | } | 243 | } |
324 | 247 | 244 | ||
325 | 248 | // Get a socket to the endpoint for this proxy and write the request on the wire. | 245 | // Get a socket to the endpoint for this proxy and write the request on the wire. |
326 | 249 | 246 | ||
327 | === modified file 'test/gtest/scopes/Activation/Activation_test.cpp' | |||
328 | --- test/gtest/scopes/Activation/Activation_test.cpp 2014-07-02 09:36:34 +0000 | |||
329 | +++ test/gtest/scopes/Activation/Activation_test.cpp 2014-07-24 15:00:51 +0000 | |||
330 | @@ -21,6 +21,7 @@ | |||
331 | 21 | #include <unity/scopes/CategoryRenderer.h> | 21 | #include <unity/scopes/CategoryRenderer.h> |
332 | 22 | #include <unity/scopes/internal/CategoryRegistry.h> | 22 | #include <unity/scopes/internal/CategoryRegistry.h> |
333 | 23 | #include <unity/scopes/internal/CategorisedResultImpl.h> | 23 | #include <unity/scopes/internal/CategorisedResultImpl.h> |
334 | 24 | #include <unity/scopes/internal/RegistryObject.h> | ||
335 | 24 | #include <unity/scopes/internal/ResultReplyObject.h> | 25 | #include <unity/scopes/internal/ResultReplyObject.h> |
336 | 25 | #include <unity/scopes/internal/RuntimeImpl.h> | 26 | #include <unity/scopes/internal/RuntimeImpl.h> |
337 | 26 | #include <unity/scopes/internal/ScopeImpl.h> | 27 | #include <unity/scopes/internal/ScopeImpl.h> |
338 | @@ -514,7 +515,10 @@ | |||
339 | 514 | 515 | ||
340 | 515 | RaiiScopeThread(std::string const& scope_id, std::string const& configfile) | 516 | RaiiScopeThread(std::string const& scope_id, std::string const& configfile) |
341 | 516 | : runtime(Runtime::create_scope_runtime(scope_id, configfile)), | 517 | : runtime(Runtime::create_scope_runtime(scope_id, configfile)), |
343 | 517 | scope_thread([this, configfile]{ runtime->run_scope(&scope, configfile, ""); }) {} | 518 | scope_thread([this, configfile]{ runtime->run_scope(&scope, configfile, ""); }) |
344 | 519 | { | ||
345 | 520 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); | ||
346 | 521 | } | ||
347 | 518 | 522 | ||
348 | 519 | ~RaiiScopeThread() | 523 | ~RaiiScopeThread() |
349 | 520 | { | 524 | { |
350 | @@ -523,9 +527,22 @@ | |||
351 | 523 | } | 527 | } |
352 | 524 | }; | 528 | }; |
353 | 525 | 529 | ||
354 | 530 | std::shared_ptr<core::posix::SignalTrap> trap(core::posix::trap_signals_for_all_subsequent_threads({core::posix::Signal::sig_chld})); | ||
355 | 531 | std::unique_ptr<core::posix::ChildProcess::DeathObserver> death_observer(core::posix::ChildProcess::DeathObserver::create_once_with_signal_trap(trap)); | ||
356 | 532 | |||
357 | 533 | RuntimeImpl::SPtr run_test_registry() | ||
358 | 534 | { | ||
359 | 535 | RuntimeImpl::SPtr runtime = RuntimeImpl::create("TestRegistry", "Runtime.ini"); | ||
360 | 536 | MiddlewareBase::SPtr middleware = runtime->factory()->create("TestRegistry", "Zmq", "Zmq.ini"); | ||
361 | 537 | RegistryObject::SPtr reg_obj(std::make_shared<RegistryObject>(*death_observer, std::make_shared<Executor>(), middleware)); | ||
362 | 538 | middleware->add_registry_object("TestRegistry", reg_obj); | ||
363 | 539 | return runtime; | ||
364 | 540 | } | ||
365 | 541 | |||
366 | 526 | // does actual activation with a test scope | 542 | // does actual activation with a test scope |
367 | 527 | TEST(Activation, scope) | 543 | TEST(Activation, scope) |
368 | 528 | { | 544 | { |
369 | 545 | auto reg_rt = run_test_registry(); | ||
370 | 529 | RaiiScopeThread<TestScope> scope_thread("TestScope", "Runtime.ini"); | 546 | RaiiScopeThread<TestScope> scope_thread("TestScope", "Runtime.ini"); |
371 | 530 | 547 | ||
372 | 531 | // parent: connect to scope and run a query | 548 | // parent: connect to scope and run a query |
373 | 532 | 549 | ||
374 | === modified file 'test/gtest/scopes/Activation/Runtime.ini.in' | |||
375 | --- test/gtest/scopes/Activation/Runtime.ini.in 2014-01-14 17:31:16 +0000 | |||
376 | +++ test/gtest/scopes/Activation/Runtime.ini.in 2014-07-24 15:00:51 +0000 | |||
377 | @@ -1,5 +1,5 @@ | |||
378 | 1 | [Runtime] | 1 | [Runtime] |
380 | 2 | Registry.Identity = Registry | 2 | Registry.Identity = TestRegistry |
381 | 3 | Registry.ConfigFile = Registry.ini | 3 | Registry.ConfigFile = Registry.ini |
382 | 4 | Default.Middleware = Zmq | 4 | Default.Middleware = Zmq |
383 | 5 | Zmq.ConfigFile = Zmq.ini | 5 | Zmq.ConfigFile = Zmq.ini |
384 | 6 | 6 | ||
385 | === modified file 'test/gtest/scopes/Filters/Filters_test.cpp' | |||
386 | --- test/gtest/scopes/Filters/Filters_test.cpp 2014-06-17 10:30:03 +0000 | |||
387 | +++ test/gtest/scopes/Filters/Filters_test.cpp 2014-07-24 15:00:51 +0000 | |||
388 | @@ -16,6 +16,7 @@ | |||
389 | 16 | * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com> | 16 | * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com> |
390 | 17 | */ | 17 | */ |
391 | 18 | 18 | ||
392 | 19 | #include <unity/scopes/internal/RegistryObject.h> | ||
393 | 19 | #include <unity/scopes/internal/RuntimeImpl.h> | 20 | #include <unity/scopes/internal/RuntimeImpl.h> |
394 | 20 | #include <unity/scopes/internal/ScopeImpl.h> | 21 | #include <unity/scopes/internal/ScopeImpl.h> |
395 | 21 | #include <unity/scopes/internal/FilterBaseImpl.h> | 22 | #include <unity/scopes/internal/FilterBaseImpl.h> |
396 | @@ -86,7 +87,10 @@ | |||
397 | 86 | 87 | ||
398 | 87 | RaiiScopeThread(std::string const& scope_id, std::string const& configfile) | 88 | RaiiScopeThread(std::string const& scope_id, std::string const& configfile) |
399 | 88 | : runtime(Runtime::create_scope_runtime(scope_id, configfile)), | 89 | : runtime(Runtime::create_scope_runtime(scope_id, configfile)), |
401 | 89 | scope_thread([this, configfile]{ runtime->run_scope(&scope, configfile, ""); }) {} | 90 | scope_thread([this, configfile]{ runtime->run_scope(&scope, configfile, ""); }) |
402 | 91 | { | ||
403 | 92 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); | ||
404 | 93 | } | ||
405 | 90 | 94 | ||
406 | 91 | ~RaiiScopeThread() | 95 | ~RaiiScopeThread() |
407 | 92 | { | 96 | { |
408 | @@ -95,8 +99,21 @@ | |||
409 | 95 | } | 99 | } |
410 | 96 | }; | 100 | }; |
411 | 97 | 101 | ||
412 | 102 | std::shared_ptr<core::posix::SignalTrap> trap(core::posix::trap_signals_for_all_subsequent_threads({core::posix::Signal::sig_chld})); | ||
413 | 103 | std::unique_ptr<core::posix::ChildProcess::DeathObserver> death_observer(core::posix::ChildProcess::DeathObserver::create_once_with_signal_trap(trap)); | ||
414 | 104 | |||
415 | 105 | RuntimeImpl::SPtr run_test_registry() | ||
416 | 106 | { | ||
417 | 107 | RuntimeImpl::SPtr runtime = RuntimeImpl::create("TestRegistry", "Runtime.ini"); | ||
418 | 108 | MiddlewareBase::SPtr middleware = runtime->factory()->create("TestRegistry", "Zmq", "Zmq.ini"); | ||
419 | 109 | RegistryObject::SPtr reg_obj(std::make_shared<RegistryObject>(*death_observer, std::make_shared<Executor>(), middleware)); | ||
420 | 110 | middleware->add_registry_object("TestRegistry", reg_obj); | ||
421 | 111 | return runtime; | ||
422 | 112 | } | ||
423 | 113 | |||
424 | 98 | TEST(Filters, scope) | 114 | TEST(Filters, scope) |
425 | 99 | { | 115 | { |
426 | 116 | auto reg_rt = run_test_registry(); | ||
427 | 100 | RaiiScopeThread<TestScope> scope_thread("TestScope", "Runtime.ini"); | 117 | RaiiScopeThread<TestScope> scope_thread("TestScope", "Runtime.ini"); |
428 | 101 | 118 | ||
429 | 102 | // parent: connect to scope and run a query | 119 | // parent: connect to scope and run a query |
430 | 103 | 120 | ||
431 | === modified file 'test/gtest/scopes/Filters/Runtime.ini.in' | |||
432 | --- test/gtest/scopes/Filters/Runtime.ini.in 2014-01-24 12:51:40 +0000 | |||
433 | +++ test/gtest/scopes/Filters/Runtime.ini.in 2014-07-24 15:00:51 +0000 | |||
434 | @@ -1,5 +1,5 @@ | |||
435 | 1 | [Runtime] | 1 | [Runtime] |
437 | 2 | Registry.Identity = Registry | 2 | Registry.Identity = TestRegistry |
438 | 3 | Registry.ConfigFile = Registry.ini | 3 | Registry.ConfigFile = Registry.ini |
439 | 4 | Default.Middleware = Zmq | 4 | Default.Middleware = Zmq |
440 | 5 | Zmq.ConfigFile = Zmq.ini | 5 | Zmq.ConfigFile = Zmq.ini |
441 | 6 | 6 | ||
442 | === modified file 'test/gtest/scopes/IdleShutdown/IdleShutdown_test.cpp' | |||
443 | --- test/gtest/scopes/IdleShutdown/IdleShutdown_test.cpp 2014-07-14 06:39:34 +0000 | |||
444 | +++ test/gtest/scopes/IdleShutdown/IdleShutdown_test.cpp 2014-07-24 15:00:51 +0000 | |||
445 | @@ -17,6 +17,7 @@ | |||
446 | 17 | */ | 17 | */ |
447 | 18 | 18 | ||
448 | 19 | #include <unity/scopes/CategorisedResult.h> | 19 | #include <unity/scopes/CategorisedResult.h> |
449 | 20 | #include <unity/scopes/internal/RegistryObject.h> | ||
450 | 20 | #include <unity/scopes/internal/RuntimeImpl.h> | 21 | #include <unity/scopes/internal/RuntimeImpl.h> |
451 | 21 | #include <unity/scopes/internal/ScopeImpl.h> | 22 | #include <unity/scopes/internal/ScopeImpl.h> |
452 | 22 | 23 | ||
453 | @@ -91,11 +92,24 @@ | |||
454 | 91 | EXPECT_TRUE(duration < chrono::seconds(6)); | 92 | EXPECT_TRUE(duration < chrono::seconds(6)); |
455 | 92 | } | 93 | } |
456 | 93 | 94 | ||
457 | 95 | std::shared_ptr<core::posix::SignalTrap> trap(core::posix::trap_signals_for_all_subsequent_threads({core::posix::Signal::sig_chld})); | ||
458 | 96 | std::unique_ptr<core::posix::ChildProcess::DeathObserver> death_observer(core::posix::ChildProcess::DeathObserver::create_once_with_signal_trap(trap)); | ||
459 | 97 | |||
460 | 98 | RuntimeImpl::SPtr run_test_registry() | ||
461 | 99 | { | ||
462 | 100 | RuntimeImpl::SPtr runtime = RuntimeImpl::create("TestRegistry", "Runtime.ini"); | ||
463 | 101 | MiddlewareBase::SPtr middleware = runtime->factory()->create("TestRegistry", "Zmq", "Zmq.ini"); | ||
464 | 102 | RegistryObject::SPtr reg_obj(std::make_shared<RegistryObject>(*death_observer, std::make_shared<Executor>(), middleware)); | ||
465 | 103 | middleware->add_registry_object("TestRegistry", reg_obj); | ||
466 | 104 | return runtime; | ||
467 | 105 | } | ||
468 | 106 | |||
469 | 94 | // Check that the idle timeout for a server waits for synchronous operations | 107 | // Check that the idle timeout for a server waits for synchronous operations |
470 | 95 | // to complete. | 108 | // to complete. |
471 | 96 | 109 | ||
472 | 97 | TEST(IdleTimeout, server_idle_timeout_while_operation_in_progress) | 110 | TEST(IdleTimeout, server_idle_timeout_while_operation_in_progress) |
473 | 98 | { | 111 | { |
474 | 112 | auto reg_rt = run_test_registry(); | ||
475 | 99 | auto start_time = chrono::steady_clock::now(); | 113 | auto start_time = chrono::steady_clock::now(); |
476 | 100 | 114 | ||
477 | 101 | { | 115 | { |
478 | 102 | 116 | ||
479 | === modified file 'test/gtest/scopes/IdleShutdown/Runtime.ini.in' | |||
480 | --- test/gtest/scopes/IdleShutdown/Runtime.ini.in 2014-05-14 04:50:14 +0000 | |||
481 | +++ test/gtest/scopes/IdleShutdown/Runtime.ini.in 2014-07-24 15:00:51 +0000 | |||
482 | @@ -1,5 +1,5 @@ | |||
483 | 1 | [Runtime] | 1 | [Runtime] |
485 | 2 | Registry.Identity = Registry | 2 | Registry.Identity = TestRegistry |
486 | 3 | Registry.ConfigFile = Registry.ini | 3 | Registry.ConfigFile = Registry.ini |
487 | 4 | Default.Middleware = Zmq | 4 | Default.Middleware = Zmq |
488 | 5 | Zmq.ConfigFile = Zmq.ini | 5 | Zmq.ConfigFile = Zmq.ini |
489 | 6 | 6 | ||
490 | === modified file 'test/gtest/scopes/Invocation/Invocation_test.cpp' | |||
491 | --- test/gtest/scopes/Invocation/Invocation_test.cpp 2014-07-22 04:38:48 +0000 | |||
492 | +++ test/gtest/scopes/Invocation/Invocation_test.cpp 2014-07-24 15:00:51 +0000 | |||
493 | @@ -25,6 +25,7 @@ | |||
494 | 25 | #include <unity/scopes/ActionMetadata.h> | 25 | #include <unity/scopes/ActionMetadata.h> |
495 | 26 | #include <unity/scopes/CategorisedResult.h> | 26 | #include <unity/scopes/CategorisedResult.h> |
496 | 27 | #include <unity/scopes/internal/MWScope.h> | 27 | #include <unity/scopes/internal/MWScope.h> |
497 | 28 | #include <unity/scopes/internal/RegistryObject.h> | ||
498 | 28 | #include <unity/scopes/internal/RuntimeImpl.h> | 29 | #include <unity/scopes/internal/RuntimeImpl.h> |
499 | 29 | #include <unity/scopes/internal/ScopeImpl.h> | 30 | #include <unity/scopes/internal/ScopeImpl.h> |
500 | 30 | #include <unity/scopes/ListenerBase.h> | 31 | #include <unity/scopes/ListenerBase.h> |
501 | @@ -40,6 +41,7 @@ | |||
502 | 40 | 41 | ||
503 | 41 | using namespace std; | 42 | using namespace std; |
504 | 42 | using namespace unity::scopes; | 43 | using namespace unity::scopes; |
505 | 44 | using namespace unity::scopes::internal; | ||
506 | 43 | 45 | ||
507 | 44 | class TestReceiver : public SearchListenerBase | 46 | class TestReceiver : public SearchListenerBase |
508 | 45 | { | 47 | { |
509 | @@ -89,12 +91,25 @@ | |||
510 | 89 | condition_variable cond_; | 91 | condition_variable cond_; |
511 | 90 | }; | 92 | }; |
512 | 91 | 93 | ||
513 | 94 | std::shared_ptr<core::posix::SignalTrap> trap(core::posix::trap_signals_for_all_subsequent_threads({core::posix::Signal::sig_chld})); | ||
514 | 95 | std::unique_ptr<core::posix::ChildProcess::DeathObserver> death_observer(core::posix::ChildProcess::DeathObserver::create_once_with_signal_trap(trap)); | ||
515 | 96 | |||
516 | 97 | RuntimeImpl::SPtr run_test_registry() | ||
517 | 98 | { | ||
518 | 99 | RuntimeImpl::SPtr runtime = RuntimeImpl::create("TestRegistry", "Runtime.ini"); | ||
519 | 100 | MiddlewareBase::SPtr middleware = runtime->factory()->create("TestRegistry", "Zmq", "Zmq.ini"); | ||
520 | 101 | RegistryObject::SPtr reg_obj(std::make_shared<RegistryObject>(*death_observer, std::make_shared<Executor>(), middleware)); | ||
521 | 102 | middleware->add_registry_object("TestRegistry", reg_obj); | ||
522 | 103 | return runtime; | ||
523 | 104 | } | ||
524 | 105 | |||
525 | 92 | // Check that invoking on a scope after a timeout exception from a previous | 106 | // Check that invoking on a scope after a timeout exception from a previous |
526 | 93 | // invocation works correctly. This tests that a failed socket is removed | 107 | // invocation works correctly. This tests that a failed socket is removed |
527 | 94 | // from the connection pool in ZmqObject::invoke_twoway_(). | 108 | // from the connection pool in ZmqObject::invoke_twoway_(). |
528 | 95 | 109 | ||
529 | 96 | TEST(Invocation, timeout) | 110 | TEST(Invocation, timeout) |
530 | 97 | { | 111 | { |
531 | 112 | auto reg_rt = run_test_registry(); | ||
532 | 98 | auto rt = internal::RuntimeImpl::create("", "Runtime.ini"); | 113 | auto rt = internal::RuntimeImpl::create("", "Runtime.ini"); |
533 | 99 | auto mw = rt->factory()->create("TestScope", "Zmq", "Zmq.ini"); | 114 | auto mw = rt->factory()->create("TestScope", "Zmq", "Zmq.ini"); |
534 | 100 | mw->start(); | 115 | mw->start(); |
535 | @@ -108,7 +123,7 @@ | |||
536 | 108 | receiver->wait_until_finished(); | 123 | receiver->wait_until_finished(); |
537 | 109 | 124 | ||
538 | 110 | EXPECT_EQ(ListenerBase::Error, receiver->reason()); | 125 | EXPECT_EQ(ListenerBase::Error, receiver->reason()); |
540 | 111 | EXPECT_EQ("unity::scopes::TimeoutException: Request timed out after 3000 milliseconds", receiver->error_message()); | 126 | EXPECT_EQ("unity::scopes::TimeoutException: Request timed out after 500 milliseconds", receiver->error_message()); |
541 | 112 | 127 | ||
542 | 113 | // Wait another three seconds, so TestScope is finally able to receive another request. | 128 | // Wait another three seconds, so TestScope is finally able to receive another request. |
543 | 114 | this_thread::sleep_for(chrono::seconds(3)); | 129 | this_thread::sleep_for(chrono::seconds(3)); |
544 | @@ -180,7 +195,7 @@ | |||
545 | 180 | 195 | ||
546 | 181 | // Give threads some time to bind to endpoints, to avoid getting ObjectNotExistException | 196 | // Give threads some time to bind to endpoints, to avoid getting ObjectNotExistException |
547 | 182 | // from a synchronous remote call. | 197 | // from a synchronous remote call. |
549 | 183 | this_thread::sleep_for(chrono::milliseconds(200)); | 198 | this_thread::sleep_for(chrono::milliseconds(500)); |
550 | 184 | 199 | ||
551 | 185 | auto rc = RUN_ALL_TESTS(); | 200 | auto rc = RUN_ALL_TESTS(); |
552 | 186 | 201 | ||
553 | 187 | 202 | ||
554 | === modified file 'test/gtest/scopes/Invocation/Runtime.ini.in' | |||
555 | --- test/gtest/scopes/Invocation/Runtime.ini.in 2014-04-17 01:36:29 +0000 | |||
556 | +++ test/gtest/scopes/Invocation/Runtime.ini.in 2014-07-24 15:00:51 +0000 | |||
557 | @@ -1,5 +1,5 @@ | |||
558 | 1 | [Runtime] | 1 | [Runtime] |
560 | 2 | Registry.Identity = Registry | 2 | Registry.Identity = TestRegistry |
561 | 3 | Registry.ConfigFile = Registry.ini | 3 | Registry.ConfigFile = Registry.ini |
562 | 4 | Default.Middleware = Zmq | 4 | Default.Middleware = Zmq |
563 | 5 | Zmq.ConfigFile = Zmq.ini | 5 | Zmq.ConfigFile = Zmq.ini |
564 | 6 | 6 | ||
565 | === modified file 'test/gtest/scopes/Invocation/TestScope.cpp' | |||
566 | --- test/gtest/scopes/Invocation/TestScope.cpp 2014-07-16 03:01:10 +0000 | |||
567 | +++ test/gtest/scopes/Invocation/TestScope.cpp 2014-07-24 15:00:51 +0000 | |||
568 | @@ -71,7 +71,7 @@ | |||
569 | 71 | 71 | ||
570 | 72 | if (count++ == 0) | 72 | if (count++ == 0) |
571 | 73 | { | 73 | { |
573 | 74 | this_thread::sleep_for(chrono::milliseconds(4000)); // Force timeout on first call | 74 | this_thread::sleep_for(chrono::milliseconds(1000)); // Force timeout on first call |
574 | 75 | } | 75 | } |
575 | 76 | return SearchQueryBase::UPtr(new TestQuery(query, metadata)); | 76 | return SearchQueryBase::UPtr(new TestQuery(query, metadata)); |
576 | 77 | } | 77 | } |
577 | 78 | 78 | ||
578 | === modified file 'test/gtest/scopes/Registry/CMakeLists.txt' | |||
579 | --- test/gtest/scopes/Registry/CMakeLists.txt 2014-07-15 05:50:10 +0000 | |||
580 | +++ test/gtest/scopes/Registry/CMakeLists.txt 2014-07-24 15:00:51 +0000 | |||
581 | @@ -8,6 +8,7 @@ | |||
582 | 8 | add_definitions(-DTEST_RUNTIME_PATH="${CMAKE_CURRENT_BINARY_DIR}") | 8 | add_definitions(-DTEST_RUNTIME_PATH="${CMAKE_CURRENT_BINARY_DIR}") |
583 | 9 | add_definitions(-DTEST_RUNTIME_FILE="${CMAKE_CURRENT_BINARY_DIR}/Runtime.ini") | 9 | add_definitions(-DTEST_RUNTIME_FILE="${CMAKE_CURRENT_BINARY_DIR}/Runtime.ini") |
584 | 10 | add_definitions(-DTEST_REGISTRY_PATH="${PROJECT_BINARY_DIR}/scoperegistry") | 10 | add_definitions(-DTEST_REGISTRY_PATH="${PROJECT_BINARY_DIR}/scoperegistry") |
585 | 11 | add_definitions(-DTEST_SCOPE_A_PATH="${CMAKE_CURRENT_BINARY_DIR}/scopes/testscopeA") | ||
586 | 11 | 12 | ||
587 | 12 | add_executable(Registry_test Registry_test.cpp) | 13 | add_executable(Registry_test Registry_test.cpp) |
588 | 13 | target_link_libraries(Registry_test ${TESTLIBS}) | 14 | target_link_libraries(Registry_test ${TESTLIBS}) |
589 | 14 | 15 | ||
590 | === modified file 'test/gtest/scopes/Registry/Registry_test.cpp' | |||
591 | --- test/gtest/scopes/Registry/Registry_test.cpp 2014-07-23 14:12:45 +0000 | |||
592 | +++ test/gtest/scopes/Registry/Registry_test.cpp 2014-07-24 15:00:51 +0000 | |||
593 | @@ -86,7 +86,7 @@ | |||
594 | 86 | EXPECT_EQ("scope-A.DisplayName", meta.display_name()); | 86 | EXPECT_EQ("scope-A.DisplayName", meta.display_name()); |
595 | 87 | EXPECT_EQ("scope-A.Description", meta.description()); | 87 | EXPECT_EQ("scope-A.Description", meta.description()); |
596 | 88 | EXPECT_EQ("/foo/scope-A.Art", meta.art()); | 88 | EXPECT_EQ("/foo/scope-A.Art", meta.art()); |
598 | 89 | EXPECT_EQ("/foo/scope-A.Icon", meta.icon()); | 89 | EXPECT_EQ("file://scope-A.Icon", meta.icon()); |
599 | 90 | EXPECT_EQ("scope-A.HotKey", meta.hot_key()); | 90 | EXPECT_EQ("scope-A.HotKey", meta.hot_key()); |
600 | 91 | EXPECT_FALSE(meta.invisible()); | 91 | EXPECT_FALSE(meta.invisible()); |
601 | 92 | EXPECT_EQ("scope-A.SearchHint", meta.search_hint()); | 92 | EXPECT_EQ("scope-A.SearchHint", meta.search_hint()); |
602 | @@ -103,14 +103,14 @@ | |||
603 | 103 | EXPECT_EQ("fg_color", attrs["foreground-color"].get_string()); | 103 | EXPECT_EQ("fg_color", attrs["foreground-color"].get_string()); |
604 | 104 | EXPECT_EQ("bg_color", attrs["background-color"].get_string()); | 104 | EXPECT_EQ("bg_color", attrs["background-color"].get_string()); |
605 | 105 | EXPECT_TRUE(attrs["shape-images"].get_bool()); | 105 | EXPECT_TRUE(attrs["shape-images"].get_bool()); |
607 | 106 | EXPECT_EQ("cat_header_bg_scheme", attrs["category-header-background"].get_string()); | 106 | EXPECT_EQ(TEST_SCOPE_A_PATH "/cat_header_bg_scheme", attrs["category-header-background"].get_string()); |
608 | 107 | EXPECT_EQ("preview_button_color", attrs["preview-button-color"].get_string()); | 107 | EXPECT_EQ("preview_button_color", attrs["preview-button-color"].get_string()); |
609 | 108 | EXPECT_EQ("overlay_color", attrs["logo-overlay-color"].get_string()); | 108 | EXPECT_EQ("overlay_color", attrs["logo-overlay-color"].get_string()); |
610 | 109 | auto page_hdr = attrs["page-header"].get_dict(); | 109 | auto page_hdr = attrs["page-header"].get_dict(); |
612 | 110 | EXPECT_EQ("some_url", page_hdr["logo"].get_string()); | 110 | EXPECT_EQ(TEST_SCOPE_A_PATH "/some_url", page_hdr["logo"].get_string()); |
613 | 111 | EXPECT_EQ("fg_color", page_hdr["foreground-color"].get_string()); | 111 | EXPECT_EQ("fg_color", page_hdr["foreground-color"].get_string()); |
614 | 112 | EXPECT_EQ("div_color", page_hdr["divider-color"].get_string()); | 112 | EXPECT_EQ("div_color", page_hdr["divider-color"].get_string()); |
616 | 113 | EXPECT_EQ("nav_background", page_hdr["navigation-background"].get_string()); | 113 | EXPECT_EQ("http://nav_background", page_hdr["navigation-background"].get_string()); |
617 | 114 | 114 | ||
618 | 115 | const char *bart = TEST_RUNTIME_PATH "/scopes/testscopeB/data/scope-B.Art"; | 115 | const char *bart = TEST_RUNTIME_PATH "/scopes/testscopeB/data/scope-B.Art"; |
619 | 116 | const char *bicon = TEST_RUNTIME_PATH "/scopes/testscopeB/data/scope-B.Icon"; | 116 | const char *bicon = TEST_RUNTIME_PATH "/scopes/testscopeB/data/scope-B.Icon"; |
620 | 117 | 117 | ||
621 | === modified file 'test/gtest/scopes/Registry/scopes/testscopeA/testscopeA.ini.in' | |||
622 | --- test/gtest/scopes/Registry/scopes/testscopeA/testscopeA.ini.in 2014-07-22 10:38:18 +0000 | |||
623 | +++ test/gtest/scopes/Registry/scopes/testscopeA/testscopeA.ini.in 2014-07-24 15:00:51 +0000 | |||
624 | @@ -3,7 +3,7 @@ | |||
625 | 3 | Description = scope-A.Description | 3 | Description = scope-A.Description |
626 | 4 | Art = /foo/scope-A.Art | 4 | Art = /foo/scope-A.Art |
627 | 5 | Author = Canonical Ltd. | 5 | Author = Canonical Ltd. |
629 | 6 | Icon = /foo/scope-A.Icon | 6 | Icon = file://scope-A.Icon |
630 | 7 | SearchHint = scope-A.SearchHint | 7 | SearchHint = scope-A.SearchHint |
631 | 8 | HotKey = scope-A.HotKey | 8 | HotKey = scope-A.HotKey |
632 | 9 | LocationDataNeeded = true | 9 | LocationDataNeeded = true |
633 | @@ -19,4 +19,4 @@ | |||
634 | 19 | PageHeader.ForegroundColor = fg_color | 19 | PageHeader.ForegroundColor = fg_color |
635 | 20 | PageHeader.Background = bg_scheme | 20 | PageHeader.Background = bg_scheme |
636 | 21 | PageHeader.DividerColor = div_color | 21 | PageHeader.DividerColor = div_color |
638 | 22 | PageHeader.NavigationBackground = nav_background | 22 | PageHeader.NavigationBackground = http://nav_background |
639 | 23 | 23 | ||
640 | === modified file 'test/gtest/scopes/Runtime/Runtime.ini.in' | |||
641 | --- test/gtest/scopes/Runtime/Runtime.ini.in 2013-12-13 11:25:44 +0000 | |||
642 | +++ test/gtest/scopes/Runtime/Runtime.ini.in 2014-07-24 15:00:51 +0000 | |||
643 | @@ -1,5 +1,5 @@ | |||
644 | 1 | [Runtime] | 1 | [Runtime] |
646 | 2 | Registry.Identity = Registry | 2 | Registry.Identity = TestRegistry |
647 | 3 | Registry.ConfigFile = Registry.ini | 3 | Registry.ConfigFile = Registry.ini |
648 | 4 | Default.Middleware = Zmq | 4 | Default.Middleware = Zmq |
649 | 5 | Zmq.ConfigFile = Zmq.ini | 5 | Zmq.ConfigFile = Zmq.ini |
650 | 6 | 6 | ||
651 | === modified file 'test/gtest/scopes/Runtime/Runtime_test.cpp' | |||
652 | --- test/gtest/scopes/Runtime/Runtime_test.cpp 2014-07-17 05:02:03 +0000 | |||
653 | +++ test/gtest/scopes/Runtime/Runtime_test.cpp 2014-07-24 15:00:51 +0000 | |||
654 | @@ -25,6 +25,7 @@ | |||
655 | 25 | #include <unity/scopes/ActionMetadata.h> | 25 | #include <unity/scopes/ActionMetadata.h> |
656 | 26 | #include <unity/scopes/CategorisedResult.h> | 26 | #include <unity/scopes/CategorisedResult.h> |
657 | 27 | #include <unity/scopes/internal/MWScope.h> | 27 | #include <unity/scopes/internal/MWScope.h> |
658 | 28 | #include <unity/scopes/internal/RegistryObject.h> | ||
659 | 28 | #include <unity/scopes/internal/RuntimeImpl.h> | 29 | #include <unity/scopes/internal/RuntimeImpl.h> |
660 | 29 | #include <unity/scopes/internal/ScopeImpl.h> | 30 | #include <unity/scopes/internal/ScopeImpl.h> |
661 | 30 | #include <unity/scopes/ListenerBase.h> | 31 | #include <unity/scopes/ListenerBase.h> |
662 | @@ -41,6 +42,7 @@ | |||
663 | 41 | 42 | ||
664 | 42 | using namespace std; | 43 | using namespace std; |
665 | 43 | using namespace unity::scopes; | 44 | using namespace unity::scopes; |
666 | 45 | using namespace unity::scopes::internal; | ||
667 | 44 | 46 | ||
668 | 45 | TEST(Runtime, basic) | 47 | TEST(Runtime, basic) |
669 | 46 | { | 48 | { |
670 | @@ -221,8 +223,22 @@ | |||
671 | 221 | atomic_int count_; | 223 | atomic_int count_; |
672 | 222 | }; | 224 | }; |
673 | 223 | 225 | ||
674 | 226 | std::shared_ptr<core::posix::SignalTrap> trap(core::posix::trap_signals_for_all_subsequent_threads({core::posix::Signal::sig_chld})); | ||
675 | 227 | std::unique_ptr<core::posix::ChildProcess::DeathObserver> death_observer(core::posix::ChildProcess::DeathObserver::create_once_with_signal_trap(trap)); | ||
676 | 228 | |||
677 | 229 | RuntimeImpl::SPtr run_test_registry() | ||
678 | 230 | { | ||
679 | 231 | RuntimeImpl::SPtr runtime = RuntimeImpl::create("TestRegistry", "Runtime.ini"); | ||
680 | 232 | MiddlewareBase::SPtr middleware = runtime->factory()->create("TestRegistry", "Zmq", "Zmq.ini"); | ||
681 | 233 | RegistryObject::SPtr reg_obj(std::make_shared<RegistryObject>(*death_observer, std::make_shared<Executor>(), middleware)); | ||
682 | 234 | middleware->add_registry_object("TestRegistry", reg_obj); | ||
683 | 235 | return runtime; | ||
684 | 236 | } | ||
685 | 237 | |||
686 | 224 | TEST(Runtime, search) | 238 | TEST(Runtime, search) |
687 | 225 | { | 239 | { |
688 | 240 | auto reg_rt = run_test_registry(); | ||
689 | 241 | |||
690 | 226 | // connect to scope and run a query | 242 | // connect to scope and run a query |
691 | 227 | auto rt = internal::RuntimeImpl::create("", "Runtime.ini"); | 243 | auto rt = internal::RuntimeImpl::create("", "Runtime.ini"); |
692 | 228 | auto mw = rt->factory()->create("TestScope", "Zmq", "Zmq.ini"); | 244 | auto mw = rt->factory()->create("TestScope", "Zmq", "Zmq.ini"); |
693 | @@ -237,6 +253,7 @@ | |||
694 | 237 | 253 | ||
695 | 238 | TEST(Runtime, consecutive_search) | 254 | TEST(Runtime, consecutive_search) |
696 | 239 | { | 255 | { |
697 | 256 | auto reg_rt = run_test_registry(); | ||
698 | 240 | auto rt = internal::RuntimeImpl::create("", "Runtime.ini"); | 257 | auto rt = internal::RuntimeImpl::create("", "Runtime.ini"); |
699 | 241 | auto mw = rt->factory()->create("TestScope", "Zmq", "Zmq.ini"); | 258 | auto mw = rt->factory()->create("TestScope", "Zmq", "Zmq.ini"); |
700 | 242 | mw->start(); | 259 | mw->start(); |
701 | @@ -278,6 +295,8 @@ | |||
702 | 278 | 295 | ||
703 | 279 | TEST(Runtime, preview) | 296 | TEST(Runtime, preview) |
704 | 280 | { | 297 | { |
705 | 298 | auto reg_rt = run_test_registry(); | ||
706 | 299 | |||
707 | 281 | // connect to scope and run a query | 300 | // connect to scope and run a query |
708 | 282 | auto rt = internal::RuntimeImpl::create("", "Runtime.ini"); | 301 | auto rt = internal::RuntimeImpl::create("", "Runtime.ini"); |
709 | 283 | auto mw = rt->factory()->create("TestScope", "Zmq", "Zmq.ini"); | 302 | auto mw = rt->factory()->create("TestScope", "Zmq", "Zmq.ini"); |
710 | @@ -303,6 +322,8 @@ | |||
711 | 303 | 322 | ||
712 | 304 | TEST(Runtime, cardinality) | 323 | TEST(Runtime, cardinality) |
713 | 305 | { | 324 | { |
714 | 325 | auto reg_rt = run_test_registry(); | ||
715 | 326 | |||
716 | 306 | // connect to scope and run a query | 327 | // connect to scope and run a query |
717 | 307 | auto rt = internal::RuntimeImpl::create("", "Runtime.ini"); | 328 | auto rt = internal::RuntimeImpl::create("", "Runtime.ini"); |
718 | 308 | auto mw = rt->factory()->create("PusherScope", "Zmq", "Zmq.ini"); | 329 | auto mw = rt->factory()->create("PusherScope", "Zmq", "Zmq.ini"); |
719 | @@ -360,6 +381,7 @@ | |||
720 | 360 | 381 | ||
721 | 361 | TEST(Runtime, early_cancel) | 382 | TEST(Runtime, early_cancel) |
722 | 362 | { | 383 | { |
723 | 384 | auto reg_rt = run_test_registry(); | ||
724 | 363 | auto rt = internal::RuntimeImpl::create("", "Runtime.ini"); | 385 | auto rt = internal::RuntimeImpl::create("", "Runtime.ini"); |
725 | 364 | auto mw = rt->factory()->create("SlowCreateScope", "Zmq", "Zmq.ini"); | 386 | auto mw = rt->factory()->create("SlowCreateScope", "Zmq", "Zmq.ini"); |
726 | 365 | mw->start(); | 387 | mw->start(); |
727 | 366 | 388 | ||
728 | === modified file 'test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp' | |||
729 | --- test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp 2014-07-07 23:53:36 +0000 | |||
730 | +++ test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp 2014-07-24 15:00:51 +0000 | |||
731 | @@ -108,8 +108,9 @@ | |||
732 | 108 | 108 | ||
733 | 109 | TEST_F(smartscopesproxytest, ss_registry) | 109 | TEST_F(smartscopesproxytest, ss_registry) |
734 | 110 | { | 110 | { |
737 | 111 | // locate should throw (direct) | 111 | // non-existent scope (direct) |
738 | 112 | EXPECT_THROW(reg_->locate("dummy.scope"), RegistryException); | 112 | EXPECT_THROW(reg_->get_metadata("dummy.scope.5"), NotFoundException); |
739 | 113 | EXPECT_THROW(reg_->locate("dummy.scope.5"), NotFoundException); | ||
740 | 113 | 114 | ||
741 | 114 | // list scopes (direct) | 115 | // list scopes (direct) |
742 | 115 | MetadataMap scopes = reg_->list(); | 116 | MetadataMap scopes = reg_->list(); |
743 | @@ -139,12 +140,10 @@ | |||
744 | 139 | EXPECT_EQ("Celsius", meta.settings_definitions()[1].get_dict()["values"].get_array()[0].get_string()); | 140 | EXPECT_EQ("Celsius", meta.settings_definitions()[1].get_dict()["values"].get_array()[0].get_string()); |
745 | 140 | EXPECT_EQ("Fahrenheit", meta.settings_definitions()[1].get_dict()["values"].get_array()[1].get_string()); | 141 | EXPECT_EQ("Fahrenheit", meta.settings_definitions()[1].get_dict()["values"].get_array()[1].get_string()); |
746 | 141 | 142 | ||
751 | 142 | // non-existant scope (direct) | 143 | // non-existent scope (via mw) |
748 | 143 | EXPECT_THROW(reg_->get_metadata("dummy.scope.5"), NotFoundException); | ||
749 | 144 | |||
750 | 145 | // locate should throw (via mw) | ||
752 | 146 | MWRegistryProxy mw_reg = mw_->registry_proxy(); | 144 | MWRegistryProxy mw_reg = mw_->registry_proxy(); |
754 | 147 | EXPECT_THROW(mw_reg->locate("Dummy Demo Scope"), RegistryException); | 145 | EXPECT_THROW(mw_reg->get_metadata("dummy.scope.5"), NotFoundException); |
755 | 146 | EXPECT_THROW(mw_reg->locate("dummy.scope.5"), NotFoundException); | ||
756 | 148 | 147 | ||
757 | 149 | // list scopes (via mw) | 148 | // list scopes (via mw) |
758 | 150 | scopes = mw_reg->list(); | 149 | scopes = mw_reg->list(); |
759 | @@ -173,9 +172,6 @@ | |||
760 | 173 | EXPECT_EQ(2, meta.settings_definitions()[1].get_dict()["values"].get_array().size()); | 172 | EXPECT_EQ(2, meta.settings_definitions()[1].get_dict()["values"].get_array().size()); |
761 | 174 | EXPECT_EQ("Celsius", meta.settings_definitions()[1].get_dict()["values"].get_array()[0].get_string()); | 173 | EXPECT_EQ("Celsius", meta.settings_definitions()[1].get_dict()["values"].get_array()[0].get_string()); |
762 | 175 | EXPECT_EQ("Fahrenheit", meta.settings_definitions()[1].get_dict()["values"].get_array()[1].get_string()); | 174 | EXPECT_EQ("Fahrenheit", meta.settings_definitions()[1].get_dict()["values"].get_array()[1].get_string()); |
763 | 176 | |||
764 | 177 | // non-existant scope (via mw) | ||
765 | 178 | EXPECT_THROW(mw_reg->get_metadata("dummy.scope.5"), NotFoundException); | ||
766 | 179 | } | 175 | } |
767 | 180 | 176 | ||
768 | 181 | TEST_F(smartscopesproxytest, ss_registry_locale) | 177 | TEST_F(smartscopesproxytest, ss_registry_locale) |
769 | 182 | 178 | ||
770 | === modified file 'test/gtest/scopes/internal/zmq_middleware/RegistryI/RegistryI_test.cpp' | |||
771 | --- test/gtest/scopes/internal/zmq_middleware/RegistryI/RegistryI_test.cpp 2014-07-22 04:46:56 +0000 | |||
772 | +++ test/gtest/scopes/internal/zmq_middleware/RegistryI/RegistryI_test.cpp 2014-07-24 15:00:51 +0000 | |||
773 | @@ -370,10 +370,10 @@ | |||
774 | 370 | } | 370 | } |
775 | 371 | } | 371 | } |
776 | 372 | 372 | ||
778 | 373 | class RegistryTest : public Test | 373 | class RegistryITest : public Test |
779 | 374 | { | 374 | { |
780 | 375 | public: | 375 | public: |
782 | 376 | RegistryTest() | 376 | RegistryITest() |
783 | 377 | { | 377 | { |
784 | 378 | start_process_count = process_count(); | 378 | start_process_count = process_count(); |
785 | 379 | 379 | ||
786 | @@ -419,7 +419,7 @@ | |||
787 | 419 | } | 419 | } |
788 | 420 | } | 420 | } |
789 | 421 | 421 | ||
791 | 422 | ~RegistryTest() | 422 | ~RegistryITest() |
792 | 423 | { | 423 | { |
793 | 424 | // tear down the registry | 424 | // tear down the registry |
794 | 425 | reg.reset(); | 425 | reg.reset(); |
795 | @@ -506,7 +506,7 @@ | |||
796 | 506 | }; | 506 | }; |
797 | 507 | 507 | ||
798 | 508 | // test initial state | 508 | // test initial state |
800 | 509 | TEST_F(RegistryTest, locate_init) | 509 | TEST_F(RegistryITest, locate_init) |
801 | 510 | { | 510 | { |
802 | 511 | // check that no scope processes are running | 511 | // check that no scope processes are running |
803 | 512 | for (auto const& scope_id : scope_ids) | 512 | for (auto const& scope_id : scope_ids) |
804 | @@ -519,7 +519,7 @@ | |||
805 | 519 | } | 519 | } |
806 | 520 | 520 | ||
807 | 521 | // test locating the same scope multiple times | 521 | // test locating the same scope multiple times |
809 | 522 | TEST_F(RegistryTest, locate_one) | 522 | TEST_F(RegistryITest, locate_one) |
810 | 523 | { | 523 | { |
811 | 524 | // locate all scopes (hence starting all scope processes) | 524 | // locate all scopes (hence starting all scope processes) |
812 | 525 | for (auto const& scope_id : scope_ids) | 525 | for (auto const& scope_id : scope_ids) |
813 | @@ -541,7 +541,7 @@ | |||
814 | 541 | } | 541 | } |
815 | 542 | 542 | ||
816 | 543 | // test locating all scopes | 543 | // test locating all scopes |
818 | 544 | TEST_F(RegistryTest, locate_all) | 544 | TEST_F(RegistryITest, locate_all) |
819 | 545 | { | 545 | { |
820 | 546 | // locate all scopes (hence starting all scope processes) | 546 | // locate all scopes (hence starting all scope processes) |
821 | 547 | for (auto const& scope_id : scope_ids) | 547 | for (auto const& scope_id : scope_ids) |
822 | @@ -585,7 +585,7 @@ | |||
823 | 585 | }; | 585 | }; |
824 | 586 | 586 | ||
825 | 587 | // test scope death and rebinding | 587 | // test scope death and rebinding |
827 | 588 | TEST_F(RegistryTest, locate_rebinding) | 588 | TEST_F(RegistryITest, locate_rebinding) |
828 | 589 | { | 589 | { |
829 | 590 | // locate first scope | 590 | // locate first scope |
830 | 591 | EXPECT_EQ(proxies[scope_ids[0]], reg->locate(scope_ids[0])); | 591 | EXPECT_EQ(proxies[scope_ids[0]], reg->locate(scope_ids[0])); |
831 | @@ -622,7 +622,7 @@ | |||
832 | 622 | } | 622 | } |
833 | 623 | 623 | ||
834 | 624 | // test removing a scope | 624 | // test removing a scope |
836 | 625 | TEST_F(RegistryTest, locate_remove) | 625 | TEST_F(RegistryITest, locate_remove) |
837 | 626 | { | 626 | { |
838 | 627 | // locate all scopes (hence starting all scope processes) | 627 | // locate all scopes (hence starting all scope processes) |
839 | 628 | for (auto const& scope_id : scope_ids) | 628 | for (auto const& scope_id : scope_ids) |
840 | @@ -649,7 +649,7 @@ | |||
841 | 649 | } | 649 | } |
842 | 650 | 650 | ||
843 | 651 | // test custom scoperunner executable | 651 | // test custom scoperunner executable |
845 | 652 | TEST_F(RegistryTest, locate_custom_exec) | 652 | TEST_F(RegistryITest, locate_custom_exec) |
846 | 653 | { | 653 | { |
847 | 654 | ScopeProxy test_proxy = start_testscopeB(); | 654 | ScopeProxy test_proxy = start_testscopeB(); |
848 | 655 | 655 | ||
849 | @@ -680,7 +680,7 @@ | |||
850 | 680 | } | 680 | } |
851 | 681 | 681 | ||
852 | 682 | // test idle timeout of a scope | 682 | // test idle timeout of a scope |
854 | 683 | TEST_F(RegistryTest, locate_idle_timeout) | 683 | TEST_F(RegistryITest, locate_idle_timeout) |
855 | 684 | { | 684 | { |
856 | 685 | ScopeProxy test_proxy = start_testscopeB(); | 685 | ScopeProxy test_proxy = start_testscopeB(); |
857 | 686 | 686 |
Yep, +1