From: Ihar Hrachyshka Date: Sun, 18 Jan 2015 11:59:39 +0000 (+0100) Subject: Drop _test_rootwrap_exec test X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ce5f38f542a66dba452b4e85155948fefaa0a6c8;p=openstack-build%2Fneutron-build.git Drop _test_rootwrap_exec test It's not a unit test and didn't participate in gating. The test would belong to functional suite, though since it's pretty trivial, and rootwrap is already tested as part of other functional tests, it's better to drop it then adopt to new requirements. Change-Id: I1667f2127b045cf002ae8516624afe9efe919fb7 --- diff --git a/neutron/tests/unit/_test_rootwrap_exec.py b/neutron/tests/unit/_test_rootwrap_exec.py deleted file mode 100644 index 7c119c53c..000000000 --- a/neutron/tests/unit/_test_rootwrap_exec.py +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright (c) 2012 OpenStack Foundation -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import os - -import fixtures - -from neutron.agent.linux import utils -from neutron.openstack.common import log as logging -from neutron.tests import base - - -LOG = logging.getLogger(__name__) - - -class RootwrapTestExec(base.BaseTestCase): - """Simple unit test to test the basic rootwrap mechanism - - Essentially hello-world. Just run a command as root and check that - it actually *did* run as root, and generated the right output. - - NB that this is named _test_rootwrap so as not to get run by default - from scripts like tox. That's because it actually executes a sudo'ed - command, and that won't work in the automated test environment, at - least as it stands today. To run this, rename it to - test_rootwrap.py, or run it by hand. - """ - - def setUp(self): - super(RootwrapTestExec, self).setUp() - self.cwd = os.getcwd() + "/../../.." - # stuff a stupid bash script into /tmp, so that the next - # method can execute it. - self.test_file = self.useFixture( - fixtures.TempDir()).join("rootwrap-test.sh") - with open(self.test_file, 'w') as f: - f.write('#!/bin/bash\n') - f.write('ID=`id | sed \'s/uid=//\' | sed \'s/(.*//\' `\n') - f.write("echo $ID $1\ -\" Now is the time for all good men to come \ -to the aid of their party.\"\n") - # we need a temporary conf file, pointing into pwd for the filter - # specs. there's probably a better way to do this, but I couldn't - # figure it out. 08/15/12 -- jrd - self.conf_file = self.useFixture( - fixtures.TempDir()).join("rootwrap.conf") - with open(self.conf_file, 'w') as f: - f.write("# temporary conf file for rootwrap-test, " + - "generated by test_rootwrap.py\n") - f.write("[DEFAULT]\n") - f.write("filters_path=" + self.cwd + - "/neutron/tests/etc/rootwrap.d/") - # now set the root helper to sudo our rootwrap script, - # with the new conf - self.root_helper = "sudo " + self.cwd + "/bin/neutron-rootwrap " - self.root_helper += self.conf_file - - def runTest(self): - try: - result = utils.execute(["bash", self.test_file, 'arg'], - self.root_helper) - self.assertEqual(result, - "0 arg Now is the time for all good men to \ -come to the aid of their party.") - except Exception: - LOG.exception("Losing in rootwrap test") - - def tearDown(self): - os.remove(self.test_file) - os.remove(self.conf_file) - super(RootwrapTestExec, self).tearDown()