Bug 70990

Summary: [1.0] Logger parallel-installability
Product: Telepathy Reporter: Simon McVittie <smcv>
Component: loggerAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium Keywords: patch
Version: git master   
Hardware: Other   
OS: All   
URL: http://cgit.collabora.com/git/user/cassidy/telepathy-glib/log/?h=logger-1-70990
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 49737    
Attachments: log-store-xml: stop using TPL_TEST_LOG_DIR
log-store-pidin: stop relying on TPL_TEST_LOG_DIR for tests
log stores: add constructor helpers
log-manager: use store constructor helpers
log-store-{pidgin,xml}: remove 'basedir' property
remove 'testmode' on log stores
logger tests: use store constructor helpers
log-store: add 'name' property
log-store: add 'writable' property
implement the empathy store using the XML store directly
Store XML logs to telepathy-1.0/
add XML legacy log store
fixed
Store XML logs to telepathy-1/
add XML legacy log store
log-store-pidin: stop relying on TPL_TEST_LOG_DIR for tests
log-store: add 'writable' property

Description Simon McVittie 2013-10-29 11:13:48 UTC
Decide whether Logger logs can be shared between Telepathy 0 and 1. If not, adapt the Logger to use a new v1 location.

I think the Logger uses its bus name as a mutex, so we might need it to write in a new directory, and do read-only access to the v0 logs? Or we could make it take the old bus name but not implement any objects?
Comment 1 Simon McVittie 2013-11-04 12:09:41 UTC
(Note that "telepathy-logger 1" is now part of the telepathy-glib repository.)
Comment 2 Guillaume Desmottes 2014-01-13 19:36:04 UTC
Created attachment 91976 [details] [review]
log-store-xml: stop using TPL_TEST_LOG_DIR
Comment 3 Guillaume Desmottes 2014-01-13 19:36:19 UTC
Created attachment 91977 [details] [review]
log-store-pidin: stop relying on TPL_TEST_LOG_DIR for tests
Comment 4 Guillaume Desmottes 2014-01-13 19:36:31 UTC
Created attachment 91978 [details] [review]
log stores: add constructor helpers
Comment 5 Guillaume Desmottes 2014-01-13 19:36:49 UTC
Created attachment 91979 [details] [review]
log-manager: use store constructor helpers
Comment 6 Guillaume Desmottes 2014-01-13 19:37:08 UTC
Created attachment 91980 [details] [review]
log-store-{pidgin,xml}: remove 'basedir' property
Comment 7 Guillaume Desmottes 2014-01-13 19:37:24 UTC
Created attachment 91981 [details] [review]
remove 'testmode' on log stores
Comment 8 Guillaume Desmottes 2014-01-13 19:37:57 UTC
Created attachment 91982 [details] [review]
logger tests: use store constructor helpers
Comment 9 Guillaume Desmottes 2014-01-13 19:38:23 UTC
Created attachment 91983 [details] [review]
log-store: add 'name' property
Comment 10 Guillaume Desmottes 2014-01-13 19:43:18 UTC
Created attachment 91984 [details] [review]
log-store: add 'writable' property
Comment 11 Guillaume Desmottes 2014-01-13 19:43:53 UTC
Created attachment 91985 [details] [review]
implement the empathy store using the XML store directly
Comment 12 Guillaume Desmottes 2014-01-13 19:44:10 UTC
Created attachment 91986 [details] [review]
Store XML logs to telepathy-1.0/
Comment 13 Guillaume Desmottes 2014-01-13 19:44:27 UTC
Created attachment 91987 [details] [review]
add XML legacy log store
Comment 14 Guillaume Desmottes 2014-01-14 09:44:14 UTC
I think that's the last thing needed to make the logger parallel installable, isn'it?
Comment 15 Simon McVittie 2014-01-14 10:27:43 UTC
Comment on attachment 91976 [details] [review]
log-store-xml: stop using TPL_TEST_LOG_DIR

Review of attachment 91976 [details] [review]:
-----------------------------------------------------------------

tests/logger/Makefile.am doesn't adjust XDG_DATA_HOME. Should it?

It would be great if the Logger's XDG_DATA_HOME could move into the tests themselves so they can safely be run without the wrapper (as a bonus, they could use separate log directories and become parallel-safe) but that's a job for the future.
Comment 16 Simon McVittie 2014-01-14 10:29:36 UTC
Comment on attachment 91977 [details] [review]
log-store-pidin: stop relying on TPL_TEST_LOG_DIR for tests

Review of attachment 91977 [details] [review]:
-----------------------------------------------------------------

::: telepathy-logger/log-store-pidgin.c
@@ +207,4 @@
>      {
>        gchar *dir;
>  
> +      dir = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".purple",

This is only OK for the tests because we have a hard dependency on GLib 2.36, in which g_get_home_dir() respects $HOME. I think this deserves a comment?
Comment 17 Simon McVittie 2014-01-14 10:30:01 UTC
Comment on attachment 91978 [details] [review]
log stores: add constructor helpers

Review of attachment 91978 [details] [review]:
-----------------------------------------------------------------

++
Comment 18 Simon McVittie 2014-01-14 10:30:20 UTC
Comment on attachment 91979 [details] [review]
log-manager: use store constructor helpers

Review of attachment 91979 [details] [review]:
-----------------------------------------------------------------

++
Comment 19 Simon McVittie 2014-01-14 10:30:45 UTC
Comment on attachment 91980 [details] [review]
log-store-{pidgin,xml}: remove 'basedir' property

Review of attachment 91980 [details] [review]:
-----------------------------------------------------------------

OK, if unused
Comment 20 Simon McVittie 2014-01-14 10:31:16 UTC
Comment on attachment 91981 [details] [review]
remove 'testmode' on log stores

Review of attachment 91981 [details] [review]:
-----------------------------------------------------------------

++
Comment 21 Simon McVittie 2014-01-14 10:31:33 UTC
Comment on attachment 91982 [details] [review]
logger tests: use store constructor helpers

Review of attachment 91982 [details] [review]:
-----------------------------------------------------------------

++
Comment 22 Simon McVittie 2014-01-14 10:40:30 UTC
Comment on attachment 91983 [details] [review]
log-store: add 'name' property

Review of attachment 91983 [details] [review]:
-----------------------------------------------------------------

::: telepathy-logger/log-store-pidgin.c
@@ +134,5 @@
> +
> +  g_free (priv->basedir);
> +  g_free (priv->name);
> +
> +  G_OBJECT_CLASS (tpl_log_store_pidgin_parent_class)->dispose (self);

should be ->finalize
Comment 23 Simon McVittie 2014-01-14 10:43:24 UTC
Comment on attachment 91985 [details] [review]
implement the empathy store using the XML store directly

Review of attachment 91985 [details] [review]:
-----------------------------------------------------------------

::: telepathy-logger/log-store-pidgin.c
@@ +93,4 @@
>          g_value_set_boolean (value, TRUE);
>          break;
>        case PROP_WRITABLE:
> +        g_value_set_boolean (value, self->priv->writable);

Why does this patch make log-store-pidgin potentially writable?

::: telepathy-logger/log-store-sqlite.c
@@ +119,4 @@
>          break;
>  
>        case PROP_WRITABLE:
> +        g_value_set_boolean (value, priv->writable);

I can see that there's value in being able to make a sqlite store read-only, but it should be mentioned in the commit message, which currently implies that only the XML store got this treatment.
Comment 24 Simon McVittie 2014-01-14 10:47:22 UTC
Comment on attachment 91987 [details] [review]
add XML legacy log store

Review of attachment 91987 [details] [review]:
-----------------------------------------------------------------

::: tests/logger/dbus/test-log-manager.c
@@ +325,1 @@
>    /* it includes 1 date from libpurple logs, 5 from TpLogger. Empathy

... 5 from telepathy-1.0 and 1 from TpLogger

I'd suggest using clever numbering to make it obvious which one(s) are being used, something like this:

* 1 item in libpurple
* 2 items in Empathy which are a subset of those in telepathy-1.0
* 4 items in TpLogger
* 8 in telepathy-1.0

Then you'd expect to see 13 items, and if you see anything different, you can work out what has gone wrong using binary.
Comment 25 Simon McVittie 2014-01-14 10:48:09 UTC
Comment on attachment 91986 [details] [review]
Store XML logs to telepathy-1.0/

Review of attachment 91986 [details] [review]:
-----------------------------------------------------------------

telepathy-1, perhaps? We've been reasonably consistent about that naming elsewhere.
Comment 26 Simon McVittie 2014-01-14 10:49:59 UTC
Looks good except where noted.

(In reply to comment #14)
> I think that's the last thing needed to make the logger parallel
> installable, isn'it?

Seems likely.
Comment 27 Guillaume Desmottes 2014-01-14 10:52:06 UTC
(In reply to comment #15)
> Comment on attachment 91976 [details] [review] [review]
> log-store-xml: stop using TPL_TEST_LOG_DIR
> 
> Review of attachment 91976 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> tests/logger/Makefile.am doesn't adjust XDG_DATA_HOME. Should it?

It was already set.

> It would be great if the Logger's XDG_DATA_HOME could move into the tests
> themselves so they can safely be run without the wrapper (as a bonus, they
> could use separate log directories and become parallel-safe) but that's a
> job for the future.

I tried that actually: relying on the C tests to set all the magic env variable itself. My goal was to run each test in its own /tmp/logger-tests-log-XXX/ directory and so be more self contained. But that didn't work because GLib internally cache the value of the variable, so it can't be changed during the lifetime of the process: https://git.gnome.org/browse/glib/tree/glib/gutils.c#n1156
Comment 28 Guillaume Desmottes 2014-01-14 10:53:42 UTC
(In reply to comment #16)
> Comment on attachment 91977 [details] [review] [review]
> log-store-pidin: stop relying on TPL_TEST_LOG_DIR for tests
> 
> Review of attachment 91977 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> ::: telepathy-logger/log-store-pidgin.c
> @@ +207,4 @@
> >      {
> >        gchar *dir;
> >  
> > +      dir = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".purple",
> 
> This is only OK for the tests because we have a hard dependency on GLib
> 2.36, in which g_get_home_dir() respects $HOME. I think this deserves a
> comment?

What do you mean? Purple logs are always stored in ~/.purple anyway.
Comment 29 Guillaume Desmottes 2014-01-14 10:58:13 UTC
(In reply to comment #22)
> Comment on attachment 91983 [details] [review] [review]
> log-store: add 'name' property
> 
> Review of attachment 91983 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> ::: telepathy-logger/log-store-pidgin.c
> @@ +134,5 @@
> > +
> > +  g_free (priv->basedir);
> > +  g_free (priv->name);
> > +
> > +  G_OBJECT_CLASS (tpl_log_store_pidgin_parent_class)->dispose (self);
> 
> should be ->finalize

Good catch; fixed.
Comment 30 Guillaume Desmottes 2014-01-14 11:00:57 UTC
(In reply to comment #23)
> Comment on attachment 91985 [details] [review] [review]
> implement the empathy store using the XML store directly
> 
> Review of attachment 91985 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> ::: telepathy-logger/log-store-pidgin.c
> @@ +93,4 @@
> >          g_value_set_boolean (value, TRUE);
> >          break;
> >        case PROP_WRITABLE:
> > +        g_value_set_boolean (value, self->priv->writable);
> 
> Why does this patch make log-store-pidgin potentially writable?
> 
> ::: telepathy-logger/log-store-sqlite.c
> @@ +119,4 @@
> >          break;
> >  
> >        case PROP_WRITABLE:
> > +        g_value_set_boolean (value, priv->writable);
> 
> I can see that there's value in being able to make a sqlite store read-only,
> but it should be mentioned in the commit message, which currently implies
> that only the XML store got this treatment.

I just naively implemented the property in each implementation of the log store interface, wich requires a setting function as the property is write only.
Actually I'm wondering if it wouldn't be easier/cleaner to turn the store iface to a base class so it could implement the property itself, saving us to do it in each store. What do you think?
Comment 31 Guillaume Desmottes 2014-01-14 11:06:19 UTC
Created attachment 92031 [details] [review]
fixed
Comment 32 Guillaume Desmottes 2014-01-14 11:07:36 UTC
Created attachment 92032 [details] [review]
Store XML logs to telepathy-1/

changed.
Comment 33 Simon McVittie 2014-01-14 11:43:02 UTC
(In reply to comment #27)
> > tests/logger/Makefile.am doesn't adjust XDG_DATA_HOME. Should it?
> 
> It was already set.

tests/logger/dbus/Makefile.am does set it, but tests/logger/Makefile.am doesn't? (Perhaps that doesn't matter, though.)

(In reply to comment #28)
> > This is only OK for the tests because we have a hard dependency on GLib
> > 2.36, in which g_get_home_dir() respects $HOME. I think this deserves a
> > comment?
> 
> What do you mean? Purple logs are always stored in ~/.purple anyway.

Before GLib 2.36, g_get_home_dir() used the equivalent of `getent passwd` to find the home directory, and ignored $HOME. (There was a Debian-specific patch to use $G_HOME.)

(In reply to comment #30)
> > I can see that there's value in being able to make a sqlite store read-only,
> > but it should be mentioned in the commit message, which currently implies
> > that only the XML store got this treatment.
> 
> I just naively implemented the property in each implementation of the log
> store interface, wich requires a setting function as the property is write
> only.

Ah, I understand now.

I think the Pidgin log store should g_warn_if_fail (writable == FALSE) or something, and be read-only anyway.

> Actually I'm wondering if it wouldn't be easier/cleaner to turn the store
> iface to a base class so it could implement the property itself, saving us
> to do it in each store. What do you think?

Neutral. If you want to do this I won't stop you, but I don't fully understand how much of this stuff is exposed to API users, and interface > class in terms of minimizing API guarantees.
Comment 34 Simon McVittie 2014-01-14 11:43:58 UTC
Comment on attachment 92031 [details] [review]
fixed

Review of attachment 92031 [details] [review]:
-----------------------------------------------------------------

Looks OK
Comment 35 Simon McVittie 2014-01-14 11:44:13 UTC
Comment on attachment 92032 [details] [review]
Store XML logs to telepathy-1/

Review of attachment 92032 [details] [review]:
-----------------------------------------------------------------

Sure
Comment 36 Guillaume Desmottes 2014-01-14 12:51:39 UTC
Created attachment 92037 [details] [review]
add XML legacy log store

Fixed the comment.

I tried adding more logs as you suggested but it broke at lot of others tests which are very strict expectations on the number and order logs stored and I didn't bother fixing all of those.
Comment 37 Guillaume Desmottes 2014-01-14 13:02:01 UTC
(In reply to comment #33)
> (In reply to comment #27)
> > > tests/logger/Makefile.am doesn't adjust XDG_DATA_HOME. Should it?
> > 
> > It was already set.
> 
> tests/logger/dbus/Makefile.am does set it, but tests/logger/Makefile.am
> doesn't? (Perhaps that doesn't matter, though.)

Yeah all the actual tests are in tests/logger/dbus.

> (In reply to comment #28)
> > > This is only OK for the tests because we have a hard dependency on GLib
> > > 2.36, in which g_get_home_dir() respects $HOME. I think this deserves a
> > > comment?
> > 
> > What do you mean? Purple logs are always stored in ~/.purple anyway.
> 
> Before GLib 2.36, g_get_home_dir() used the equivalent of `getent passwd` to
> find the home directory, and ignored $HOME. (There was a Debian-specific
> patch to use $G_HOME.)

Ah I see. Adding a comment.

> (In reply to comment #30)
> > > I can see that there's value in being able to make a sqlite store read-only,
> > > but it should be mentioned in the commit message, which currently implies
> > > that only the XML store got this treatment.
> > 
> > I just naively implemented the property in each implementation of the log
> > store interface, wich requires a setting function as the property is write
> > only.
> 
> Ah, I understand now.
> 
> I think the Pidgin log store should g_warn_if_fail (writable == FALSE) or
> something, and be read-only anyway.

Good point; adding that.

> > Actually I'm wondering if it wouldn't be easier/cleaner to turn the store
> > iface to a base class so it could implement the property itself, saving us
> > to do it in each store. What do you think?
> 
> Neutral. If you want to do this I won't stop you, but I don't fully
> understand how much of this stuff is exposed to API users, and interface >
> class in terms of minimizing API guarantees.

Fair enough; let's keep it as it for now.
Comment 38 Guillaume Desmottes 2014-01-14 13:05:52 UTC
Created attachment 92038 [details] [review]
log-store-pidin: stop relying on TPL_TEST_LOG_DIR for tests
Comment 39 Guillaume Desmottes 2014-01-14 13:15:33 UTC
Created attachment 92040 [details] [review]
log-store: add 'writable' property
Comment 40 Guillaume Desmottes 2014-02-17 13:31:21 UTC
Review ping? That's one of our latest 1.0 blocker.
Comment 41 Simon McVittie 2014-03-20 16:38:01 UTC
Reviewing this, sorry for the delay.
Comment 42 Simon McVittie 2014-03-20 17:02:12 UTC
(In reply to comment #27)
> > tests/logger/Makefile.am doesn't adjust XDG_DATA_HOME. Should it?
> 
> It was already set.

Not in tests/logger/Makefile.am, only in tests/logger/dbus/Makefile.am.

Also, there's a difference:

tests/logger/dbus/Makefile.am:    TPL_TEST_LOG_DIR=@abs_top_srcdir@/tests/logger/logs           \
tests/logger/dbus/Makefile.am:    XDG_DATA_HOME=@abs_top_builddir@/tests/logger/logs            \

Which should it be?

I wonder whether we should in fact be creating a temporary directory in the builddir, and copying the logs in from the srcdir before each test?
Comment 43 Simon McVittie 2014-03-20 17:26:51 UTC
(In reply to comment #42)
> Not in tests/logger/Makefile.am, only in tests/logger/dbus/Makefile.am.

I fixed that.

> tests/logger/dbus/Makefile.am:   
> TPL_TEST_LOG_DIR=@abs_top_srcdir@/tests/logger/logs           \
> tests/logger/dbus/Makefile.am:   
> XDG_DATA_HOME=@abs_top_builddir@/tests/logger/logs            \

I fixed that; it should have been consistently the srcdir (tests failed without this change, and pass with it).

> I wonder whether we should in fact be creating a temporary directory in the
> builddir, and copying the logs in from the srcdir before each test?

The tests that need write access already do that.

Pushed with those changes.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.