Merge "Remove puppet modules tests"
This commit is contained in:
@@ -8,6 +8,5 @@ Documentation for the QA test code repo
|
|||||||
models.rst
|
models.rst
|
||||||
helpers.rst
|
helpers.rst
|
||||||
base_tests.rst
|
base_tests.rst
|
||||||
puppet_tests.rst
|
|
||||||
testrail.rst
|
testrail.rst
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
.. index:: Puppet tests
|
|
||||||
|
|
||||||
Puppet tests
|
|
||||||
============
|
|
||||||
|
|
||||||
Puppet test generator
|
|
||||||
---------------------
|
|
||||||
.. automodule:: fuelweb_test.puppet_tests.pp_testgenerator
|
|
||||||
:members:
|
|
||||||
|
|
||||||
Puppet module
|
|
||||||
-------------
|
|
||||||
.. automodule:: fuelweb_test.puppet_tests.puppet_module
|
|
||||||
:members:
|
|
||||||
|
|
||||||
Puppet test
|
|
||||||
-----------
|
|
||||||
.. automodule:: fuelweb_test.puppet_tests.puppet_test
|
|
||||||
:members:
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
"""
|
|
||||||
Script for creating Puppet integration tests scripts using template engine.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
from puppet_tests.pp_testgenerator import PuppetTestGenerator
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument("tests", type=str, help="Directory to save tests")
|
|
||||||
parser.add_argument("modules", type=str, help="Path to Puppet modules")
|
|
||||||
parser.add_argument("-k", "--keep_tests",
|
|
||||||
action='store_true',
|
|
||||||
help="Keep previous test files",
|
|
||||||
default=False)
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
generator = PuppetTestGenerator(args.tests, args.modules)
|
|
||||||
if not args.keep_tests:
|
|
||||||
generator.remove_all_tests()
|
|
||||||
|
|
||||||
generator.make_all_scripts()
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
# Copyright 2014 Mirantis, Inc.
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
|
|
||||||
from devops.helpers.helpers import tcp_ping
|
|
||||||
from devops.helpers.helpers import wait
|
|
||||||
from fuelweb_test.models.environment import EnvironmentModel
|
|
||||||
from fuelweb_test import settings
|
|
||||||
|
|
||||||
|
|
||||||
class PuppetEnvironment(EnvironmentModel):
|
|
||||||
"""Create environment for puppet modules testing."""
|
|
||||||
|
|
||||||
def __init__(self, os_image=None):
|
|
||||||
"""Constructor for create environment."""
|
|
||||||
self.os_image = os_image or settings.OS_IMAGE
|
|
||||||
super(PuppetEnvironment, self).__init__(self.os_image)
|
|
||||||
self.environment = super(PuppetEnvironment, self).d_env
|
|
||||||
self.start_env()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def env_name(self):
|
|
||||||
return os.environ.get('PPENV_NAME', 'pp-integration')
|
|
||||||
|
|
||||||
def start_env(self):
|
|
||||||
self.d_env.start(self.d_env.nodes())
|
|
||||||
|
|
||||||
def execute_cmd(self, command, debug=True):
|
|
||||||
"""Execute command on node."""
|
|
||||||
return self.d_env.get_admin_remote().execute(
|
|
||||||
command, verbose=debug)['exit_code']
|
|
||||||
|
|
||||||
def await(self, timeout=1200):
|
|
||||||
wait(
|
|
||||||
lambda: tcp_ping(self.get_admin_node_ip(), 22), timeout=timeout)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
env = PuppetEnvironment(
|
|
||||||
'/var/lib/libvirt/images/ubuntu-12.04.1-server-amd64-p2.qcow2')
|
|
||||||
env.await()
|
|
||||||
env.make_snapshot(snapshot_name="test1")
|
|
||||||
env.execute_cmd('apt-get install mc')
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
__author__ = 'aurlapova'
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
# Copyright 2014 Mirantis, Inc.
|
|
||||||
#
|
|
||||||
# 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 logging
|
|
||||||
import os
|
|
||||||
|
|
||||||
import jinja2
|
|
||||||
|
|
||||||
from puppet_module import PuppetModule
|
|
||||||
|
|
||||||
|
|
||||||
class PuppetTestGenerator:
|
|
||||||
"""Puppet Test Generator
|
|
||||||
This is main class. It finds all modules in the given directory and creates
|
|
||||||
tests for them.
|
|
||||||
You should give constructor following arguments:
|
|
||||||
|
|
||||||
- local_modules_path* Path to puppet modules which will be scanned for
|
|
||||||
test files
|
|
||||||
- tests_directory_path* Output directory where files will be written
|
|
||||||
- debug level
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, tests_directory_path, modules_path):
|
|
||||||
"""Constructor
|
|
||||||
Constructor
|
|
||||||
"""
|
|
||||||
if not os.path.isdir(modules_path):
|
|
||||||
logging.error('No such directory: ' + modules_path)
|
|
||||||
|
|
||||||
if not os.path.isdir(tests_directory_path):
|
|
||||||
logging.error('No such directory: ' + tests_directory_path)
|
|
||||||
|
|
||||||
self.modules_path = modules_path
|
|
||||||
self.tests_directory = tests_directory_path
|
|
||||||
|
|
||||||
self.default_template = 'puppet_module_test.py.tmpl'
|
|
||||||
self.test_file_prefix = 'TestPuppetModule'
|
|
||||||
|
|
||||||
self.modules = []
|
|
||||||
self.module_templates = {}
|
|
||||||
self.make_tests_dir = os.path.dirname(os.path.abspath(__file__))
|
|
||||||
|
|
||||||
if not os.path.isdir('puppet_tests/templates'):
|
|
||||||
logging.error("No such directory: puppet_tests/templates")
|
|
||||||
self.template_directory = 'puppet_tests/templates'
|
|
||||||
self.template_loader = jinja2.FileSystemLoader(
|
|
||||||
searchpath='puppet_tests/templates')
|
|
||||||
self.template_environment = jinja2.Environment(
|
|
||||||
loader=self.template_loader,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.internal_modules_path = '/etc/puppet/modules'
|
|
||||||
self.internal_manifests_path = '/etc/puppet/manifests'
|
|
||||||
|
|
||||||
self.find_modules()
|
|
||||||
|
|
||||||
def find_modules(self):
|
|
||||||
"""Find modules in library path
|
|
||||||
Find all Puppet modules in module_library_path
|
|
||||||
and create array of PuppetModule objects
|
|
||||||
"""
|
|
||||||
logging.debug('Starting find modules in "%s"' % self.modules_path)
|
|
||||||
for module_dir in os.listdir(self.modules_path):
|
|
||||||
full_module_path = os.path.join(self.modules_path, module_dir)
|
|
||||||
full_tests_path = os.path.join(full_module_path, 'tests')
|
|
||||||
if not os.path.isdir(full_tests_path):
|
|
||||||
continue
|
|
||||||
logging.debug('Found Puppet module: "%s"' % full_module_path)
|
|
||||||
puppet_module = PuppetModule(full_module_path)
|
|
||||||
self.modules.append(puppet_module)
|
|
||||||
|
|
||||||
def compile_script(self, module):
|
|
||||||
"""Compile script template
|
|
||||||
Compile script template for given module and return it
|
|
||||||
"""
|
|
||||||
template_file = self.module_templates.get(module.name,
|
|
||||||
self.default_template)
|
|
||||||
template = self.template_environment.get_template(template_file)
|
|
||||||
general = {
|
|
||||||
'local_modules_path': self.modules_path,
|
|
||||||
'internal_modules_path': self.internal_modules_path,
|
|
||||||
'internal_manifests_path': self.internal_manifests_path,
|
|
||||||
'tests_directory_path': self.tests_directory
|
|
||||||
}
|
|
||||||
compiled_template = template.render(module=module, **general)
|
|
||||||
return compiled_template
|
|
||||||
|
|
||||||
def save_script(self, module):
|
|
||||||
"""Save compiled script
|
|
||||||
Saves compiled script to a file
|
|
||||||
"""
|
|
||||||
file_name = self.test_file_prefix + module.name.title() + '.py'
|
|
||||||
full_file_path = os.path.join(self.tests_directory, file_name)
|
|
||||||
script_content = self.compile_script(module)
|
|
||||||
script_file = open(full_file_path, 'w+')
|
|
||||||
script_file.write(script_content)
|
|
||||||
script_file.close()
|
|
||||||
|
|
||||||
def make_all_scripts(self):
|
|
||||||
"""Compile and save all scripts
|
|
||||||
Compile and save to tests_directory_path all the test scripts.
|
|
||||||
Main function.
|
|
||||||
"""
|
|
||||||
for module in self.modules:
|
|
||||||
logging.debug('Processing module: "%s"' % module.name)
|
|
||||||
self.save_script(module)
|
|
||||||
|
|
||||||
def remove_all_tests(self):
|
|
||||||
"""Remove all tests
|
|
||||||
Remove all tests from tests_directory_path
|
|
||||||
"""
|
|
||||||
file_list = os.listdir(self.tests_directory)
|
|
||||||
for test_file in file_list:
|
|
||||||
if not test_file.endswith('.py'):
|
|
||||||
continue
|
|
||||||
if not test_file.startswith('TestPuppetModule'):
|
|
||||||
continue
|
|
||||||
full_file_path = os.path.join(self.tests_directory, test_file)
|
|
||||||
logging.debug('Removing test file: "%s"' % full_file_path)
|
|
||||||
os.remove(full_file_path)
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
# Copyright 2014 Mirantis, Inc.
|
|
||||||
#
|
|
||||||
# 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 logging
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from puppet_test import PuppetTest
|
|
||||||
|
|
||||||
path = os.path.abspath(__file__)
|
|
||||||
path = os.path.dirname(path)
|
|
||||||
sys.path.insert(0, path)
|
|
||||||
|
|
||||||
|
|
||||||
class PuppetModule:
|
|
||||||
"""This class represents Puppet module."""
|
|
||||||
|
|
||||||
def __init__(self, local_module_path):
|
|
||||||
"""You should give this constructor the full path to the module."""
|
|
||||||
self.local_module_path = local_module_path
|
|
||||||
self.module_name = os.path.basename(self.local_module_path)
|
|
||||||
|
|
||||||
self.__tests = []
|
|
||||||
self.__dependencies = []
|
|
||||||
|
|
||||||
self.comment_regexp = re.compile(r'^\s*#')
|
|
||||||
self.dependency_regexp = \
|
|
||||||
re.compile(r'^\s*dependency\s*[\'\"]*([^\'\"]+)[\'\"]*')
|
|
||||||
|
|
||||||
self.find_tests()
|
|
||||||
self.find_dependencies()
|
|
||||||
|
|
||||||
def find_dependencies(self):
|
|
||||||
"""Get dependencies of this module from Modulefile if present."""
|
|
||||||
module_file = 'Modulefile'
|
|
||||||
dependencies = []
|
|
||||||
module_file_path = os.path.join(self.local_module_path, module_file)
|
|
||||||
if not os.path.isfile(module_file_path):
|
|
||||||
self.__dependencies = dependencies
|
|
||||||
return False
|
|
||||||
opened_file = open(module_file_path, 'r')
|
|
||||||
for line in opened_file.readlines():
|
|
||||||
if re.match(self.comment_regexp, line):
|
|
||||||
# skip commented line
|
|
||||||
continue
|
|
||||||
match = re.match(self.dependency_regexp, line)
|
|
||||||
if match:
|
|
||||||
# found dependency line
|
|
||||||
dependency_name = match.group(1).split('/')[-1]
|
|
||||||
dependencies.append(dependency_name)
|
|
||||||
self.__dependencies = dependencies
|
|
||||||
return True
|
|
||||||
|
|
||||||
def find_tests(self):
|
|
||||||
"""Find all tests.
|
|
||||||
Find all tests in this module and fill tests array
|
|
||||||
with PuppetTest objects.
|
|
||||||
"""
|
|
||||||
current_path = os.path.abspath(os.curdir)
|
|
||||||
try:
|
|
||||||
os.chdir(self.local_module_path)
|
|
||||||
except OSError as error:
|
|
||||||
logging.error("Cannot change directory to %s: %s" %
|
|
||||||
(self.local_module_path, error.message))
|
|
||||||
else:
|
|
||||||
for root, dirs, files in os.walk('tests'):
|
|
||||||
for test_file in files:
|
|
||||||
if not test_file[-3:] == '.pp':
|
|
||||||
continue
|
|
||||||
test_file_path = os.path.join(root, test_file)
|
|
||||||
puppet_test = PuppetTest(test_file_path)
|
|
||||||
self.__tests.append(puppet_test)
|
|
||||||
finally:
|
|
||||||
# try to restore original folder on exit
|
|
||||||
try:
|
|
||||||
os.chdir(current_path)
|
|
||||||
except OSError as error:
|
|
||||||
logging.error("Cannot change directory to %s: %s" %
|
|
||||||
(self.local_module_path, error.message), 1)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def tests(self):
|
|
||||||
"""Property returns list of tests."""
|
|
||||||
return self.__tests
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Property returns module name."""
|
|
||||||
return self.module_name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def path(self):
|
|
||||||
"""Property returns path to this module."""
|
|
||||||
return self.local_module_path
|
|
||||||
|
|
||||||
@property
|
|
||||||
def dependencies(self):
|
|
||||||
"""Property returns list of module dependencies."""
|
|
||||||
return self.__dependencies
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
"""String representation of PuppetModule."""
|
|
||||||
tests_string = ''
|
|
||||||
if len(self.tests) > 0:
|
|
||||||
tests = [repr(test) for test in self.tests]
|
|
||||||
tests_string += ", ".join(tests)
|
|
||||||
tpl = "PuppetModule(name=%s, path=%s, tests=[%s]" \
|
|
||||||
% (self.name, self.path, tests_string)
|
|
||||||
|
|
||||||
return tpl
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
# Copyright 2014 Mirantis, Inc.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
from glob import glob
|
|
||||||
import os
|
|
||||||
import stat
|
|
||||||
|
|
||||||
|
|
||||||
class PuppetTest:
|
|
||||||
"""This class represents single test of the Puppet module."""
|
|
||||||
|
|
||||||
def __init__(self, test_file_path):
|
|
||||||
"""You should give this constructor path to test file."""
|
|
||||||
self.test_file_path = test_file_path
|
|
||||||
self.tests_path = os.path.dirname(self.test_file_path)
|
|
||||||
self.test_file_name = os.path.basename(self.test_file_path)
|
|
||||||
self.test_name = self.test_file_name.replace('.pp', '')
|
|
||||||
self.find_verify_file()
|
|
||||||
|
|
||||||
def find_verify_file(self):
|
|
||||||
"""Get verify script for this test if there is one."""
|
|
||||||
pattern = os.path.join(self.tests_path, self.test_name) + '*'
|
|
||||||
verify_files = glob(pattern)
|
|
||||||
verify_files = [os.path.basename(verify_file)
|
|
||||||
for verify_file in verify_files
|
|
||||||
if not verify_file.endswith('.pp')]
|
|
||||||
if verify_files:
|
|
||||||
self.__verify_file = verify_files[0]
|
|
||||||
self.make_verify_executable()
|
|
||||||
else:
|
|
||||||
self.__verify_file = None
|
|
||||||
|
|
||||||
def make_verify_executable(self):
|
|
||||||
"""Set executable bit for a file."""
|
|
||||||
file_path = os.path.join(self.tests_path, self.__verify_file)
|
|
||||||
if not os.path.isfile(file_path):
|
|
||||||
return False
|
|
||||||
file_stat = os.stat(file_path)
|
|
||||||
os.chmod(
|
|
||||||
file_path,
|
|
||||||
file_stat.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
|
||||||
def path(self):
|
|
||||||
"""Return path to test.
|
|
||||||
Property returns path to this test relative to module and excluding
|
|
||||||
file name
|
|
||||||
"""
|
|
||||||
return self.tests_path
|
|
||||||
|
|
||||||
@property
|
|
||||||
def file(self):
|
|
||||||
"""Property returns this tests' file name."""
|
|
||||||
return self.test_file_name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Property returns name of this test."""
|
|
||||||
return self.test_name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def verify_file(self):
|
|
||||||
"""Property returns verify file name."""
|
|
||||||
return self.__verify_file
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
"""String representation of PuppetTest."""
|
|
||||||
return "PuppetTest(name=%s, path=%s, file=%s)" % \
|
|
||||||
(self.name, self.path, self.file)
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
# modules_path="{{ modules_path }}"
|
|
||||||
# local_modules_path="{{ local_modules_path }}"
|
|
||||||
# internal_modules_path="{{ internal_modules_path }}"
|
|
||||||
# internal_manifests_path="{{ internal_manifests_path }}"
|
|
||||||
# tests_directory_path="{{ tests_directory_path }}"
|
|
||||||
|
|
||||||
# Module
|
|
||||||
|
|
||||||
# module.name="{{ module.name }}"
|
|
||||||
# module.path="{{ module.path }}"
|
|
||||||
# module.tests="{{ module.tests }}"
|
|
||||||
# module.dependencies="{{ module.dependencies }}"
|
|
||||||
|
|
||||||
# Module "{{ module.name }}" has {{ module.tests|count }} tests:
|
|
||||||
{% set count = 0 -%}
|
|
||||||
{% for test in module.tests -%}
|
|
||||||
{% set count = count + 1 -%}
|
|
||||||
# Test {{ count }}:
|
|
||||||
# test.name="{{ test.name }}"
|
|
||||||
# test.path="{{ test.path }}"
|
|
||||||
# test.file="{{ test.file }}"
|
|
||||||
{% endfor -%}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
# Copyright 2014 Mirantis, Inc.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
from fuelweb_test.helpers.decorators import debug
|
|
||||||
from fuelweb_test.helpers.decorators import upload_manifests
|
|
||||||
from fuelweb_test.models.pp_environment import PuppetEnvironment
|
|
||||||
|
|
||||||
import logging
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
logger = logging.getLogger('integration')
|
|
||||||
logwrap = debug(logger)
|
|
||||||
|
|
||||||
|
|
||||||
class TestPuppetModule{{ module.name|title }}(unittest.TestCase): # flake8: noqa
|
|
||||||
@upload_manifests
|
|
||||||
def setUp(self):
|
|
||||||
self.env = PuppetEnvironment()
|
|
||||||
self.env.await()
|
|
||||||
self.puppet_apply = "puppet apply " \
|
|
||||||
"--verbose " \
|
|
||||||
"--detailed-exitcodes " \
|
|
||||||
"--modulepath='{{ internal_modules_path }}'"
|
|
||||||
|
|
||||||
if not self.env.d_env.has_snapshot("before_test"):
|
|
||||||
self.env.make_snapshot(snapshot_name="before_test")
|
|
||||||
{% for test in module.tests %} # flake8: noqa
|
|
||||||
def test_{{ test.name|title }}(self): # flake8: noqa
|
|
||||||
manifest = \
|
|
||||||
"{{ internal_modules_path }}/{{ module.name }}/{{ test.path }}/{{test.file }}" # flake8: noqa
|
|
||||||
result = self.env.execute_cmd("%s '%s'" % (self.puppet_apply,manifest)) # flake8: noqa
|
|
||||||
self.assertIn(result, [0, 2])
|
|
||||||
{% endfor %} # flake8: noqa
|
|
||||||
def tearDown(self): # flake8: noqa
|
|
||||||
self.env.revert_snapshot("before_test")
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
||||||
|
|
||||||
{# Enable this to get a debug list with all template values
|
|
||||||
{% include 'debug_template.txt' %}
|
|
||||||
#}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
# Class: acpid
|
|
||||||
#
|
|
||||||
# Sample for usage acpid
|
|
||||||
#
|
|
||||||
#
|
|
||||||
class acpid($status = true) {
|
|
||||||
|
|
||||||
if ($::osfamily == 'Debian') {
|
|
||||||
$package = 'acpid'
|
|
||||||
$service = 'acpid'
|
|
||||||
}
|
|
||||||
elsif ($::osfamily == 'RedHat') {
|
|
||||||
$package = 'acpid'
|
|
||||||
$service = 'acpid'
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fail("Module ${module_name} is not supported on ${::operatingsystem}!")
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($status) {
|
|
||||||
$ensure = 'running'
|
|
||||||
$enable = true
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$ensure = 'stopped'
|
|
||||||
$enable = false
|
|
||||||
}
|
|
||||||
|
|
||||||
package { $package :
|
|
||||||
ensure => installed,
|
|
||||||
}
|
|
||||||
|
|
||||||
service { $service :
|
|
||||||
ensure => $ensure,
|
|
||||||
enable => $enable,
|
|
||||||
hasrestart => true,
|
|
||||||
hasstatus => true,
|
|
||||||
}
|
|
||||||
|
|
||||||
Package[$package] -> Service[$service]
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# acpid_off
|
|
||||||
class { 'acpid' :
|
|
||||||
status => false,
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
|
|
||||||
|
|
||||||
ps axuwww | grep -v grep | grep -q " acpid "
|
|
||||||
if [ $? -gt 0 ]; then
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# acpid_on
|
|
||||||
class { 'acpid' :
|
|
||||||
status => true,
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
|
|
||||||
|
|
||||||
ps axuwww | grep -v grep | grep -q " acpid "
|
|
||||||
return $?
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
--colour
|
|
||||||
--format documentation
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
require 'rake'
|
|
||||||
|
|
||||||
require 'rspec/core/rake_task'
|
|
||||||
|
|
||||||
task :default => :spec
|
|
||||||
|
|
||||||
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
||||||
t.pattern = 'spec/*/*_spec.rb'
|
|
||||||
end
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# = Class: motd
|
|
||||||
#
|
|
||||||
# Create file /etc/motd.
|
|
||||||
#
|
|
||||||
class motd {
|
|
||||||
file { '/etc/motd' :
|
|
||||||
ensure => present,
|
|
||||||
owner => 'root',
|
|
||||||
group => 'root',
|
|
||||||
mode => '0644',
|
|
||||||
content => 'Hello!',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe 'motd' do
|
|
||||||
it do
|
|
||||||
should contain_file('/etc/motd').with({
|
|
||||||
'ensure' => 'present',
|
|
||||||
'owner' => 'root',
|
|
||||||
'group' => 'root',
|
|
||||||
'mode' => '0644',
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
it do
|
|
||||||
should contain_file('/etc/motd').with_content('Hello!')
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../../manifests
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
require 'rspec-puppet'
|
|
||||||
|
|
||||||
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
|
|
||||||
|
|
||||||
RSpec.configure do |c|
|
|
||||||
c.module_path = File.join(fixture_path, 'modules')
|
|
||||||
c.manifest_dir = File.join(fixture_path, 'manifests')
|
|
||||||
end
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# motd test
|
|
||||||
include motd
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
# For more information about this file, see the man pages
|
|
||||||
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
|
|
||||||
|
|
||||||
driftfile /var/lib/ntp/drift
|
|
||||||
|
|
||||||
# Permit time synchronization with our time source, but do not
|
|
||||||
# permit the source to query or modify the service on this system.
|
|
||||||
restrict default kod nomodify notrap nopeer noquery
|
|
||||||
restrict -6 default kod nomodify notrap nopeer noquery
|
|
||||||
|
|
||||||
# Permit all access over the loopback interface. This could
|
|
||||||
# be tightened as well, but to do so would effect some of
|
|
||||||
# the administrative functions.
|
|
||||||
restrict 127.0.0.1
|
|
||||||
restrict -6 ::1
|
|
||||||
|
|
||||||
# Hosts on local network are less restricted.
|
|
||||||
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
|
|
||||||
|
|
||||||
# Use public servers from the pool.ntp.org project.
|
|
||||||
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
|
|
||||||
server 0.centos.pool.ntp.org
|
|
||||||
server 1.centos.pool.ntp.org
|
|
||||||
server 2.centos.pool.ntp.org
|
|
||||||
|
|
||||||
#broadcast 192.168.1.255 autokey # broadcast server
|
|
||||||
#broadcastclient # broadcast client
|
|
||||||
#broadcast 224.0.1.1 autokey # multicast server
|
|
||||||
#multicastclient 224.0.1.1 # multicast client
|
|
||||||
#manycastserver 239.255.254.254 # manycast server
|
|
||||||
#manycastclient 239.255.254.254 autokey # manycast client
|
|
||||||
|
|
||||||
# Undisciplined Local Clock. This is a fake driver intended for backup
|
|
||||||
# and when no outside source of synchronized time is available.
|
|
||||||
#server 127.127.1.0 # local clock
|
|
||||||
#fudge 127.127.1.0 stratum 10
|
|
||||||
|
|
||||||
# Enable public key cryptography.
|
|
||||||
#crypto
|
|
||||||
|
|
||||||
includefile /etc/ntp/crypto/pw
|
|
||||||
|
|
||||||
# Key file containing the keys and key identifiers used when operating
|
|
||||||
# with symmetric key cryptography.
|
|
||||||
keys /etc/ntp/keys
|
|
||||||
|
|
||||||
# Specify the key identifiers which are trusted.
|
|
||||||
#trustedkey 4 8 42
|
|
||||||
|
|
||||||
# Specify the key identifier to use with the ntpdc utility.
|
|
||||||
#requestkey 8
|
|
||||||
|
|
||||||
# Specify the key identifier to use with the ntpq utility.
|
|
||||||
#controlkey 8
|
|
||||||
|
|
||||||
# Enable writing of statistics records.
|
|
||||||
#statistics clockstats cryptostats loopstats peerstats
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
|
|
||||||
|
|
||||||
driftfile /var/lib/ntp/ntp.drift
|
|
||||||
|
|
||||||
|
|
||||||
# Enable this if you want statistics to be logged.
|
|
||||||
#statsdir /var/log/ntpstats/
|
|
||||||
|
|
||||||
statistics loopstats peerstats clockstats
|
|
||||||
filegen loopstats file loopstats type day enable
|
|
||||||
filegen peerstats file peerstats type day enable
|
|
||||||
filegen clockstats file clockstats type day enable
|
|
||||||
|
|
||||||
# Specify one or more NTP servers.
|
|
||||||
|
|
||||||
# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
|
|
||||||
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
|
|
||||||
# more information.
|
|
||||||
server 0.ubuntu.pool.ntp.org
|
|
||||||
server 1.ubuntu.pool.ntp.org
|
|
||||||
server 2.ubuntu.pool.ntp.org
|
|
||||||
server 3.ubuntu.pool.ntp.org
|
|
||||||
|
|
||||||
# Use Ubuntu's ntp server as a fallback.
|
|
||||||
server ntp.ubuntu.com
|
|
||||||
|
|
||||||
# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
|
|
||||||
# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
|
|
||||||
# might also be helpful.
|
|
||||||
#
|
|
||||||
# Note that "restrict" applies to both servers and clients, so a configuration
|
|
||||||
# that might be intended to block requests from certain clients could also end
|
|
||||||
# up blocking replies from your own upstream servers.
|
|
||||||
|
|
||||||
# By default, exchange time with everybody, but don't allow configuration.
|
|
||||||
restrict -4 default kod notrap nomodify nopeer noquery
|
|
||||||
restrict -6 default kod notrap nomodify nopeer noquery
|
|
||||||
|
|
||||||
# Local users may interrogate the ntp server more closely.
|
|
||||||
restrict 127.0.0.1
|
|
||||||
restrict ::1
|
|
||||||
|
|
||||||
# Clients from this (example!) subnet have unlimited access, but only if
|
|
||||||
# cryptographically authenticated.
|
|
||||||
#restrict 192.168.123.0 mask 255.255.255.0 notrust
|
|
||||||
|
|
||||||
|
|
||||||
# If you want to provide time to your local subnet, change the next line.
|
|
||||||
# (Again, the address is an example only.)
|
|
||||||
#broadcast 192.168.123.255
|
|
||||||
|
|
||||||
# If you want to listen to time broadcasts on your local subnet, de-comment the
|
|
||||||
# next lines. Please do this only if you trust everybody on the network!
|
|
||||||
#disable auth
|
|
||||||
#broadcastclient
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
# = Class: ntp
|
|
||||||
#
|
|
||||||
# Sample of usage ntp,
|
|
||||||
# create config and start service ntp.
|
|
||||||
#
|
|
||||||
class ntp {
|
|
||||||
if $::osfamily == 'RedHat' {
|
|
||||||
$package = 'ntp'
|
|
||||||
$service = 'ntpd'
|
|
||||||
$config = '/etc/ntp.conf'
|
|
||||||
$conf_from = 'centos-ntp.conf'
|
|
||||||
} elsif $::osfamily == 'Debian' {
|
|
||||||
$package = 'ntp'
|
|
||||||
$service = 'ntp'
|
|
||||||
$config = '/etc/ntp.conf'
|
|
||||||
$conf_from = 'ubuntu-ntp.conf'
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fail("Module ${module_name} is not supported on ${::operatingsystem}!")
|
|
||||||
}
|
|
||||||
|
|
||||||
package { $package :
|
|
||||||
ensure => installed,
|
|
||||||
}
|
|
||||||
|
|
||||||
file { $config :
|
|
||||||
ensure => present,
|
|
||||||
owner => 'root',
|
|
||||||
group => 'root',
|
|
||||||
mode => '0644',
|
|
||||||
source => "puppet:///modules/ntp/${conf_from}",
|
|
||||||
}
|
|
||||||
|
|
||||||
service { $service :
|
|
||||||
ensure => 'running',
|
|
||||||
enable => true,
|
|
||||||
hasrestart => true,
|
|
||||||
hasstatus => true,
|
|
||||||
}
|
|
||||||
|
|
||||||
Package[$package] -> File[$config] ~> Service[$service]
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# ntp class test
|
|
||||||
include ntp
|
|
||||||
1
fuelweb_test/puppet_tests/tests/.gitignore
vendored
1
fuelweb_test/puppet_tests/tests/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
*.py
|
|
||||||
Reference in New Issue
Block a user