Adding testenv worker wrapper script
Adds a script 60-setup-testenvs which is run by os-refresh-config. On first boot this carves up the host into a number of test environments and starts a gearman worker for each environment, noop if run more than once. Each test environment will have a seed, 3 vm's all on their own bridge. Depends-on: Ie33736850ec8186f0c90b82b6fbb0fd57fe47dc9 Change-Id: I46b2c95ccbda484b4de03585b830ac578df0e937
This commit is contained in:
parent
2adf68e075
commit
5d0b87738d
22
elements/testenv-worker/README.md
Normal file
22
elements/testenv-worker/README.md
Normal file
@ -0,0 +1,22 @@
|
||||
Install and configure a tripleo testenv worker
|
||||
|
||||
Carves up this host into a number of test environments and registers each one with gearman.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
gearman-worker:
|
||||
host: 127.0.0.1 # gearman broker host
|
||||
port:
|
||||
mem-per-env: 16 # Indicates each testenv should have 16G of Mem
|
||||
cpu-per-env: 4 # Indicates each testenv should have 4 cpu cores
|
||||
disk-per-env: 80 # Indicates each testenv should have 80G of disk space
|
||||
auth_user: admin
|
||||
auth_tenant: admin
|
||||
auth_url: http://127.0.0.1:5000
|
||||
auth_passwd: password
|
||||
neutron:
|
||||
ovs:
|
||||
physical_bridge: # A bridge name for the public_interface and seed interfaces
|
||||
public_interface: # The interface that should be moved onto physical_bridge
|
||||
# in order to comunicate with seed VM's
|
51
elements/testenv-worker/bin/ensure-test-env
Executable file
51
elements/testenv-worker/bin/ensure-test-env
Executable file
@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2013 Red Hat, Inc.
|
||||
# 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.
|
||||
#
|
||||
|
||||
set -eux
|
||||
|
||||
HOSTIP=$1
|
||||
OVSBRIDGE=$2
|
||||
NUM=$3
|
||||
|
||||
DATAFILE=$(mktemp /tmp/test_env_${NUM}_XXXXXX)
|
||||
trap 'rm -f $DATAFILE' ERR
|
||||
LOGFILE=/var/log/testenv-worker_${NUM}.log
|
||||
|
||||
setup-network $NUM
|
||||
|
||||
# FIXME : not idempotent, just creates more nodes, even if some already existed in this bridge
|
||||
create-nodes 1 4 30 amd64 3 brbm$NUM
|
||||
NODEMACS=
|
||||
for node in $(virsh list --all --name | grep brbm$NUM); do
|
||||
NODEMACS="$(virsh dumpxml $node | grep 'mac address' | awk -F \' 'NR==1,/mac address/ {print $2}')${NODEMACS:+ }$NODEMACS"
|
||||
done
|
||||
|
||||
IMAGE_NAME=seed_${NUM}
|
||||
setup-seed-vm -a amd64 -o $IMAGE_NAME -b brbm$NUM -p $OVSBRIDGE
|
||||
SEEDMAC=$(virsh dumpxml $IMAGE_NAME | grep 'mac address' | awk -F \' 'NR==1,/mac address/ {print $2}')
|
||||
|
||||
PORTOUTPUT=$(neutron port-create --name te_$(hostname)_$NUM --mac-address $SEEDMAC ctlplane)
|
||||
echo "$PORTOUTPUT"
|
||||
SEEDIP=$(echo "$PORTOUTPUT" | awk '/ fixed_ips / {print gensub(".*:\\s?\"([0-9.]+)\".*", "\\1", $0)}')
|
||||
|
||||
# FIXME : Need to somehow figure out a way to send auth details to the client
|
||||
echo "{\"host-ip\":\"$HOSTIP\", \"seed-ip\":\"$SEEDIP\", \"node-macs\":\"$NODEMACS\"}" > $DATAFILE
|
||||
|
||||
BROKER=$(os-apply-config --key gearman-worker.host --type netaddress):$(os-apply-config --key gearman-worker.port --key-default 4730 --type int)
|
||||
# FIXME : not idempotent, just starts more workers, we need a way cleanly kill then
|
||||
testenv-worker -b $BROKER $DATAFILE >> $LOGFILE 2>&1 &
|
4
elements/testenv-worker/element-deps
Normal file
4
elements/testenv-worker/element-deps
Normal file
@ -0,0 +1,4 @@
|
||||
network-utils
|
||||
openstack-clients
|
||||
os-collect-config
|
||||
source-repositories
|
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -eux
|
||||
|
||||
install-packages python-pip
|
||||
install-packages python-pip libvirt-bin qemu-utils python-libvirt qemu-kvm qemu-system
|
||||
|
||||
pip install gear
|
||||
|
||||
|
63
elements/testenv-worker/os-refresh-config/configure.d/60-setup-testenvs
Executable file
63
elements/testenv-worker/os-refresh-config/configure.d/60-setup-testenvs
Executable file
@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2013 Red Hat, Inc.
|
||||
# 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.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
# We don't want this running twice, even if it fails
|
||||
# We'll end up with lots of stuff duplicated
|
||||
[ -e /opt/stack/setup-testenvs.done ] && exit 0
|
||||
touch /opt/stack/setup-testenvs.done
|
||||
|
||||
# Calculate number of envs to setup based on lowest of Host Mem/CPU and Disk
|
||||
MEMTOTAL=$(free -g | awk '/Mem/ {print $2}')
|
||||
NUMENVS=$(expr $MEMTOTAL / $(os-apply-config --key gearman-worker.mem-per-env --key-default 16))
|
||||
|
||||
CPUTOTAL=$(grep "^processor" /proc/cpuinfo | wc -l)
|
||||
ENVS=$(expr $CPUTOTAL / $(os-apply-config --key gearman-worker.cpu-per-env --key-default 4))
|
||||
NUMENVS=$(($ENVS < $NUMENVS ? $ENVS : $NUMENVS))
|
||||
|
||||
DISKTOTAL=$(df /var/lib/libvirt/images/ | awk '/^\// {print $2}')
|
||||
ENVS=$(expr $DISKTOTAL / 1024 / 1024 / $(os-apply-config --key gearman-worker.disk-per-env --key-default 80))
|
||||
NUMENVS=$(($ENVS < $NUMENVS ? $ENVS : $NUMENVS))
|
||||
|
||||
echo "Setting up $NUMENVS test environments"
|
||||
|
||||
export PATH=/opt/stack/tripleo-incubator/scripts/:$PATH
|
||||
|
||||
# Place the physical interface onto the seed bridge
|
||||
OVSBRIDGE=$(os-apply-config --key gearman-worker.ovs.physical_bridge --type netdevice)
|
||||
ensure-bridge $OVSBRIDGE \
|
||||
$(os-apply-config --key gearman-worker.ovs.public_interface --type netdevice)
|
||||
|
||||
# Get the IP of this host
|
||||
HOSTIP=$(os-apply-config --key local-ipv4 --type netaddress)
|
||||
|
||||
# Define OS Auth env variables, needed for neutron command
|
||||
export OS_PASSWORD=$(os-apply-config --key gearman-worker.auth_passwd)
|
||||
export OS_AUTH_URL=$(os-apply-config --key gearman-worker.auth_url --type netaddress)
|
||||
export OS_USERNAME=$(os-apply-config --key gearman-worker.auth_user)
|
||||
export OS_TENANT_NAME=$(os-apply-config --key gearman-worker.auth_tenant)
|
||||
|
||||
killall -9 testenv-worker || true
|
||||
for port in $(neutron port-list | awk "\$4~\"te_$(hostname)_.*\" {print \$2}") ; do
|
||||
neutron port-delete $port
|
||||
done
|
||||
|
||||
for NUM in $(seq 1 $NUMENVS) ; do
|
||||
ensure-test-env $HOSTIP $OVSBRIDGE $NUM
|
||||
done
|
2
elements/testenv-worker/source-repository-testenv-worker
Normal file
2
elements/testenv-worker/source-repository-testenv-worker
Normal file
@ -0,0 +1,2 @@
|
||||
tripleo-incubator git /opt/stack/tripleo-incubator https://git.openstack.org/openstack/tripleo-incubator.git
|
||||
tripleo-image-elements git /opt/stack/tripleo-image-elements https://git.openstack.org/openstack/tripleo-image-elements.git
|
Loading…
Reference in New Issue
Block a user