Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
introducing atomic
  • Loading branch information
dparalen committed Nov 21, 2014
1 parent 41a1eaa commit d666f26
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 15 deletions.
23 changes: 13 additions & 10 deletions dva/test/testcase_02_selinux_context.py
Expand Up @@ -4,7 +4,16 @@
import os
import tempfile
from testcase import Testcase
from collections import defaultdict

EXCLUDED_PATHS = defaultdict(lambda: ['/mnt', '/proc', '/sys'], {
'ATOMIC': [ '/var/mnt', '/proc', '/sys', '/sysroot/' ]
})

def restorecon_cmd(product):
'''return a restorecon cmd to execute remotely to get list of changes'''
return 'restorecon -R -v -n ' + ' '.join(map(lambda path: '-e ' + path, EXCLUDED_PATHS[product])) + \
''' | sed -e 's, context , ,' -e 's,^restorecon reset ,,' '''

class testcase_02_selinux_context(Testcase):
"""
Expand All @@ -19,8 +28,8 @@ def test(self, connection, params):
prod = params['product'].upper()
ver = params['version']
#get the restorecon output file
# pylint: disable=C0301
self.ping_pong(connection, "restorecon -R -v -n -e /proc -e /sys -e /mnt / | sed -e 's, context , ,' -e 's,^restorecon reset ,,' | cat > /tmp/restorecon_output.txt && echo SUCCESS", "\r\nSUCCESS\r\n", 260)
self.ping_pong(connection, restorecon_cmd(prod) + " > /tmp/restorecon_output.txt && echo SUCCESS",
"\r\nSUCCESS\r\n", 260)
tfile = tempfile.NamedTemporaryFile(delete=False)
tfile.close()
connection.sftp.get('/tmp/restorecon_output.txt', tfile.name)
Expand All @@ -40,14 +49,8 @@ def test(self, connection, params):
restorecon_dict[filename] = [source_context, destination_context]
#figure out if there are new/lost entries or the restorecon output matched the list of allowed exclusions
with open(self.datadir + '/selinux_context.yaml') as selinux_context:
context_exclusions_ = yaml.load(selinux_context)
try:
context_exclusions = context_exclusions_['%s_%s' % (prod, ver)]
except KeyError:
self.log.append({
'result': 'skip',
'comment': 'unsupported product-version combination'})
return self.log
# by default, no SELinux issues are expected for untracked product/version combinations
context_exclusions = defaultdict(lambda: {}, yaml.load(selinux_context))['%s_%s' % (prod, ver)]

lost_entries = []
for filename in context_exclusions:
Expand Down
2 changes: 1 addition & 1 deletion dva/test/testcase_07_libc6_xen_conf.py
Expand Up @@ -8,7 +8,7 @@ class testcase_07_libc6_xen_conf(Testcase):
Check for /etc/ld.so.conf.d/libc6-xen.conf absence on RHEL
"""
stages = ['stage1']
applicable = {'product': '(?i)RHEL|BETA'}
applicable = {'product': '(?i)RHEL|BETA|ATOMIC'}
tags = ['default']

# pylint: disable=W0613
Expand Down
2 changes: 1 addition & 1 deletion dva/test/testcase_360_ebs.py
Expand Up @@ -15,7 +15,7 @@ class testcase_360_ebs(Testcase):
"""
stages = ['stage1']
tags = ['default', 'kernel']
applicable = {"product": "(?i)RHEL|BETA", 'cloud': 'ec2', 'version': 'OS (>=5.5, !=6.0)'}
applicable = {"product": "(?i)RHEL|BETA|ATOMIC", 'cloud': 'ec2', 'version': 'OS (>=5.5, !=6.0)'}

def test(self, connection, params):
""" Perform test """
Expand Down
2 changes: 1 addition & 1 deletion dva/test/testcase_41_rh_amazon_rhui_client.py
Expand Up @@ -8,7 +8,7 @@ class testcase_41_rh_amazon_rhui_client(Testcase):
"""
tags = ['default']
stages = ['stage1']
not_applicable = {'product': '(?i)FEDORA'}
not_applicable = {'product': '(?i)FEDORA|ATOMIC'}

def test(self, connection, params):
""" Perform test """
Expand Down
1 change: 1 addition & 0 deletions dva/test/testcase_61_yum_proxy.py
Expand Up @@ -11,6 +11,7 @@ class testcase_61_yum_proxy(Testcase):
stages = ['stage1']
after = ['testcase_60_yum_update']
tags = ['default', 'content']
not_applicable = {'product': '(?i)atomic'}

def test(self, connection, params):
""" Perform test """
Expand Down
2 changes: 1 addition & 1 deletion dva/test/testcase_62_cpuflags.py
Expand Up @@ -8,7 +8,7 @@ class testcase_62_cpuflags(Testcase):
"""
stages = ['stage1', 'stage2']
tags = ['default', 'kernel']
applicable = {'virtualization': 'hvm', 'product': 'BETA|RHEL', 'version': 'OS (>=6.6)'}
applicable = {'virtualization': 'hvm', 'product': '(?i)BETA|RHEL|ATOMIC', 'version': 'OS (>=6.6)'}

# pylint: disable=unused-argument
def test(self, connection, params):
Expand Down
1 change: 1 addition & 0 deletions dva/test/testcase_90_1_kernel_bug874053.py
Expand Up @@ -9,6 +9,7 @@ class testcase_90_1_kernel_bug874053(Testcase):
"""
stages = ['stage1']
tags = ['kernel']
not_applicable = {'product': '(?i)ATOMIC'}

def test(self, connection, params):
""" Perform test """
Expand Down
1 change: 1 addition & 0 deletions dva/test/testcase_90_2_cgroups_kernel_bug914737.py
Expand Up @@ -9,6 +9,7 @@ class testcase_90_2_cgroups_kernel_bug914737(Testcase):
"""
stages = ['stage1']
tags = ['kernel']
not_applicable = {'product': '(?i)ATOMIC'}

def test(self, connection, params):
""" Perform test """
Expand Down
5 changes: 4 additions & 1 deletion dva/work/stage.py
Expand Up @@ -23,7 +23,7 @@
CREATE_ATTEMPTS=360
SETUP_ATTEMPTS = 30
SETUP_SETTLEWAIT = 30
SSH_USERS = ['root', 'ec2-user', 'fedora']
SSH_USERS = ['root', 'ec2-user', 'fedora', 'cloud-user']
DEFAULT_GLOBAL_SETUP_SCRIPT_TIMEOUT = 120
OLD_BASH_HISTORY_FILE = '~/DVA_OLD_BASH_HISTORY'

Expand Down Expand Up @@ -142,10 +142,13 @@ def allow_root_login(params):
return params

from textwrap import dedent
# FIXME: copying the skel items explicitly so paramiko minds the prompt
# rhel/fedora atomic issue: http://ask.projectatomic.io/en/question/141/root-home-missing-usual-skel-items/
command = dedent(r'''
sudo cp -af /home/%s/.ssh/authorized_keys /root/.ssh/authorized_keys && \
sudo chown root.root /root/.ssh/authorized_keys && \
sudo restorecon -Rv /root/.ssh && \
sudo cp -f /etc/skel/.bash* ~root/ && \
echo SUCCESS
''' % user)

Expand Down

0 comments on commit d666f26

Please sign in to comment.