Merge lp://staging/~jamesodhunt/upstart/bug-1238078 into lp://staging/upstart

Proposed by James Hunt
Status: Merged
Merged at revision: 1561
Proposed branch: lp://staging/~jamesodhunt/upstart/bug-1238078
Merge into: lp://staging/upstart
Diff against target: 19782 lines (+19467/-52)
11 files modified
ChangeLog (+52/-5)
init/Makefile.am (+2/-1)
init/job_class.c (+67/-5)
init/job_class.h (+8/-0)
init/state.c (+25/-1)
init/tests/data/upstart-1.11.json (+19034/-0)
init/tests/test_state.c (+85/-1)
test/test_util_common.c (+89/-35)
test/test_util_common.h (+7/-2)
util/man/initctl.8 (+2/-1)
util/tests/test_initctl.c (+96/-1)
To merge this branch: bzr merge lp://staging/~jamesodhunt/upstart/bug-1238078
Reviewer Review Type Date Requested Status
Steve Langasek Needs Fixing
Review via email: mp+190723@code.staging.launchpad.net

Description of the change

Fix for bug 1238078:

------------------------------------------------------------
revno: 1545
committer: James Hunt <email address hidden>
branch nick: upstart-bug-1238078
timestamp: Fri 2013-10-11 17:17:19 +0100
message:
  * test/test_util_common.c:
    - session_init_reexec(): New.
    - set_upstart_session(): Whitespace.
  * test/test_util_common.h: REEXEC_UPSTART(): Update to handle Session
    Inits too.
  * util/man/initctl.8: Clarify 'set-env' behaviour.
  * util/tests/test_initctl.c: New tests:
    - "ensure 'set-env' persists across session-init re-exec".
    - "ensure 'set-env --global' persists across session-init re-exec".
------------------------------------------------------------
revno: 1544
fixes bug: https://launchpad.net/bugs/1238078
committer: James Hunt <email address hidden>
branch nick: upstart-bug-1238078
timestamp: Fri 2013-10-11 14:35:51 +0100
message:
  * init/job_class.c:
    - job_class_serialise_job_environ(): New function to serialise global
      job environment table.
    - job_class_deserialise_job_environ(): New function to deserialise global
      job environment table.
  * init/state.c:
    - state_to_string(): Serialise global job environment table
      (LP: #1238078).
    - state_from_string(): Deserialise global job environment table.
    - _state_deserialise_str_array(): Don't attempt to free array if type
      check fails.

To post a comment you must log in.
Revision history for this message
James Hunt (jamesodhunt) wrote :

I need to add a few more .json test files before this is merged.

Revision history for this message
Steve Langasek (vorlon) wrote :

per above :)

review: Needs Fixing
Revision history for this message
James Hunt (jamesodhunt) wrote :

New tests added.

Revision history for this message
Steve Langasek (vorlon) wrote :

Hi James,

What's the difference between the upstart-reload-signal.json test and the upstart-no-job-environ.json test? AFAICS, there isn't one. If the serialization format hasn't changed between 1.9 and 1.10, we shouldn't add a redundant test here, it's unnecessary and confusing.

Also, perhaps it would be a good idea to name these json data tests after the upstream versions they correspond to, so that it's clearer? For instance, upstart-reload-signal.json could be called 'upstart-1.9.json', and upstart-with-job-environ.json could be called 'upstart-1.11.json'.

I'm not sure if (or how) the separate session-init tests are needed. They contain different data (since they're obviously taken from a running session init's state rather than a system init), but there shouldn't be any differences in the *format*, should there? If there are no differences, then I think the tests are redundant and should be omitted. If there are differences, please call this out more clearly so that it's understood at a glance what we're testing for.

I haven't had a chance yet to review the code; will do that tomorrow and send any further comments.

review: Needs Fixing
1547. By James Hunt

* init/tests/test_state.c: Removed some redundant JSON upgrade
  tests and renamed some existing data files to reflect the
  serialisation format version they encapsulate.

1548. By James Hunt

* Sync with lp:upstart.

Revision history for this message
James Hunt (jamesodhunt) wrote :

Hi Steve,

> What's the difference between the upstart-reload-signal.json test and
> the upstart-no-job-environ.json test? AFAICS, there isn't one. If the
> serialization format hasn't changed between 1.9 and 1.10, we shouldn't
> add a redundant test here, it's unnecessary and confusing.
Ack - gone.

>
> Also, perhaps it would be a good idea to name these json data tests
> after the upstream versions they correspond to, so that it's clearer?
> For instance, upstart-reload-signal.json could be called
> 'upstart-1.9.json', and upstart-with-job-environ.json could be called
> 'upstart-1.11.json'.
Agreed. We just need to remember to update upstart-1.11.json if new
serialisation data is added prior to 1.11 being released.

> I'm not sure if (or how) the separate session-init tests are needed.
> They contain different data (since they're obviously taken from a
> running session init's state rather than a system init), but there
> shouldn't be any differences in the *format*, should there? If there are
> no differences, then I think the tests are redundant and should be
> omitted. If there are differences, please call this out more clearly so
> that it's understood at a glance what we're testing for.
Right - there is no difference in the format of the data in the session
init .json files: the Session Init tests were an attempt to ensure
correct deserialisation of a "non-default" job environment table (which
can only be non-default when running as a Session Init). However, I
think you are right: these tests aren't really adding much since to
test that setup. Really, we need to be able to feed the .json files
to an actual Session Init process and we don't currently have that
ability.

> I haven't had a chance yet to review the code; will do that tomorrow and
> send any further comments.
Thanks!

Branch updated.

Revision history for this message
Steve Langasek (vorlon) wrote :

Ok, finally found the time to fully review this patch. The revised json looks good. I have just a couple other comments:

- "_state_deserialise_str_array(): Don't attempt to free array if type check fails." It's not at all clear to me how this relates to the rest of the code changes. If this is fixing a problem exposed by the addition of the environment serialization, it would be better if this were made more explicit - and probably kept in a commit all to its own. (This does not warrant redoing the branch, but please keep in mind for the future.)

- I don't understand the added test_initctl test case. You appear to be dynamically creating a job that has both an 'exec' and a 'script' stanza. I don't know if this is an accident or if you're relying on some particular behavior of upstart here, but if it's the latter I think this should be done some other way because the current job definition is quite opaque. If this *isn't* relying on some upstart behavior that I don't know about, then I suspect this job doesn't actually do what you intend anyway, because it talks about using a flag file to notify the job that upstart has re-execed "to allow it to move out of pre-start", but the only place the job watches for this file after creating it is in a post-stop script. So I suspect that the test succeeds but is not actually testing what it's meant to because of a broken job definition. Please take a close look at this.

- Finally, you've added a commented-out call to a non-existent test_reexec_job_env function, which should be dropped from the patch.

review: Needs Fixing
1549. By James Hunt

* test/test_util_common.h: WAIT_FOR_FILE(): Check @path not logfile.

1550. By James Hunt

* util/tests/test_initctl.c: test_reexec(): Fixed behaviour and comments
  for test "ensure 'set-env --global' persists across session-init
  re-exec".

1551. By James Hunt

* Sync with lp:upstart.

Revision history for this message
James Hunt (jamesodhunt) wrote :

> - "_state_deserialise_str_array(): Don't attempt to free array if type check fails." It's not at all clear to me how this relates to the rest of the code changes. If this is fixing a problem exposed by the addition of the environment serialization, it would be better if this were made more explicit - and probably kept in a commit all to its own. (This does not warrant redoing the branch, but please keep in mind for the future.)
No, I just noticed this additional issue whilst fixing the main bug. I guess it should prolly have had more prominence and a separate commit, but atleast the bug is now fixed :)

> - I don't understand the added test_initctl test case. You appear to be dynamically creating a job that has both an 'exec' and a 'script' stanza. I don't know if this is an accident or if you're relying on some particular behavior of upstart here, but if it's the latter I think this should be done some other way because the current job definition is quite opaque. If this *isn't* relying on some upstart behavior that I don't know about, then I suspect this job doesn't actually do what you intend anyway, because it talks about using a flag file to notify the job that upstart has re-execed "to allow it to move out of pre-start", but the only place the job watches for this file after creating it is in a post-stop script. So I suspect that the test succeeds but is not actually testing what it's meant to because of a broken job definition. Please take a close look at this.
Good catch - comments were misleading and indeed the auto-generated job was incorrect.

> - Finally, you've added a commented-out call to a non-existent test_reexec_job_env function, which should be dropped from the patch.
Done.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches