~ubuntu-cloud-archive/ubuntu/precise/nova/trunk

« back to all changes in this revision

Viewing changes to nova/tests/test_nova_rootwrap.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-07-06 10:18:33 UTC
  • mfrom: (1.1.58)
  • Revision ID: package-import@ubuntu.com-20120706101833-wp2nv392mpe9re8p
Tags: 2012.2~f2-0ubuntu1
[ Adam Gandelman ]
* Use new rootwrap configuration structure:
  - debian/nova-{compute, network, volume}.{pyinstall, pyremove}: Dropped.
  - debian/nova-common.dirs: Add /etc/nova/rootwrap.d/.
  - debian/nova-common.install: Install /etc/nova/rootwrap.conf.
  - debian/debian/nova.conf: Reference rootwrap.conf in calls to
    nova-rootwrap.
  - debian/nova-{compute, network, volume}.install: Install corresponding
    filter in /etc/nova/rootwrap.d/
* debian/rules: Install logging_sample.conf to /etc/nova/logging.conf
  as part of nova-common.
* debian/pydist-overrides: Add setuptools-git.
* debian/control: Add python-setuptools-git as a Build-Depends.
* debian/rules: Do not remove nova.egg-info during auto_clean.  Now that
  upstream has moved to setuptools-git, doing so results in missing files
  from built package.

[ Chuck Short ]
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
                  "Test requires /proc filesystem (procfs)")
68
68
    def test_KillFilter(self):
69
69
        p = subprocess.Popen(["/bin/sleep", "5"])
70
 
        f = filters.KillFilter("/bin/kill", "root",
71
 
                               ["-ALRM"],
72
 
                               ["/bin/sleep", "/usr/bin/sleep"])
73
 
        usercmd = ['kill', '-9', p.pid]
 
70
        f = filters.KillFilter("root", "/bin/sleep", "-9", "-HUP")
 
71
        f2 = filters.KillFilter("root", "/usr/bin/sleep", "-9", "-HUP")
 
72
        usercmd = ['kill', '-ALRM', p.pid]
74
73
        # Incorrect signal should fail
75
 
        self.assertFalse(f.match(usercmd))
 
74
        self.assertFalse(f.match(usercmd) or f2.match(usercmd))
76
75
        usercmd = ['kill', p.pid]
77
76
        # Providing no signal should fail
78
 
        self.assertFalse(f.match(usercmd))
 
77
        self.assertFalse(f.match(usercmd) or f2.match(usercmd))
 
78
        # Providing matching signal should be allowed
 
79
        usercmd = ['kill', '-9', p.pid]
 
80
        self.assertTrue(f.match(usercmd) or f2.match(usercmd))
79
81
 
80
 
        f = filters.KillFilter("/bin/kill", "root",
81
 
                               ["-9", ""],
82
 
                               ["/bin/sleep", "/usr/bin/sleep"])
83
 
        usercmd = ['kill', '-9', os.getpid()]
 
82
        f = filters.KillFilter("root", "/bin/sleep")
 
83
        f2 = filters.KillFilter("root", "/usr/bin/sleep")
 
84
        usercmd = ['kill', os.getpid()]
84
85
        # Our own PID does not match /bin/sleep, so it should fail
85
 
        self.assertFalse(f.match(usercmd))
86
 
        usercmd = ['kill', '-9', 999999]
 
86
        self.assertFalse(f.match(usercmd) or f2.match(usercmd))
 
87
        usercmd = ['kill', 999999]
87
88
        # Nonexistant PID should fail
88
 
        self.assertFalse(f.match(usercmd))
 
89
        self.assertFalse(f.match(usercmd) or f2.match(usercmd))
89
90
        usercmd = ['kill', p.pid]
90
91
        # Providing no signal should work
91
 
        self.assertTrue(f.match(usercmd))
92
 
        usercmd = ['kill', '-9', p.pid]
93
 
        # Providing -9 signal should work
94
 
        self.assertTrue(f.match(usercmd))
 
92
        self.assertTrue(f.match(usercmd) or f2.match(usercmd))
95
93
 
96
94
    def test_KillFilter_no_raise(self):
97
95
        """Makes sure ValueError from bug 926412 is gone"""
98
 
        f = filters.KillFilter("/bin/kill", "root", [""])
 
96
        f = filters.KillFilter("root", "")
99
97
        # Providing anything other than kill should be False
100
98
        usercmd = ['notkill', 999999]
101
99
        self.assertFalse(f.match(usercmd))
109
107
        def fake_readlink(blah):
110
108
            return '/bin/commandddddd (deleted)'
111
109
 
112
 
        f = filters.KillFilter("/bin/kill", "root",
113
 
                               [""],
114
 
                               ["/bin/commandddddd"])
 
110
        f = filters.KillFilter("root", "/bin/commandddddd")
115
111
        usercmd = ['kill', 1234]
116
112
        # Providing no signal should work
117
113
        self.stubs.Set(os, 'readlink', fake_readlink)