aboutsummaryrefslogtreecommitdiffstats
path: root/docker/Dockerfile
blob: 46e52d55723a2f526be1e8e1efdb5947e867ee53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
##############################################################################
# Copyright (c) 2015 Ericsson AB and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

FROM ubuntu:16.04

LABEL image=opnfv/yardstick

ARG BRANCH=master

# GIT repo directory
ENV REPOS_DIR="/home/opnfv/repos" \
    IMAGE_DIR="/home/opnfv/images/"

# Set work directory

# Yardstick repo
ENV YARDSTICK_REPO_DIR="${REPOS_DIR}/yardstick" \
    RELENG_REPO_DIR="${REPOS_DIR}/releng" \
    STORPERF_REPO_DIR="${REPOS_DIR}/storperf"

RUN apt-get update && apt-get install -y git python-setuptools python-pip && apt-get -y autoremove && apt-get clean
RUN easy_install -U setuptools==30.0.0
RUN pip install appdirs==1.4.0 pyopenssl==17.5.0 python-openstackclient==3.11.0 python-heatclient==1.11.0

RUN mkdir -p ${REPOS_DIR}

RUN git config --global http.sslVerify false
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/yardstick ${YARDSTICK_REPO_DIR}
RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng ${RELENG_REPO_DIR}
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/storperf ${STORPERF_REPO_DIR}

WORKDIR ${YARDSTICK_REPO_DIR}
RUN ${YARDSTICK_REPO_DIR}/install.sh
RUN ${YARDSTICK_REPO_DIR}/docker/supervisor.sh

RUN echo "daemon off;" >> /etc/nginx/nginx.conf

EXPOSE 5000

ADD http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img ${IMAGE_DIR}
ADD http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img ${IMAGE_DIR}

COPY ./exec_tests.sh /usr/local/bin/

ENV NSB_DIR="/opt/nsb_bin" \
    PYTHONPATH="${PYTHONPATH}:${NSB_DIR}/trex_client:${NSB_DIR}/trex_client/stl"

WORKDIR ${REPOS_DIR}
CMD ["/usr/bin/supervisord"]
handlers from pod import Pod class K8sDeployment: """Deployment class to create containers for test execution in Kubernetes environment. """ LOG_FILE_NAME = "createrapidk8s.log" SSH_PRIVATE_KEY = "./rapid_rsa_key" SSH_USER = "centos" POD_YAML_TEMPLATE_FILE_NAME = "pod-rapid.yaml" _log = None _create_config = None _runtime_config = None _total_number_of_pods = 0 _pods = [] def __init__(self): # Configure logger self._log = logging.getLogger("k8srapid") self._log.setLevel(logging.DEBUG) console_formatter = logging.Formatter("%(message)s") console_handler = logging.StreamHandler(sys.stdout) console_handler.setLevel(logging.DEBUG) console_handler.setFormatter(console_formatter) file_formatter = logging.Formatter("%(asctime)s - " "%(levelname)s - " "%(message)s") file_handler = logging.handlers.RotatingFileHandler(self.LOG_FILE_NAME, backupCount=10) file_handler.setLevel(logging.DEBUG) file_handler.setFormatter(file_formatter) self._log.addHandler(file_handler) self._log.addHandler(console_handler) # Initialize k8s plugin config.load_kube_config() Pod.k8s_CoreV1Api = client.CoreV1Api() def load_create_config(self, config_file_name): """Read and parse configuration file for the test environment. """ self._log.info("Loading configuration file %s", config_file_name) self._create_config = ConfigParser.RawConfigParser() try: self._create_config.read(config_file_name) except Exception as e: self._log.error("Failed to read config file!\n%s\n" % e) return -1 # Now parse config file content # Parse [DEFAULT] section if self._create_config.has_option("DEFAULT", "total_number_of_pods"): self._total_number_of_pods = self._create_config.getint( "DEFAULT", "total_number_of_pods") else: self._log.error("No option total_number_of_pods in DEFAULT section") return -1 self._log.debug("Total number of pods %d" % self._total_number_of_pods) # Parse [PODx] sections for i in range(1, int(self._total_number_of_pods) + 1): # Search for POD name if self._create_config.has_option("POD%d" % i, "name"): pod_name = self._create_config.get( "POD%d" % i, "name") else: pod_name = "pod-rapid-%d" % i # Search for POD hostname if self._create_config.has_option("POD%d" % i, "nodeSelector_hostname"): pod_nodeselector_hostname = self._create_config.get( "POD%d" % i, "nodeSelector_hostname") else: pod_nodeselector_hostname = None # Search for POD dataplane static IP if self._create_config.has_option("POD%d" % i, "dp_ip"): pod_dp_ip = self._create_config.get( "POD%d" % i, "dp_ip") else: pod_dp_ip = None pod = Pod(pod_name) pod.set_nodeselector(pod_nodeselector_hostname) pod.set_dp_ip(pod_dp_ip) pod.set_id(i) # Add POD to the list of PODs which need to be created self._pods.append(pod) return 0 def create_pods(self): """ Create test PODs and wait for them to start. Collect information for tests to run. """ self._log.info("Creating PODs...") # Create PODs using template from yaml file for pod in self._pods: self._log.info("Creating POD %s...", pod.get_name()) pod.create_from_yaml(K8sDeployment.POD_YAML_TEMPLATE_FILE_NAME) # Wait for PODs to start for pod in self._pods: pod.wait_for_start() # Collect information from started PODs for test execution for pod in self._pods: pod.set_ssh_credentials(K8sDeployment.SSH_USER, K8sDeployment.SSH_PRIVATE_KEY) pod.get_sriov_dev_mac() def save_runtime_config(self, config_file_name): self._log.info("Saving config %s for runrapid script...", config_file_name) self._runtime_config = ConfigParser.RawConfigParser() # Section [DEFAULT] # self._runtime_config.set("DEFAULT", # "total_number_of_test_machines", # self._total_number_of_pods) # Section [ssh] self._runtime_config.add_section("ssh") self._runtime_config.set("ssh", "key", K8sDeployment.SSH_PRIVATE_KEY) self._runtime_config.set("ssh", "user", K8sDeployment.SSH_USER) # Section [rapid] self._runtime_config.add_section("rapid") self._runtime_config.set("rapid", "total_number_of_machines", self._total_number_of_pods) # Export information about each pod # Sections [Mx] for pod in self._pods: self._runtime_config.add_section("M%d" % pod.get_id()) self._runtime_config.set("M%d" % pod.get_id(), "admin_ip", pod.get_admin_ip()) self._runtime_config.set("M%d" % pod.get_id(), "dp_mac1", pod.get_dp_mac()) self._runtime_config.set("M%d" % pod.get_id(), "dp_pci_dev", pod.get_dp_pci_dev()) self._runtime_config.set("M%d" % pod.get_id(), "dp_ip1", pod.get_dp_ip()) # Section [Varia] self._runtime_config.add_section("Varia") self._runtime_config.set("Varia", "vim", "kubernetes") # Write runtime config file with open(config_file_name, "w") as file: self._runtime_config.write(file) def delete_pods(self): for pod in self._pods: pod.terminate()