mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-11 03:31:29 -07:00
automated integration tests for cloudstack (#20552)
This commit is contained in:
parent
b58cf0d23a
commit
aaf4f04574
92 changed files with 1248 additions and 193 deletions
64
test/utils/docker/cloudstack-simulator/Dockerfile
Normal file
64
test/utils/docker/cloudstack-simulator/Dockerfile
Normal file
|
@ -0,0 +1,64 @@
|
|||
FROM ubuntu:16.04
|
||||
|
||||
MAINTAINER "René Moser" <mail@renemoser.net>
|
||||
|
||||
RUN echo 'mysql-server mysql-server/root_password password root' | debconf-set-selections; \
|
||||
echo 'mysql-server mysql-server/root_password_again password root' | debconf-set-selections;
|
||||
|
||||
RUN apt-get -y update && apt-get install -y \
|
||||
genisoimage \
|
||||
libffi-dev \
|
||||
libssl-dev \
|
||||
sudo \
|
||||
ipmitool \
|
||||
maven \
|
||||
netcat \
|
||||
openjdk-8-jdk \
|
||||
python-dev \
|
||||
python-setuptools \
|
||||
python-pip \
|
||||
python-mysql.connector \
|
||||
supervisor \
|
||||
wget \
|
||||
nginx \
|
||||
jq \
|
||||
mysql-server \
|
||||
openssh-client \
|
||||
&& apt-get clean all \
|
||||
&& rm -rf /var/lib/apt/lists/*;
|
||||
|
||||
# TODO: check if and why this is needed
|
||||
RUN mkdir -p /root/.ssh \
|
||||
&& chmod 0700 /root/.ssh \
|
||||
&& ssh-keygen -t rsa -N "" -f id_rsa.cloud
|
||||
|
||||
RUN mkdir -p /var/run/mysqld; \
|
||||
chown mysql /var/run/mysqld; \
|
||||
echo '''sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"''' >> /etc/mysql/mysql.conf.d/mysqld.cnf
|
||||
|
||||
RUN (/usr/bin/mysqld_safe &); sleep 5; mysqladmin -u root -proot password ''
|
||||
|
||||
RUN wget https://github.com/apache/cloudstack/archive/4.9.2.0.tar.gz -O /opt/cloudstack.tar.gz; \
|
||||
mkdir -p /opt/cloudstack; \
|
||||
tar xvzf /opt/cloudstack.tar.gz -C /opt/cloudstack --strip-components=1
|
||||
|
||||
WORKDIR /opt/cloudstack
|
||||
|
||||
RUN mvn -Pdeveloper -Dsimulator -DskipTests clean install
|
||||
|
||||
RUN (/usr/bin/mysqld_safe &); \
|
||||
sleep 5; \
|
||||
mvn -Pdeveloper -pl developer -Ddeploydb; \
|
||||
mvn -Pdeveloper -pl developer -Ddeploydb-simulator; \
|
||||
MARVIN_FILE=$(find /opt/cloudstack/tools/marvin/dist/ -name "Marvin*.tar.gz"); \
|
||||
pip install $MARVIN_FILE;
|
||||
|
||||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
COPY zones.cfg /opt/zones.cfg
|
||||
COPY nginx_default.conf /etc/nginx/sites-available/default
|
||||
RUN pip install cs
|
||||
COPY run.sh /opt/run.sh
|
||||
|
||||
EXPOSE 8888 8080 8096
|
||||
|
||||
CMD ["/usr/bin/supervisord"]
|
14
test/utils/docker/cloudstack-simulator/Makefile
Normal file
14
test/utils/docker/cloudstack-simulator/Makefile
Normal file
|
@ -0,0 +1,14 @@
|
|||
build:
|
||||
docker build -t cloudstack-sim .
|
||||
|
||||
clean:
|
||||
docker rm -f cloudstack
|
||||
|
||||
run:
|
||||
docker run --name cloudstack -d -p 8080:8080 -p 8888:8888 cloudstack-sim
|
||||
|
||||
shell:
|
||||
docker exec -it cloudstack /bin/bash
|
||||
|
||||
logs:
|
||||
docker logs -f cloudstack
|
31
test/utils/docker/cloudstack-simulator/README.rst
Normal file
31
test/utils/docker/cloudstack-simulator/README.rst
Normal file
|
@ -0,0 +1,31 @@
|
|||
CloudStack Simulator as Docker Image
|
||||
====================================
|
||||
|
||||
The purpose of this docker image is to run automated integration tests for the CloudStack modules in Ansible.
|
||||
|
||||
Setup
|
||||
-----
|
||||
|
||||
The docker image runs the CloudStack simulator and contains two zones for the different network setups: `basic` and `advanced` networking.
|
||||
|
||||
- CloudStack Zone: Sandbox-simulator-advanced
|
||||
- Zone: Sandbox-simulator-basic
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
docker build -t ansible/cloudstack-simulator .
|
||||
|
||||
Run
|
||||
---
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
docker run --name cloudstack-simulator -d -p 8888:8888 ansible/cloudstack-simulator
|
||||
|
||||
|
||||
.. Note::
|
||||
|
||||
It may take some time until the zones are deployed. The web server will respond with HTTP 503 on port 8888 unless the zones are fully deployed.
|
23
test/utils/docker/cloudstack-simulator/nginx_default.conf
Normal file
23
test/utils/docker/cloudstack-simulator/nginx_default.conf
Normal file
|
@ -0,0 +1,23 @@
|
|||
upstream cloudstack-backend {
|
||||
server 127.0.0.1:8080;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8888 default_server;
|
||||
|
||||
root /var/www/html;
|
||||
|
||||
server_name _;
|
||||
|
||||
# waiting for zone to be deployed
|
||||
if (!-f /var/www/html/admin.json) {
|
||||
return 503;
|
||||
}
|
||||
|
||||
location /client {
|
||||
proxy_pass http://cloudstack-backend;
|
||||
}
|
||||
location / {
|
||||
|
||||
}
|
||||
}
|
15
test/utils/docker/cloudstack-simulator/run.sh
Executable file
15
test/utils/docker/cloudstack-simulator/run.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
until nc -z localhost 8096; do
|
||||
echo "waiting for port 8096..."
|
||||
sleep 3
|
||||
done
|
||||
|
||||
sleep 3
|
||||
if [ ! -e /var/www/html/admin.json ]
|
||||
then
|
||||
python /opt/cloudstack/tools/marvin/marvin/deployDataCenter.py -i /opt/zones.cfg
|
||||
export CLOUDSTACK_ENDPOINT=http://127.0.0.1:8096
|
||||
export CLOUDSTACK_KEY=""
|
||||
export CLOUDSTACK_SECRET=""
|
||||
cs listUsers account=admin | jq .user[0] > /var/www/html/admin.json
|
||||
fi
|
28
test/utils/docker/cloudstack-simulator/supervisord.conf
Normal file
28
test/utils/docker/cloudstack-simulator/supervisord.conf
Normal file
|
@ -0,0 +1,28 @@
|
|||
[supervisord]
|
||||
nodaemon=true
|
||||
|
||||
[program:mysqld]
|
||||
command=/usr/bin/mysqld_safe
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=root
|
||||
|
||||
[program:cloudstack]
|
||||
command=/bin/bash -c "mvn -pl client jetty:run -Dsimulator -Dorg.eclipse.jetty.annotations.maxWait=120"
|
||||
directory=/opt/cloudstack
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
user=root
|
||||
|
||||
[program:nginx]
|
||||
command=/usr/sbin/nginx
|
||||
autostart=true
|
||||
autorestart=false
|
||||
user=root
|
||||
|
||||
[program:deploy-zones]
|
||||
command = /opt/run.sh
|
||||
startsecs = 0
|
||||
autorestart = false
|
||||
startretries = 1
|
||||
user=root
|
310
test/utils/docker/cloudstack-simulator/zones.cfg
Normal file
310
test/utils/docker/cloudstack-simulator/zones.cfg
Normal file
|
@ -0,0 +1,310 @@
|
|||
{
|
||||
"zones": [
|
||||
{
|
||||
"name": "Sandbox-simulator-basic",
|
||||
"dns1": "8.8.8.8",
|
||||
"physical_networks": [
|
||||
{
|
||||
"broadcastdomainrange": "Zone",
|
||||
"name": "Sandbox-pnet",
|
||||
"traffictypes": [
|
||||
{
|
||||
"typ": "Guest"
|
||||
},
|
||||
{
|
||||
"typ": "Management"
|
||||
}
|
||||
],
|
||||
"providers": [
|
||||
{
|
||||
"broadcastdomainrange": "ZONE",
|
||||
"name": "VirtualRouter"
|
||||
},
|
||||
{
|
||||
"broadcastdomainrange": "Pod",
|
||||
"name": "SecurityGroupProvider"
|
||||
}
|
||||
],
|
||||
"isolationmethods": [
|
||||
"L3"
|
||||
]
|
||||
}
|
||||
],
|
||||
"securitygroupenabled": "true",
|
||||
"networktype": "Basic",
|
||||
"pods": [
|
||||
{
|
||||
"endip": "172.16.15.254",
|
||||
"name": "POD0-basic",
|
||||
"startip": "172.16.15.2",
|
||||
"guestIpRanges": [
|
||||
{
|
||||
"startip": "60.147.41.2",
|
||||
"endip": "60.147.41.254",
|
||||
"netmask": "255.255.255.0",
|
||||
"gateway": "60.147.41.1"
|
||||
}
|
||||
],
|
||||
"netmask": "255.255.255.0",
|
||||
"clusters": [
|
||||
{
|
||||
"clustername": "C0-basic",
|
||||
"hypervisor": "simulator",
|
||||
"hosts": [
|
||||
{
|
||||
"username": "root",
|
||||
"url": "http://sim/c0-basic/h0",
|
||||
"password": "password"
|
||||
},
|
||||
{
|
||||
"username": "root",
|
||||
"url": "http://sim/c0-basic/h1",
|
||||
"password": "password"
|
||||
}
|
||||
],
|
||||
"clustertype": "CloudManaged",
|
||||
"primaryStorages": [
|
||||
{
|
||||
"url": "nfs://nfsstor:/export/home/sandbox/primary",
|
||||
"name": "PS0-basic"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"gateway": "172.16.15.1"
|
||||
}
|
||||
],
|
||||
"internaldns1": "8.8.8.8",
|
||||
"secondaryStorages": [
|
||||
{
|
||||
"url": "nfs://nfsstor:/export/home/sandbox/secondary",
|
||||
"provider" : "NFS"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Sandbox-simulator-advanced",
|
||||
"guestcidraddress": "10.1.1.0/24",
|
||||
"dns1": "10.147.28.7",
|
||||
"physical_networks": [
|
||||
{
|
||||
"broadcastdomainrange": "Zone",
|
||||
"vlan": "100-200",
|
||||
"name": "Sandbox-pnet",
|
||||
"traffictypes": [
|
||||
{
|
||||
"typ": "Guest"
|
||||
},
|
||||
{
|
||||
"typ": "Management"
|
||||
},
|
||||
{
|
||||
"typ": "Public"
|
||||
}
|
||||
],
|
||||
"providers": [
|
||||
{
|
||||
"broadcastdomainrange": "ZONE",
|
||||
"name": "VirtualRouter"
|
||||
},
|
||||
{
|
||||
"broadcastdomainrange": "ZONE",
|
||||
"name": "VpcVirtualRouter"
|
||||
},
|
||||
{
|
||||
"broadcastdomainrange": "ZONE",
|
||||
"name": "InternalLbVm"
|
||||
}
|
||||
],
|
||||
"isolationmethods": [
|
||||
"VLAN"
|
||||
]
|
||||
}
|
||||
],
|
||||
"vmwaredc": {
|
||||
"username": "",
|
||||
"vcenter": "",
|
||||
"password": "",
|
||||
"name": ""
|
||||
},
|
||||
"ipranges": [
|
||||
{
|
||||
"startip": "192.168.2.2",
|
||||
"endip": "192.168.2.200",
|
||||
"netmask": "255.255.255.0",
|
||||
"vlan": "50",
|
||||
"gateway": "192.168.2.1"
|
||||
}
|
||||
],
|
||||
"networktype": "Advanced",
|
||||
"pods": [
|
||||
{
|
||||
"endip": "172.16.15.200",
|
||||
"name": "POD0-adv",
|
||||
"startip": "172.16.15.2",
|
||||
"netmask": "255.255.255.0",
|
||||
"clusters": [
|
||||
{
|
||||
"clustername": "C0-adv",
|
||||
"hypervisor": "simulator",
|
||||
"hosts": [
|
||||
{
|
||||
"username": "root",
|
||||
"url": "http://sim/c0-adv/h0",
|
||||
"password": "password"
|
||||
},
|
||||
{
|
||||
"username": "root",
|
||||
"url": "http://sim/c0-adv/h1",
|
||||
"password": "password"
|
||||
}
|
||||
],
|
||||
"clustertype": "CloudManaged",
|
||||
"primaryStorages": [
|
||||
{
|
||||
"url": "nfs://10.147.28.7:/export/home/sandbox/primary0",
|
||||
"name": "PS0-adv"
|
||||
},
|
||||
{
|
||||
"url": "nfs://10.147.28.7:/export/home/sandbox/primary1",
|
||||
"name": "PS1-adv"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"clustername": "C1-adv",
|
||||
"hypervisor": "simulator",
|
||||
"hosts": [
|
||||
{
|
||||
"username": "root",
|
||||
"url": "http://sim/c1-adv/h0",
|
||||
"password": "password"
|
||||
}
|
||||
],
|
||||
"clustertype": "CloudManaged",
|
||||
"primaryStorages": [
|
||||
{
|
||||
"url": "nfs://10.147.28.7:/export/home/sandbox/primary2",
|
||||
"name": "PS2-adv"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"gateway": "172.16.15.1"
|
||||
}
|
||||
],
|
||||
"internaldns1": "10.147.28.7",
|
||||
"secondaryStorages": [
|
||||
{
|
||||
"url": "nfs://10.147.28.7:/export/home/sandbox/secondary",
|
||||
"provider" : "NFS"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"dbSvr": {
|
||||
"dbSvr": "localhost",
|
||||
"passwd": "cloud",
|
||||
"db": "cloud",
|
||||
"port": 3306,
|
||||
"user": "cloud"
|
||||
},
|
||||
"logger":
|
||||
{
|
||||
"LogFolderPath": "/tmp/"
|
||||
},
|
||||
"globalConfig": [
|
||||
{
|
||||
"name": "network.gc.wait",
|
||||
"value": "20"
|
||||
},
|
||||
{
|
||||
"name": "storage.cleanup.interval",
|
||||
"value": "40"
|
||||
},
|
||||
{
|
||||
"name": "vm.op.wait.interval",
|
||||
"value": "5"
|
||||
},
|
||||
{
|
||||
"name": "default.page.size",
|
||||
"value": "500"
|
||||
},
|
||||
{
|
||||
"name": "network.gc.interval",
|
||||
"value": "20"
|
||||
},
|
||||
{
|
||||
"name": "instance.name",
|
||||
"value": "QA"
|
||||
},
|
||||
{
|
||||
"name": "workers",
|
||||
"value": "10"
|
||||
},
|
||||
{
|
||||
"name": "account.cleanup.interval",
|
||||
"value": "20"
|
||||
},
|
||||
{
|
||||
"name": "guest.domain.suffix",
|
||||
"value": "sandbox.simulator"
|
||||
},
|
||||
{
|
||||
"name": "expunge.delay",
|
||||
"value": "20"
|
||||
},
|
||||
{
|
||||
"name": "vm.allocation.algorithm",
|
||||
"value": "random"
|
||||
},
|
||||
{
|
||||
"name": "expunge.interval",
|
||||
"value": "20"
|
||||
},
|
||||
{
|
||||
"name": "expunge.workers",
|
||||
"value": "3"
|
||||
},
|
||||
{
|
||||
"name": "check.pod.cidrs",
|
||||
"value": "true"
|
||||
},
|
||||
{
|
||||
"name": "secstorage.allowed.internal.sites",
|
||||
"value": "10.147.28.0/24"
|
||||
},
|
||||
{
|
||||
"name": "direct.agent.load.size",
|
||||
"value": "1000"
|
||||
},
|
||||
{
|
||||
"name": "enable.dynamic.scale.vm",
|
||||
"value": "true"
|
||||
},
|
||||
{
|
||||
"name": "ping.interval",
|
||||
"value": "10"
|
||||
},
|
||||
{
|
||||
"name": "ping.timeout",
|
||||
"value": "1.5"
|
||||
},
|
||||
{
|
||||
"name": "outofbandmanagement.sync.interval",
|
||||
"value": "1000"
|
||||
}
|
||||
],
|
||||
"mgtSvr": [
|
||||
{
|
||||
"mgtSvrIp": "localhost",
|
||||
"passwd": "password",
|
||||
"user": "root",
|
||||
"port": 8096,
|
||||
"hypervisor": "simulator",
|
||||
"useHttps": "False",
|
||||
"certCAPath": "NA",
|
||||
"certPath": "NA"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue