Add intial files

Change-Id: I4f80853cacd16b8500376cd429e866a389ce8408
This commit is contained in:
Federico Ressi 2020-09-29 05:42:47 +02:00
parent 96659a89be
commit 1af98dca8e
14 changed files with 724 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# Tox files
.tox

30
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,30 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-added-large-files
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: forbid-new-submodules
- id: requirements-txt-fixer
args: [linters-requirements.txt]
- id: trailing-whitespace
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.25.0
hooks:
- id: yamllint
files: \.(yaml|yml)$
- repo: https://opendev.org/openstack/bashate.git
rev: 2.0.0
hooks:
- id: bashate

29
README.rst Normal file
View File

@ -0,0 +1,29 @@
======================
Tobiko Devstack Plugin
======================
DevStack plugin to configure Tobiko framework on a DevStack provisioned host
----------------------------------------------------------------------------
The only goal of this plugin is generating a valid /etc/tobiko/tobiko.conf file
to be consumed by Tobiko Python framework on a machine that is running DevStack.
This translates DevStack configurations from `local.conf` file to tobiko's
configuration file. It is intended to facilitate running Tobiko test cases from
an host that has been provisioned using DevStack project.
References
----------
* Free software: Apache License, Version 2.0
* Source code: https://opendev.org/x/tobiko-devstack
* Bugs: https://storyboard.openstack.org/#!/project/x/tobiko
Related projects
~~~~~~~~~~~~~~~~
* Tobiko: https://tobiko.readthedocs.io/en/latest/
* OpenStack: https://www.openstack.org/
* DevStack: https://docs.openstack.org/devstack/latest/

26
devstack/README.rst Normal file
View File

@ -0,0 +1,26 @@
====================
Enabling in Devstack
====================
**WARNING**: the stack.sh script must be run in a disposable VM that is not
being created automatically, see the README.md file in the "devstack"
repository. See contrib/vagrant to create a vagrant VM.
1. Download DevStack::
git clone https://opendev.org/openstack/devstack.git
cd devstack
2. Add this repo as an external repository::
> cat local.conf
[[local|localrc]]
enable_plugin tobiko https://opendev.org/x/tobiko
3. Tobiko require Heat to be enabled, so heat should be also enabled::
[[local|localrc]]
enable_plugin heat https://opendev.org/openstack/heat
3. Run ``stack.sh``

192
devstack/plugin.sh Normal file
View File

@ -0,0 +1,192 @@
# Directory where this plugin.sh file is
TOBIKO_PLUGIN_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
function install_tobiko_deps {
if [ "${TOBIKO_BINDEP}" != "" ]; then
install_python3
install_bindep "${TOBIKO_DIR}/bindep.txt" test
fi
}
function configure_tobiko {
# Ensure any user can write to log file
local log_dir
log_dir=$(dirname ${TOBIKO_LOG_FILE})
if ! [ -d "${log_dir}" ]; then
sudo mkdir -p "${log_dir}"
fi
if ! [ -w "${TOBIKO_LOG_FILE}" ]; then
sudo touch "${TOBIKO_LOG_FILE}"
sudo chmod ugo+rw "${TOBIKO_LOG_FILE}"
fi
# Write configuration to a new temporary file
local tobiko_conf_file
tobiko_conf_file=$(mktemp)
if [ -f "${TOBIKO_CONF_FILE}" ]; then
# Start from existing tobiko.conf file
cp "${TOBIKO_CONF_FILE}" "${tobiko_conf_file}"
fi
configure_tobiko_default "${tobiko_conf_file}"
configure_tobiko_cirros "${tobiko_conf_file}"
configure_tobiko_glance "${tobiko_conf_file}"
configure_tobiko_keystone "${tobiko_conf_file}"
configure_tobiko_nova "${tobiko_conf_file}"
configure_tobiko_neutron "${tobiko_conf_file}"
echo_summary "Apply changes to actual ${TOBIKO_CONF_FILE} file."
sudo mkdir -p $(dirname "${TOBIKO_CONF_FILE}")
sudo mv "${tobiko_conf_file}" "${TOBIKO_CONF_FILE}"
sudo chmod ugo+r "${TOBIKO_CONF_FILE}"
echo "${TOBIKO_CONF_FILE} file content:"
echo --------------------------------
cat "${TOBIKO_CONF_FILE}"
echo --------------------------------
}
function configure_tobiko_cirros {
echo_summary "Write [cirros] section to ${TOBIKO_CONF_FILE}"
local tobiko_conf_file=$1
iniset_nonempty "${tobiko_conf_file}" cirros name \
"${TOBIKO_CIRROS_IMAGE_NAME}"
iniset_nonempty "${tobiko_conf_file}" cirros url \
"${TOBIKO_CIRROS_IMAGE_URL}"
iniset_nonempty "${tobiko_conf_file}" cirros file \
"${TOBIKO_CIRROS_IMAGE_FILE}"
iniset_nonempty "${tobiko_conf_file}" cirros username \
"${TOBIKO_CIRROS_USERNAME}"
iniset_nonempty "${tobiko_conf_file}" cirros password \
"${TOBIKO_CIRROS_PASSWORD}"
}
function configure_tobiko_default {
echo_summary "Write [DEFAULT] section to ${TOBIKO_CONF_FILE}"
local tobiko_conf_file=$1
setup_logging "${tobiko_conf_file}"
iniset ${tobiko_conf_file} DEFAULT debug "${TOBIKO_DEBUG}"
iniset ${tobiko_conf_file} DEFAULT log_dir $(dirname "${TOBIKO_LOG_FILE}")
iniset ${tobiko_conf_file} DEFAULT log_file \
$(basename "${TOBIKO_LOG_FILE}")
}
function configure_tobiko_glance {
echo_summary "Write [glance] section to ${TOBIKO_CONF_FILE}"
local tobiko_conf_file=$1
iniset_nonempty "${tobiko_conf_file}" glance image_dir \
"${TOBIKO_GLANCE_IMAGE_DIR}"
}
function configure_tobiko_keystone {
echo_summary "Write [keystone] section to ${TOBIKO_CONF_FILE}"
local tobiko_conf_file=$1
local api_version=${IDENTITY_API_VERSION}
if [ "${api_version}" == '2' ]; then
local auth_url=${KEYSTONE_AUTH_URI/v2.0}
else
local auth_url=${KEYSTONE_AUTH_URI_V3:-${KEYSTONE_AUTH_URI/v3}}
fi
local project_id
project_id=$(get_or_create_project \
"${TOBIKO_KEYSTONE_PROJECT_NAME}" \
"${TOBIKO_KEYSTONE_PROJECT_DOMAIN_NAME}")
local user_id
user_id=$(get_or_create_user \
"${TOBIKO_KEYSTONE_USERNAME}" \
"${TOBIKO_KEYSTONE_PASSWORD}" \
"${TOBIKO_KEYSTONE_USER_DOMAIN_NAME}")
local user_project_role_id
user_project_role_id=$(get_or_add_user_project_role \
"${TOBIKO_KEYSTONE_USER_ROLE}" \
"${user_id}" \
"${project_id}")
local user_domain_role_id
user_domain_role_id=$(get_or_add_user_domain_role \
"${TOBIKO_KEYSTONE_USER_ROLE}" \
"${user_id}" \
"${TOBIKO_KEYSTONE_USER_DOMAIN_NAME}")
iniset "${tobiko_conf_file}" keystone cloud_name \
"${TOBIKO_KEYSTONE_CLOUD_NAME}"
iniset "${tobiko_conf_file}" keystone api_version "${api_version}"
iniset "${tobiko_conf_file}" keystone auth_url "${auth_url}"
iniset "${tobiko_conf_file}" keystone username \
"${TOBIKO_KEYSTONE_USERNAME}"
iniset "${tobiko_conf_file}" keystone password \
"${TOBIKO_KEYSTONE_PASSWORD}"
iniset "${tobiko_conf_file}" keystone project_name \
"${TOBIKO_KEYSTONE_PROJECT_NAME}"
if [ "${api_version}" != '2' ]; then
iniset "${tobiko_conf_file}" keystone domain_name \
"${TOBIKO_KEYSTONE_DOMAIN_NAME}"
iniset "${tobiko_conf_file}" keystone user_domain_name \
"${TOBIKO_KEYSTONE_USER_DOMAIN_NAME}"
iniset "${tobiko_conf_file}" keystone project_domain_name \
"${TOBIKO_KEYSTONE_PROJECT_DOMAIN_NAME}"
iniset "${tobiko_conf_file}" keystone trust_id \
"${TOBIKO_KEYSTONE_TRUST_ID}"
fi
}
function configure_tobiko_nova {
echo_summary "Write [nova] section to ${TOBIKO_CONF_FILE}"
local tobiko_conf_file=$1
# Write key_file
local key_file=${TOBIKO_NOVA_KEY_FILE:-}
if [ "${key_file}" != "" ]; then
iniset "${tobiko_conf_file}" nova key_file "${key_file}"
fi
}
function configure_tobiko_neutron {
echo_summary "Write [neutron] section to ${TOBIKO_CONF_FILE}"
local tobiko_conf_file=$1
# Write floating network
local floating_network=${TOBIKO_NEUTRON_FLOATING_NETWORK}
if [ "${floating_network}" != "" ]; then
iniset "${tobiko_conf_file}" neutron floating_network \
"${floating_network}"
fi
}
function iniset_nonempty {
# Calls iniset only when option value is not an empty string
if [ -n "$4" ]; then
iniset "$@"
fi
}
if [[ "$1" == "stack" ]]; then
case "$2" in
install)
echo_summary "Installing Tobiko dependencies"
install_tobiko_deps
;;
test-config)
echo_summary "Configuring Tobiko test cases"
configure_tobiko
;;
esac
fi

43
devstack/settings Normal file
View File

@ -0,0 +1,43 @@
define_plugin tobiko
plugin_requires tobiko heat
# --- General settings ----
TOBIKO_REPO=${TOBIKO_REPO:-${GIT_BASE}/x/tobiko.git}
GITREPO["tobiko"]=${TOBIKO_REPO}
TOBIKO_VERSION=${TOBIKO_BRANCH:-master}
GITBRANCH["tobiko"]=${TOBIKO_VERSION}
TOBIKO_DIR=${TOBIKO_DIR:-${DEST}/tobiko}
GITDIR["tobiko"]=${TOBIKO_DIR}
TOBIKO_CONF_FILE=${TOBIKO_CONF_FILE:-/etc/tobiko/tobiko.conf}
TOBIKO_DEBUG=${TOBIKO_DEBUG:-True}
TOBIKO_LOG_FILE=${TOBIKO_LOG_FILE:-${LOGDIR}/tobiko.log}
TOBIKO_BINDEP=${BINDEP_CMD:+-bindep}
# --- Glance settings ---
TOBIKO_GLANCE_IMAGE_DIR=${TOBIKO_GLANCE_IMAGE_DIR:-}
# --- Cirros image settings ---
TOBIKO_CIRROS_IMAGE_NAME=${TOBIKO_CIRROS_IMAGE_NAME:-}
TOBIKO_CIRROS_IMAGE_URL=${TOBIKO_CIRROS_IMAGE_URL:-}
TOBIKO_CIRROS_IMAGE_FILE=${TOBIKO_CIRROS_IMAGE_FILE:-}
TOBIKO_CIRROS_USERNAME=${TOBIKO_CIRROS_USERNAME:-}
TOBIKO_CIRROS_PASSWORD=${TOBIKO_CIRROS_PASSWORD:-}
# --- Keystone settings ---
# See ``lib/keystone`` where these users and tenants are set up
TOBIKO_KEYSTONE_CLOUD_NAME=${TOBIKO_KEYSTONE_CLOUD_NAME:-devstack-admin}
TOBIKO_KEYSTONE_USERNAME=${TOBIKO_KEYSTONE_USERNAME:-${ADMIN_USERNAME:-admin}}
TOBIKO_KEYSTONE_PASSWORD=${TOBIKO_KEYSTONE_PASSWORD:-${ADMIN_PASSWORD:-secret}}
TOBIKO_KEYSTONE_PROJECT_NAME=${TOBIKO_KEYSTONE_PROJECT_NAME:-${ADMIN_TENANT_NAME:-admin}}
TOBIKO_KEYSTONE_USER_DOMAIN_NAME=${TOBIKO_KEYSTONE_USER_DOMAIN_NAME:-${ADMIN_DOMAIN_NAME:-Default}}
TOBIKO_KEYSTONE_PROJECT_DOMAIN_NAME=${TOBIKO_KEYSTONE_PROJECT_DOMAIN_NAME:-${ADMIN_DOMAIN_NAME:-Default}}
TOBIKO_KEYSTONE_TRUST_ID=${TOBIKO_KEYSTONE_TRUST_ID:-}
TOBIKO_KEYSTONE_USER_ROLE=${TOBIKO_KEYSTONE_USER_ROLE:-admin}
# --- Nova settings ---
TOBIKO_NOVA_KEY_FILE=${TOBIKO_NOVA_KEY_FILE:-}
# --- Neutron settings ---
TOBIKO_NEUTRON_FLOATING_NETWORK=${TOBIKO_NEUTRON_FLOATING_NETWORK:-${PUBLIC_NETWORK_NAME}}

1
linters-requirements.txt Normal file
View File

@ -0,0 +1 @@
pre-commit

View File

@ -0,0 +1,6 @@
---
- hosts: tempest
roles:
- tobiko-zuul
- tobiko-collect

View File

@ -0,0 +1,12 @@
---
- hosts: tempest
roles:
- tobiko-zuul
- tobiko-configure
- hosts: all
roles:
- role: multi-node-setup
- role: orchestrate-devstack

View File

@ -0,0 +1,20 @@
# Copyright 2018 Red Hat
#
# 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.
---
- hosts: tempest
roles:
- tobiko-zuul
- tobiko-run

19
tox.ini Normal file
View File

@ -0,0 +1,19 @@
[tox]
skipsdist = True
envlist = linters
minversion = 3.8.0
[testenv]
usedevelop=False
[testenv:linters]
deps =
-r {toxinidir}/linters-requirements.txt
commands =
pre-commit --version
pre-commit autoupdate
pre-commit run --all-files
pre-commit install

250
zuul.d/jobs.yaml Normal file
View File

@ -0,0 +1,250 @@
---
- job:
name: devstack-tobiko-base
parent: devstack
abstract: true
description: |
Base Devstack Tobiko Plugin job.
This job provides the base for both the single and multi-node
test setup. To run a multi-node test inherit from devstack-tobiko
job and set the nodeset to a multi-node one.
required-projects:
- openstack/devstack-gate
- openstack/heat
- openstack/neutron
- openstack/requirements
- openstack/validations-libs
- x/tobiko
- x/devstack-plugin-tobiko
timeout: 7200
vars:
devstack_localrc:
MULTI_HOST: 0
LOG_COLOR: false
NETWORK_API_EXTENSIONS: >-
address-scope,agent,allowed-address-pairs,auto-allocated-topology,
availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,
dns-domain-ports,dns-integration,dvr,empty-string-filtering,
ext-gw-mode,external-net,extra_dhcp_opt,extraroute,filter-validation,
fip-port-details,flavors,ip-substring-filtering,l3-flavors,l3-ha,
l3_agent_scheduler,logging,metering,multi-provider,net-mtu,
net-mtu-writable,network-ip-availability,network_availability_zone,
pagination,port-security,project-id,provider,qos,
qos-bw-minimum-ingress,qos-fip,quotas,quota_details,rbac-policies,
router,router_availability_zone,security-group,
port-mac-address-regenerate,port-security-groups-filtering,
segment,service-type,sorting,standard-attr-description,
standard-attr-revisions,standard-attr-segment,
standard-attr-timestamp,standard-attr-tag,subnet_allocation,
trunk,trunk-details,uplink-status-propagation
devstack_plugins:
heat: https://opendev.org/openstack/heat.git
neutron: https://opendev.org/openstack/neutron.git
tobiko: https://opendev.org/x/devstack-plugin-tobiko.git
devstack_services:
heat: true
h-api: true
h-api-cfn: true
h-eng: true
n-cpu: true
# NOTE(slaweq): we need to enable it as "legacy" service because for
# Fedora job it has to be disabled. If it would be disabled as
# "neutron-dns: false" then it devstack would consider that
# neutron-legacy isn't used and would not load proper files
q-dns: true
# see bug #1860753 (https://bugs.launchpad.net/devstack/+bug/1860753)
memory_tracker: false
neutron-qos: true
neutron-segments: true
neutron-trunk: true
neutron-uplink-status-propagation: true
tempest: false
tls-proxy: false
# NOTE(slaweq): Swift can't run with python3 currently
s-account: false
s-container: false
s-object: false
s-proxy: false
# NOTE(slaweq): without Swift, c-bak cannot run (in the Gate at least)
c-bak: false
devstack_local_conf:
post-config:
$NEUTRON_CONF:
QUOTAS:
quota_router: 100
quota_floatingip: 500
quota_security_group: 100
quota_security_group_rule: 1000
$NOVA_CONF:
quota:
instances: 20
zuul_copy_output:
'{{ stage_dir }}/stackviz': logs
extensions_to_txt:
conf: true
log: true
yaml: true
yml: true
test_log_debug: true
test_case_timeout: 1800
tobiko_dir: '/opt/stack/tobiko'
upper_constraints_file: >-
{{ ansible_user_dir }}/src/opendev.org/openstack/requirements/
upper-constraints.txt'
pre-run: playbooks/devstack/pre.yaml
run: playbooks/devstack/run.yaml
post-run: playbooks/devstack/post.yaml
irrelevant-files:
- ^.*\.rst$
- ^doc/
- ^infrared_plugin/
- ^releasenotes/
- ^report/
- ^tobiko/tests/unit/
- job:
name: devstack-tobiko-octavia
parent: devstack-tobiko-base
abstract: true
description: |
Base Tobiko devstack job to be used with Octavia.
required-projects:
- openstack/barbican
- openstack/diskimage-builder
- openstack/octavia
- openstack/octavia-lib
- openstack/python-barbicanclient
- openstack/tripleo-image-elements
timeout: 7800
vars:
devstack_services:
# Octavia
octavia: true
o-cw: true
o-hk: true
o-hm: true
o-api: true
zuul_copy_output:
'/var/log/dib-build/': logs
'/var/log/octavia-tenant-traffic.log': logs
'/var/log/octavia-amphora.log': logs
extensions_to_txt:
conf: true
log: true
yaml: true
yml: true
- job:
name: devstack-tobiko
parent: devstack-tobiko-octavia
abstract: true
- job:
name: devstack-tobiko-functional
parent: devstack-tobiko
description: |
Base Tobiko devstack job to execute functional tests.
vars:
test_workflow: functional
irrelevant-files:
- ^.*\.rst$
- ^doc/
- ^infrared_plugin/
- ^releasenotes/
- ^report/
- ^tobiko/tests/faults/
- ^tobiko/tests/scenario/
- ^tobiko/tests/unit/
- job:
name: devstack-tobiko-functional-centos
parent: devstack-tobiko-functional
nodeset: devstack-single-node-centos-8
voting: false
- job:
name: devstack-tobiko-functional-ubuntu
parent: tobiko-devstack-functional
nodeset: openstack-single-node-focal
voting: false
- job:
name: devstack-tobiko-multinode
parent: devstack-tobiko
abstract: true
description: Base DevStack Tobiko job with multinode.
vars:
topology: multinode
devstack_localrc:
ENABLE_FILE_INJECTION: true
MULTI_HOST: 1
devstack_services:
n-cpu: false
group-vars:
subnode:
devstack_services:
c-vol: true
dstat: true
heat: false
h-api: false
h-api-cfn: false
h-eng: false
n-api-meta: true
placement-client: true
n-cpu: true
neutron-agent: true
# see bug #1860753 (https://bugs.launchpad.net/devstack/+bug/1860753)
memory_tracker: false
q-agt: true
q-l3: true
q-meta: true
tls-proxy: false
- job:
name: devstack-tobiko-faults
parent: devstack-tobiko-multinode
abstract: true
description: |
Base Tobiko devstack job to execute scenario+faults+scenario test cases.
vars:
test_workflow: faults
irrelevant-files:
- ^.*\.rst$
- ^doc/
- ^infrared_plugin/
- ^releasenotes/
- ^report/
- ^tobiko/tests/functional/
- ^tobiko/tests/unit/
- job:
name: devstack-tobiko-faults-centos
parent: devstack-tobiko-faults
nodeset: devstack-tobiko-multinode-centos
voting: false
- job:
name: devstack-tobiko-faults-ubuntu
parent: devstack-tobiko-faults
nodeset: devstack-tobiko-multinode-ubuntu
voting: false
vars:
devstack_services:
tls-proxy: true
group-vars:
subnode:
devstack_services:
tls-proxy: true

72
zuul.d/nodesets.yaml Normal file
View File

@ -0,0 +1,72 @@
---
- nodeset:
name: devstack-tobiko-multinode-centos
nodes:
- name: controller
label: centos-8
- name: compute1
label: centos-8
- name: compute2
label: centos-8
groups:
# Node where tests are executed and test results collected
- name: tempest
nodes:
- controller
# Nodes running the compute service
- name: compute
nodes:
- compute1
- compute2
# Nodes that are not the controller
- name: subnode
nodes:
- compute1
- compute2
# Switch node for multinode networking setup
- name: switch
nodes:
- controller
# Peer nodes for multinode networking setup
- name: peers
nodes:
- compute1
- compute2
- nodeset:
name: devstack-tobiko-multinode-ubuntu
nodes:
- name: controller
label: ubuntu-focal
- name: compute1
label: ubuntu-focal
- name: compute2
label: ubuntu-focal
groups:
# Node where tests are executed and test results collected
- name: tempest
nodes:
- controller
# Nodes running the compute service
- name: compute
nodes:
- compute1
- compute2
# Nodes that are not the controller
- name: subnode
nodes:
- compute1
- compute2
# Switch node for multinode networking setup
- name: switch
nodes:
- controller
# Peer nodes for multinode networking setup
- name: peers
nodes:
- compute1
- compute2

22
zuul.d/project.yaml Normal file
View File

@ -0,0 +1,22 @@
---
- project:
check:
jobs:
- openstack-tox-linters
# - devstack-tobiko-functional-centos
# - devstack-tobiko-functional-ubuntu
# - devstack-tobiko-faults-centos
# - devstack-tobiko-faults-ubuntu
gate:
jobs:
- openstack-tox-linters
periodic:
jobs:
- devstack-tobiko-functional-centos
- devstack-tobiko-functional-ubuntu
- devstack-tobiko-faults-centos
- devstack-tobiko-faults-ubuntu