UpstartChrootTesting

WARNING: this document is still very much draft!

Testing Sessions with Upstart

Upstart now has support for chroot. It also has partial support for user sessions, but since this is experimental (and disabled in Ubuntu), this document does not cover testing this feature.

Unfortunately, the session support does not provide full tests. This is partly due to the complexity of automatically testing some of the scenarios below.

This document attempts to outline the minimum set of tests that should be performed to ensure that chroot support works as expected.

Setup

  1. install schroot
  2. debootstrap release into schroot
  3. create following files outside chroot:
    • /etc/init/foo.conf

          start on wibble
      
          script
            exec 2>>/tmp/foo.$$.log
            echo "foo: stat=`stat /`" 
            echo "foo: env=`env`"
            sleep 999 
          end script
    • /etc/init/outside_chroot.conf

          start on A
      
          script
            exec 2>>/tmp/in_chroot.$$.log
      
            exec 2>>/tmp/foo.$$.log
            echo "in_chroot: stat=`stat /`" 
            echo "in_chroot: env=`env`"
            sleep 999 
          end script
  4. create following files inside chroot environment:
    • /path/to/chroot/etc/init/foo.conf

          start on wibble
      
          script
            exec 2>>/tmp/foo.$$.log
            echo "foo: stat=`stat /`" 
            echo "foo: env=`env`" 
            sleep 999
          end script
    • /path/to/chroot/etc/init/in_chroot.conf

          start on A
      
          script
            exec 2>>/tmp/in_chroot.$$.log
      
            exec 2>>/tmp/foo.$$.log
            echo "in_chroot: stat=`stat /`" 
            echo "in_chroot: env=`env`" 
            sleep 999
          end script

Run as non-root with no chroot

  • initctl list
    • ensure list is contents of /etc/init/.
  • initctl status cron
    • should work.
  • initctl show-config cron
    • should work.
  • initctl check-config
    • should work.
  • start foo
    • should fail ("initctl: Rejected send message").
  • stop cron
    • should fail ("initctl: Rejected send message").
  • restart cron
    • should fail ("initctl: Rejected send message").
  • initctl emit bar
    • should fail ("initctl: Rejected send message").

Run as root with no chroot

  • initctl list
    • ensure list is contents of /etc/init/.
      • Command below should return no output:
            cmp <(initctl list|awk '{print }'|sort -u) <(cd /etc/init && ls *.conf|cut -d: -f2-|sed 's/\.conf//g'|sort -u)
  • initctl status outside_chroot
    • should work.
  • initctl status in_chroot
    • should fail with message:
      •     initct: Unknown job: in_chroot
  • initctl show-config <job>

  • initctl check-config <job>

  • start in_chroot
    • should fail with message:
      •     initct: Unknown job: in_chroot
  • start outside_chroot
    • should work.
  • stop in_chroot
    • should fail with message:
      •     initct: Unknown job: in_chroot
  • restart outside_chroot
    • should work.
  • stop outside_chroot
    • should work.
  • initctl emit wibble
    • Ensure /etc/init/foo.conf runs by looking at the log and ensuring
      • the inode for the stat of '/' is the same as running "stat /" on the command-line.
    • Ensure /path/to/chroot/etc/init/foo.conf DOES NOT run.
  • initctl emit A
    • Ensure /etc/init/outside_chroot.conf runs.
    • Ensure /path/to/chroot/etc/init/in_chroot.conf DOES NOT run.

Run as root inside a chroot

  • initctl list
    • ensure list is contents of /path/to/chroot/etc/init/.
      • Command below should return no output:
            cmp <(initctl list|awk '{print }'|sort -u) <(cd /etc/init && ls *.conf|cut -d: -f2-|sed 's/\.conf//g'|sort -u)
  • initctl status in_chroot
    • should work.
  • initctl status outside_chroot
    • should fail with message:
      •     initct: Unknown job: outside_chroot
  • initctl show-config <job>

  • initctl check-config <job>

  • start outside_chroot
    • should fail with message:
      •     initct: Unknown job: outside_chroot
  • stop outside_chroot
    • should fail with message:
      •     initct: Unknown job: outside_chroot
  • start in_chroot
    • should work.
  • restart in_chroot
    • should work.
  • stop in_chroot
    • should work.
  • initctl emit wibble
    • Ensure /path/to/chroot/etc/init/foo.conf runs by looking at the log and ensuring
      • the inode for the stat of '/' is the same as running "stat /" on the command-line.
    • Ensure /etc/init/foo.conf DOES NOT run.
  • initctl emit A
    • Ensure /path/to/chroot/etc/init/in_chroot.conf runs.
    • Ensure /etc/init/outside_chroot.conf DOES NOT run.

Run as non-root inside a chroot

Not supported.

Run with --no-sessions

The "--no-sessions" option makes Upstart behave as it used to prior to the introduction of session support.

1. Reboot system and specify "--no-sessions" on kernel command-line.

1. Ensure "initctl list" within a chroot displays the same list as

  • "initctl list" run outside of any chroot environment.

JamesHunt/UpstartChrootTesting (last edited 2011-06-03 13:48:00 by jamesodhunt)