Merge lp:~marcustomlinson/unity-scopes-api/merge-trunk into lp:unity-scopes-api/devel

Proposed by Marcus Tomlinson
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
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.

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Yep, +1

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
422. By Marcus Tomlinson

Whoops, one change that shouldn't have been reverted

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

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

Subscribers

People subscribed via source and target branches

to all changes: