Bugfix: ha test case criteria pass when sla not pass
[yardstick.git] / install.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 # fit for arm64
12 DOCKER_ARCH="$(uname -m)"
13
14 UBUNTU_PORTS_URL="http://ports.ubuntu.com/ubuntu-ports/"
15 UBUNTU_ARCHIVE_URL="http://archive.ubuntu.com/ubuntu/"
16
17 source /etc/os-release
18 source_file=/etc/apt/sources.list
19
20 if [[ "${DOCKER_ARCH}" == "aarch64" ]]; then
21     sed -i -e 's/^deb \([^/[]\)/deb [arch=arm64] \1/g' "${source_file}"
22     DOCKER_ARCH="arm64"
23     DOCKER_REPO="${UBUNTU_PORTS_URL}"
24     EXTRA_ARCH="amd64"
25     EXTRA_REPO="${UBUNTU_ARCHIVE_URL}"
26     dpkg --add-architecture amd64
27 else
28     sed -i -e 's/^deb \([^/[]\)/deb [arch=amd64] \1/g' "${source_file}"
29     DOCKER_ARCH="amd64"
30     DOCKER_REPO="${UBUNTU_ARCHIVE_URL}"
31     EXTRA_ARCH="arm64"
32     EXTRA_REPO="${UBUNTU_PORTS_URL}"
33     dpkg --add-architecture arm64
34 fi
35
36 sed -i -e 's/^deb-src /# deb-src /g' "${source_file}"
37
38 VERSION_CODENAME=${VERSION_CODENAME:-trusty}
39
40 echo "APT::Default-Release \""${VERSION_CODENAME}"\";" > /etc/apt/apt.conf.d/default-distro
41
42 sub_source_file=/etc/apt/sources.list.d/yardstick.list
43 touch "${sub_source_file}"
44
45 # first add xenial repo needed for installing qemu_static_user/xenial in the container
46 # then add complementary architecture repositories in case the cloud image is of different arch
47 if [[ "${VERSION_CODENAME}" != "xenial" ]]; then
48     REPO_UPDATE="deb [arch="${DOCKER_ARCH}"] "${DOCKER_REPO}" xenial-updates universe"
49 fi
50
51 echo -e ""${REPO_UPDATE}"
52 deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}" main universe multiverse restricted
53 deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}"-updates main universe multiverse restricted
54 deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}"-security main universe multiverse restricted
55 deb [arch="${EXTRA_ARCH}"] "${EXTRA_REPO}" "${VERSION_CODENAME}"-proposed main universe multiverse restricted" > "${sub_source_file}"
56
57 echo "vm.mmap_min_addr = 0" > /etc/sysctl.d/mmap_min_addr.conf
58
59 # install tools
60 apt-get update && apt-get install -y \
61     qemu-user-static/xenial \
62     bonnie++ \
63     wget \
64     expect \
65     curl \
66     git \
67     sshpass \
68     qemu-utils \
69     kpartx \
70     libffi-dev \
71     libssl-dev \
72     libzmq-dev \
73     python \
74     python-dev \
75     libxml2-dev \
76     libxslt1-dev \
77     nginx \
78     uwsgi \
79     uwsgi-plugin-python \
80     supervisor \
81     python-pip \
82     vim
83
84 if [[ "${DOCKER_ARCH}" != "aarch64" ]]; then
85     apt-get install -y libc6:arm64
86 fi
87
88 apt-get -y autoremove && apt-get clean
89
90 git config --global http.sslVerify false
91
92
93 # install yardstick + dependencies
94 easy_install -U pip
95 pip install -r requirements.txt
96 pip install -e .
97
98 /bin/bash "${PWD}/docker/uwsgi.sh"
99 /bin/bash "${PWD}/docker/nginx.sh"
100 cd "${PWD}/gui" && /bin/bash gui.sh
101 mkdir -p /etc/nginx/yardstick
102 mv dist /etc/nginx/yardstick/gui
103
104 service nginx restart
105 uwsgi -i /etc/yardstick/yardstick.ini