Move elements at the top level

This commit is contained in:
Thomas Herve 2017-01-03 14:02:25 +01:00
parent 3a1e20c676
commit d802d177c7
86 changed files with 88 additions and 162 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
*.pyc
*.swp
*~
.tox
.testrepository

4
.gitreview Normal file
View File

@ -0,0 +1,4 @@
[gerrit]
host=review.openstack.org
port=29418
project=openstack/heat-agents.git

4
.testr.conf Normal file
View File

@ -0,0 +1,4 @@
[DEFAULT]
test_command=${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list

View File

@ -27,7 +27,7 @@ with the following:
git clone https://git.openstack.org/openstack/heat-templates.git
git clone https://git.openstack.org/openstack/dib-utils.git
export PATH="${PWD}/dib-utils/bin:$PATH"
export ELEMENTS_PATH=tripleo-image-elements/elements:heat-templates/hot/software-config/elements
export ELEMENTS_PATH=tripleo-image-elements/elements:heat-agents/
diskimage-builder/bin/disk-image-create vm \
fedora selinux-permissive \
os-collect-config \

19
test-requirements.txt Normal file
View File

@ -0,0 +1,19 @@
coverage>=3.6
discover
dpath>=1.3.2
fixtures>=0.3.14
# Hacking already pins down pep8, pyflakes and flake8
hacking>=0.10.0,<0.11
mock>=1.0
requests>=1.2.1,!=2.4.0
requests-mock>=0.4.0 # Apache-2.0
salt
testrepository>=0.0.18
testscenarios>=0.4
testtools>=0.9.34
yamllint>=1.2.0
os-apply-config
python-heatclient>=1.2.0
python-keystoneclient>=0.10.0
python-openstackclient>=2.1.0

1
tests/heat_config_notify.py Symbolic link
View File

@ -0,0 +1 @@
../heat-config/bin/heat-config-notify

1
tests/hook_kubelet.py Symbolic link
View File

@ -0,0 +1 @@
../heat-config-kubelet/install.d/hook-kubelet.py

View File

@ -1 +0,0 @@
../../hot/software-config/elements/heat-config/bin/heat-config-notify

View File

@ -1 +0,0 @@
../../hot/software-config/elements/heat-config-kubelet/install.d/hook-kubelet.py

View File

@ -1,115 +0,0 @@
#
# 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 json
import os
import fixtures
from tests.software_config import common
class HookAtomicTest(common.RunScriptTest):
data = {
"id": "abcdef001",
"group": "atomic",
"inputs": [],
"config": {
"command": "install",
"image": "imain/atomic-install-rabbitmq"
}
}
def setUp(self):
super(HookAtomicTest, self).setUp()
self.hook_path = self.relative_path(
__file__,
'../..',
'hot/software-config/heat-container-agent',
'scripts/hooks/atomic')
self.fake_tool_path = self.relative_path(
__file__,
'config-tool-fake.py')
self.working_dir = self.useFixture(fixtures.TempDir())
self.outputs_dir = self.useFixture(fixtures.TempDir())
self.test_state_path = self.outputs_dir.join('test_state.json')
self.env = os.environ.copy()
self.env.update({
'HEAT_ATOMIC_WORKING': self.working_dir.join(),
'HEAT_ATOMIC_CMD': self.fake_tool_path,
'TEST_STATE_PATH': self.test_state_path,
})
def test_hook(self):
self.env.update({
'TEST_RESPONSE': json.dumps({
'stdout': 'Downloading xxx',
'stderr': ''
})
})
returncode, stdout, stderr = self.run_cmd(
[self.hook_path], self.env, json.dumps(self.data))
self.assertEqual(0, returncode, stderr)
self.assertEqual({
'deploy_stdout': 'Downloading xxx',
'deploy_stderr': '',
'deploy_status_code': 0
}, json.loads(stdout))
state = self.json_from_file(self.test_state_path)
self.assertEqual(
[
self.fake_tool_path,
'install',
'imain/atomic-install-rabbitmq',
'-n abcdef001',
''
],
state['args'])
def test_hook_failed(self):
self.env.update({
'TEST_RESPONSE': json.dumps({
'stdout': '',
'stderr': 'Container exists...',
'returncode': 1
})
})
returncode, stdout, stderr = self.run_cmd(
[self.hook_path], self.env, json.dumps(self.data))
self.assertEqual(0, returncode, stderr)
self.assertEqual({
'deploy_stdout': '',
'deploy_stderr': 'Container exists...',
'deploy_status_code': 1
}, json.loads(stdout))
state = self.json_from_file(self.test_state_path)
self.assertEqual(
[
self.fake_tool_path,
'install',
'imain/atomic-install-rabbitmq',
'-n abcdef001',
''
],
state['args'])

View File

@ -20,7 +20,7 @@ import tempfile
import fixtures
from testtools import matchers
from tests.software_config import common
from tests import common
class HeatConfigTest(common.RunScriptTest):
@ -128,8 +128,7 @@ class HeatConfigTest(common.RunScriptTest):
self.heat_config_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config/os-refresh-config/configure.d/55-heat-config')
self.hooks_dir = self.useFixture(fixtures.TempDir())

View File

@ -18,7 +18,7 @@ import tempfile
import fixtures
import yaml
from tests.software_config import common
from tests import common
class HeatConfigDockerComposeORCTest(common.RunScriptTest):
@ -72,8 +72,7 @@ class HeatConfigDockerComposeORCTest(common.RunScriptTest):
self.fake_hook_path = self.relative_path(__file__, 'hook-fake.py')
self.heat_config_docker_compose_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config-docker-compose/os-refresh-config/configure.d/'
'50-heat-config-docker-compose')

View File

@ -18,7 +18,7 @@ import tempfile
import fixtures
from testtools import matchers
from tests.software_config import common
from tests import common
class HeatConfigKubeletORCTest(common.RunScriptTest):
@ -99,8 +99,7 @@ class HeatConfigKubeletORCTest(common.RunScriptTest):
self.heat_config_kubelet_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config-kubelet/os-refresh-config/configure.d/'
'50-heat-config-kubelet')

View File

@ -18,8 +18,8 @@ import tempfile
import fixtures
import mock
from tests.software_config import common
from tests.software_config import heat_config_notify as hcn
from tests import common
from tests import heat_config_notify as hcn
class HeatConfigNotifyTest(common.RunScriptTest):

View File

@ -18,7 +18,7 @@ import os
import fixtures
from tests.software_config import common
from tests import common
class HookAnsibleTest(common.RunScriptTest):
@ -62,8 +62,7 @@ class HookAnsibleTest(common.RunScriptTest):
super(HookAnsibleTest, self).setUp()
self.hook_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config-ansible/install.d/hook-ansible.py')
self.fake_tool_path = self.relative_path(

View File

@ -18,7 +18,7 @@ import os
import tempfile
import yaml
from tests.software_config import common
from tests import common
log = logging.getLogger('test_hook_apply_config')
@ -36,8 +36,7 @@ class HookApplyConfigTest(common.RunScriptTest):
super(HookApplyConfigTest, self).setUp()
self.hook_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config-apply-config/install.d/hook-apply-config.py')
self.metadata_dir = self.useFixture(fixtures.TempDir())

View File

@ -16,7 +16,7 @@ import os
import fixtures
from tests.software_config import common
from tests import common
class HookCfnInitTest(common.RunScriptTest):
@ -31,8 +31,7 @@ class HookCfnInitTest(common.RunScriptTest):
super(HookCfnInitTest, self).setUp()
self.hook_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config-cfn-init/install.d/hook-cfn-init.py')
self.fake_tool_path = self.relative_path(

View File

@ -19,7 +19,7 @@ import mock
import StringIO
import sys
from tests.software_config import common
from tests import common
log = logging.getLogger('test_hook_chef')
@ -56,8 +56,7 @@ class HookChefTest(common.RunScriptTest):
super(HookChefTest, self).setUp()
self.hook_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config-chef/install.d/hook-chef.py')
sys.stdin = StringIO.StringIO()
sys.stdout = StringIO.StringIO()

View File

@ -19,7 +19,7 @@ import tempfile
import fixtures
from testtools import matchers
from tests.software_config import common
from tests import common
class HookDockerCmdTest(common.RunScriptTest):
@ -55,14 +55,13 @@ class HookDockerCmdTest(common.RunScriptTest):
super(HookDockerCmdTest, self).setUp()
self.hook_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config-docker-cmd/install.d/hook-docker-cmd.py')
self.cleanup_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements/heat-config-docker-cmd/',
'..',
'heat-config-docker-cmd/',
'os-refresh-config/configure.d/50-heat-config-docker-cmd')
self.fake_tool_path = self.relative_path(

View File

@ -16,7 +16,7 @@ import os
import fixtures
from tests.software_config import common
from tests import common
class HookDockerComposeTest(common.RunScriptTest):
@ -72,8 +72,7 @@ class HookDockerComposeTest(common.RunScriptTest):
super(HookDockerComposeTest, self).setUp()
self.hook_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config-docker-compose/install.d/hook-docker-compose.py')
self.fake_tool_path = self.relative_path(

View File

@ -18,7 +18,7 @@ import os
import tempfile
import yaml
from tests.software_config import common
from tests import common
log = logging.getLogger('test_hook_hiera_config')
@ -51,8 +51,7 @@ class HookHieraTest(common.RunScriptTest):
super(HookHieraTest, self).setUp()
self.hook_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config-hiera/install.d/hook-hiera.py')
self.hieradata_dir = self.useFixture(fixtures.TempDir()).join()

View File

@ -16,7 +16,7 @@ import mock
import re
import testtools
from tests.software_config import hook_kubelet
from tests import hook_kubelet
class HookKubeletTest(testtools.TestCase):

View File

@ -17,7 +17,7 @@ import os
import fixtures
from tests.software_config import common
from tests import common
class HookPuppetTest(common.RunScriptTest):
@ -48,8 +48,7 @@ class HookPuppetTest(common.RunScriptTest):
super(HookPuppetTest, self).setUp()
self.hook_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config-puppet/install.d/hook-puppet.py')
self.fake_tool_path = self.relative_path(

View File

@ -17,7 +17,7 @@ import logging
import os
import yaml
from tests.software_config import common
from tests import common
log = logging.getLogger('test_hook_salt')
@ -64,8 +64,7 @@ class HookSaltTest(common.RunScriptTest):
super(HookSaltTest, self).setUp()
self.hook_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config-salt/install.d/hook-salt.py')
self.working_dir = self.useFixture(fixtures.TempDir())

View File

@ -16,7 +16,7 @@ import os
import fixtures
from tests.software_config import common
from tests import common
class HookScriptTest(common.RunScriptTest):
@ -25,8 +25,7 @@ class HookScriptTest(common.RunScriptTest):
super(HookScriptTest, self).setUp()
self.hook_path = self.relative_path(
__file__,
'../..',
'hot/software-config/elements',
'..',
'heat-config-script/install.d/hook-script.py')
self.fake_tool_path = self.relative_path(

22
tox.ini Normal file
View File

@ -0,0 +1,22 @@
[tox]
envlist = py27,pep8
minversion = 1.6
skipsdist = True
[testenv]
setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = bash -c 'if [ ! -d ./.testrepository ] ; then testr init ; fi'
testr run {posargs}
[testenv:pep8]
commands = flake8
[testenv:venv]
commands = {posargs}
[flake8]
show-source = True
builtins = _
exclude=.venv,.git,.tox,*lib/python*,private,.eggs