summaryrefslogtreecommitdiffstats
path: root/src/CMakeLists.txt
blob: 2fb0703e1748451c9788b36f830c7cb830e64540 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# Copyright (c) 2018 Cisco and/or its affiliates.
# 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.

cmake_minimum_required(VERSION 3.13)

set(CMAKE_C_COMPILER_NAMES clang gcc cc)

project(vpp C)

if(NOT DEFINED CMAKE_INSTALL_LIBDIR AND EXISTS "/etc/debian_version")
  set(CMAKE_INSTALL_LIBDIR "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
endif()

include(CheckCCompilerFlag)
include(CheckIPOSupported)
include(GNUInstallDirs)
include(cmake/misc.cmake)
include(cmake/cpu.cmake)
include(cmake/ccache.cmake)

##############################################################################
# VPP Version
##############################################################################
execute_process(
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  COMMAND scripts/version
  OUTPUT_VARIABLE VPP_VERSION
  OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REPLACE "-" ";" VPP_LIB_VERSION ${VPP_VERSION})
list(GET VPP_LIB_VERSION 0 VPP_LIB_VERSION)

##############################################################################
# compiler specifics
##############################################################################

set(MIN_SUPPORTED_CLANG_C_COMPILER_VERSION 9.0.0)
set(MIN_SUPPORTED_GNU_C_COMPILER_VERSION 9.0.0)

if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
  if (CMAKE_C_COMPILER_VERSION VERSION_LESS MIN_SUPPORTED_CLANG_C_COMPILER_VERSION)
    set(COMPILER_TOO_OLD TRUE)
  endif()
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
  if (CMAKE_C_COMPILER_VERSION VERSION_LESS MIN_SUPPORTED_GNU_C_COMPILER_VERSION)
    set(COMPILER_TOO_OLD TRUE)
  endif()
else()
  message(WARNING "WARNING: Unsupported C compiler `${CMAKE_C_COMPILER_ID}` is used")
  set (PRINT_MIN_C_COMPILER_VER TRUE)
endif()
if (COMPILER_TOO_OLD)
  message(WARNING "WARNING: C compiler version is too old and it's usage may result")
  message(WARNING "         in sub-optimal binaries or lack of support for specific CPU types.")
  set (PRINT_MIN_C_COMPILER_VER TRUE)
endif()

if (PRINT_MIN_C_COMPILER_VER)
  string (APPEND _t "Supported C compilers are ")
  string (APPEND _t "Clang ${MIN_SUPPORTED_CLANG_C_COMPILER_VERSION} or higher ")
  string (APPEND _t "and GNU ${MIN_SUPPORTED_GNU_C_COMPILER_VERSION} or higher.")
  message(WARNING "         ${_t}")
  unset (_t)
endif()

##############################################################################
# cross compiling
##############################################################################
if(CMAKE_CROSSCOMPILING)
  set(CMAKE_IGNORE_PATH
    /usr/lib/${CMAKE_HOST_SYSTEM_PROCESSOR}-linux-gnu/
    /usr/lib/${CMAKE_HOST_SYSTEM_PROCESSOR}-linux-gnu/lib/
  )
endif()
set(CMAKE_C_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-linux-gnu)

##############################################################################
# build config
##############################################################################
check_c_compiler_flag("-Wno-address-of-packed-member"
		      compiler_flag_no_address_of_packed_member)
set(VPP_RUNTIME_DIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "Relative runtime directory path")
set(VPP_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Relative library directory path")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${VPP_RUNTIME_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${VPP_LIBRARY_DIR})
set(VPP_BINARY_DIR ${CMAKE_BINARY_DIR}/CMakeFiles)
set(PYENV PYTHONPYCACHEPREFIX=${CMAKE_BINARY_DIR}/CMakeFiles/__pycache__)

if (CMAKE_BUILD_TYPE)
  add_compile_options(-g -Werror -Wall)
endif()

if (compiler_flag_no_address_of_packed_member)
  add_compile_options(-Wno-address-of-packed-member)
endif()

string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LC)
string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UC)

set(CMAKE_C_FLAGS_RELEASE "")
set(CMAKE_C_FLAGS_DEBUG "")

if (${CMAKE_BUILD_TYPE_LC} MATCHES "release")
  add_compile_options(-O3 -fstack-protector -fno-common)
  add_compile_definitions(_FORTIFY_SOURCE=2)
elseif (${CMAKE_BUILD_TYPE_LC} MATCHES "debug")
  add_compile_options(-O0 -fstack-protector -fno-common)
  add_compile_definitions(CLIB_DEBUG)
elseif (${CMAKE_BUILD_TYPE_LC} MATCHES "coverity")
  add_compile_options(-O0)
  add_compile_definitions(__COVERITY__)
elseif (${CMAKE_BUILD_TYPE_LC} MATCHES "gcov")
  add_compile_options(-O0 -fprofile-arcs -ftest-coverage)
  add_compile_definitions(CLIB_DEBUG CLIB_GCOV)
endif()

set(BUILD_TYPES release debug coverity gcov)
string(REPLACE ";" " " BUILD_TYPES_STR "${BUILD_TYPES}")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
	     HELPSTRING "Build type - valid options are: ${BUILD_TYPES_STR}")

##############################################################################
# link time optimizations
##############################################################################
if (CMAKE_BUILD_TYPE_UC STREQUAL "RELEASE")
  check_ipo_supported(RESULT _result)
  if (_result)
    option(VPP_USE_LTO "Link time optimization of release binaries" ON)
  endif()
endif()

if(VPP_USE_LTO)
  check_c_compiler_flag("-Wno-stringop-overflow"
		        compiler_flag_no_stringop_overflow)
endif()
##############################################################################
# sanitizers
##############################################################################

option(VPP_ENABLE_SANITIZE_ADDR "Enable Address Sanitizer" OFF)
set(VPP_SANITIZE_ADDR_OPTIONS
  "unmap_shadow_on_exit=1:disable_coredump=0:abort_on_error=1:detect_leaks=0"
  CACHE
  STRING "Address sanitizer arguments"
)

if (VPP_ENABLE_SANITIZE_ADDR)
  add_compile_options(-fsanitize=address)
  add_link_options(-fsanitize=address)
endif (VPP_ENABLE_SANITIZE_ADDR)

##############################################################################
# trajectory trace
##############################################################################

option(VPP_ENABLE_TRAJECTORY_TRACE "Build vpp with trajectory tracing enabled" OFF)
if(VPP_ENABLE_TRAJECTORY_TRACE)
  add_compile_definitions(VLIB_BUFFER_TRACE_TRAJECTORY=1)
endif()

##############################################################################
# unittest with clang ode coverage
##############################################################################

if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.13" AND "${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
  option(VPP_BUILD_TESTS_WITH_COVERAGE "Build unit tests with code coverage" OFF)
endif()

##############################################################################
# install config
##############################################################################
option(VPP_SET_RPATH "Set rpath for resulting binaries and libraries." ON)
if(VPP_SET_RPATH)
  set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${VPP_LIBRARY_DIR}")
endif()
set(CMAKE_INSTALL_MESSAGE NEVER)

include_directories (
	${CMAKE_SOURCE_DIR}
	${VPP_BINARY_DIR}
)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "vpp")

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

include(cmake/syscall.cmake)
include(cmake/api.cmake)
include(cmake/library.cmake)
include(cmake/exec.cmake)
include(cmake/plugin.cmake)

##############################################################################
# subdirs - order matters
##############################################################################
option(VPP_HOST_TOOLS_ONLY "Build only host tools" OFF)
if(VPP_HOST_TOOLS_ONLY)
  set(SUBDIRS tools/vppapigen cmake)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
  find_package(OpenSSL)
  set(SUBDIRS
    vppinfra svm vlib vlibmemory vlibapi vnet vpp vat vat2 vcl vpp-api
    plugins tools/vppapigen tools/g2 tools/perftool cmake pkg
    tools/appimage
  )
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
  set(SUBDIRS vppinfra)
else()
  message(FATAL_ERROR "Unsupported system: ${CMAKE_SYSTEM_NAME}")
endif()

foreach(DIR ${SUBDIRS})
  add_subdirectory(${DIR} ${VPP_BINARY_DIR}/${DIR})
endforeach()

##############################################################################
# detect if we are inside git repo and add configure dependency
##############################################################################
execute_process(
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  COMMAND git rev-parse --show-toplevel
  OUTPUT_VARIABLE VPP_GIT_TOPLEVEL_DIR
  OUTPUT_STRIP_TRAILING_WHITESPACE
  ERROR_QUIET
)

if (VPP_GIT_TOPLEVEL_DIR)
  set_property(
    DIRECTORY APPEND PROPERTY
    CMAKE_CONFIGURE_DEPENDS ${VPP_GIT_TOPLEVEL_DIR}/.git/index
  )
endif()

##############################################################################
# custom targets
##############################################################################

add_custom_target(run
  COMMAND ./${VPP_RUNTIME_DIR}/vpp -c startup.conf
  COMMENT "Starting VPP..."
  USES_TERMINAL
)

add_custom_target(debug
  COMMAND gdb --args ./${VPP_RUNTIME_DIR}/vpp -c startup.conf
  COMMENT "Starting VPP in the debugger..."
  USES_TERMINAL
)

add_custom_target(config
  COMMAND ccmake ${CMAKE_BINARY_DIR}
  COMMENT "Starting Configuration TUI..."
  USES_TERMINAL
)

foreach(bt ${BUILD_TYPES})
  add_custom_target(set-build-type-${bt}
    COMMAND cmake -DCMAKE_BUILD_TYPE:STRING=${bt} .
    COMMENT "Changing build type to ${bt}"
    USES_TERMINAL
  )
endforeach()

mark_as_advanced(CLEAR
  CMAKE_C_FLAGS
  CMAKE_C_COMPILER
  CMAKE_EXPORT_COMPILE_COMMANDS
  CMAKE_INSTALL_PREFIX
  CMAKE_LINKER
  CMAKE_SHARED_LINKER_FLAGS
  CMAKE_VERBOSE_MAKEFILE
)

##############################################################################
# print configuration
##############################################################################
message(STATUS "Configuration:")
pr("VPP version" ${VPP_VERSION})
pr("VPP library version" ${VPP_LIB_VERSION})
pr("GIT toplevel dir" ${VPP_GIT_TOPLEVEL_DIR})
pr("Build type" ${CMAKE_BUILD_TYPE})
pr("C compiler" "${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION})")
pr("C flags" ${CMAKE_C_FLAGS}${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}})
pr("Linker flags (apps)" ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}})
pr("Linker flags (libs)" ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}})
pr("Host processor" ${CMAKE_HOST_SYSTEM_PROCESSOR})
pr("Target processor" ${CMAKE_SYSTEM_PROCESSOR})
pr("Prefix path" ${CMAKE_PREFIX_PATH})
pr("Install prefix" ${CMAKE_INSTALL_PREFIX})
pr("Library dir" ${VPP_LIBRARY_DIR})
pr("Multiarch variants" ${MARCH_VARIANTS_NAMES})
ense for the specific language governing permissions and # limitations under the License. set -x cat /etc/hostname cat /etc/hosts JOB_ARCHIVE_ARTIFACTS=(log.html output.xml report.html *.log) LOG_ARCHIVE_ARTIFACTS=(log.html output.xml report.html *.log) JOB_ARCHIVE_DIR="archive" LOG_ARCHIVE_DIR="$WORKSPACE/archives" mkdir -p ${JOB_ARCHIVE_DIR} mkdir -p ${LOG_ARCHIVE_DIR} SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export PYTHONPATH=${SCRIPT_DIR} if [ -f "/etc/redhat-release" ]; then DISTRO="CENTOS" sudo yum install -y python-devel python-virtualenv openssh-clients sshpass DPDK_ARTIFACTS="" VIRL_TOPOLOGY=$(cat ${SCRIPT_DIR}/VIRL_TOPOLOGY_CENTOS) VIRL_RELEASE=$(cat ${SCRIPT_DIR}/VIRL_RELEASE_CENTOS) else DISTRO="UBUNTU" export DEBIAN_FRONTEND=noninteractive sudo apt-get -y update sudo apt-get -y install libpython2.7-dev python-virtualenv DPDK_ARTIFACTS="" VIRL_TOPOLOGY=$(cat ${SCRIPT_DIR}/VIRL_TOPOLOGY_UBUNTU) VIRL_RELEASE=$(cat ${SCRIPT_DIR}/VIRL_RELEASE_UBUNTU) fi VIRL_SERVERS=("10.30.51.28" "10.30.51.29" "10.30.51.30") IPS_PER_VIRL=( "10.30.51.28:252" "10.30.51.29:252" "10.30.51.30:252" ) SIMS_PER_VIRL=( "10.30.51.28:13" "10.30.51.29:13" "10.30.51.30:13" ) IPS_PER_SIMULATION=5 function get_max_ip_nr() { virl_server=$1 IP_VALUE="0" for item in "${IPS_PER_VIRL[@]}" ; do if [ "${item%%:*}" == "${virl_server}" ] then IP_VALUE=${item#*:} break fi done echo "$IP_VALUE" } function get_max_sim_nr() { virl_server=$1 SIM_VALUE="0" for item in "${SIMS_PER_VIRL[@]}" ; do if [ "${item%%:*}" == "${virl_server}" ] then SIM_VALUE=${item#*:} break fi done echo "$SIM_VALUE" } VIRL_USERNAME=jenkins-in VIRL_PKEY=priv_key VIRL_SERVER_STATUS_FILE="status" VIRL_SERVER_EXPECTED_STATUS="PRODUCTION" SSH_OPTIONS="-i ${VIRL_PKEY} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -o LogLevel=error" TEST_GROUPS=("func") SUITE_PATH="tests.dmm" SKIP_PATCH="SKIP_PATCH" # Create tmp dir mkdir ${SCRIPT_DIR}/tmp # Use tmp dir to store log files LOG_PATH="${SCRIPT_DIR}/tmp" # Use tmp dir for tarballs export TMPDIR="${SCRIPT_DIR}/tmp" function ssh_do() { echo echo "### " ssh $@ ssh ${SSH_OPTIONS} $@ } rm -f ${VIRL_PKEY} cat > ${VIRL_PKEY} <<EOF -----BEGIN RSA PRIVATE KEY----- MIIEpQIBAAKCAQEA+IHXq87GcqMR1C47rzx6Cbip5Ghq8pKrbqKrP5Nf41HcYrT6 GOXl9nFWKsMOzIlIn+8y7Il27eZh7csQGApbg8QLiHMtcYEmWNzKZpkqg4nuAPxX VXwlKgnKX902SrET9Gp9TDayiHtCRWVfrlPPPSA0UEXW6BjLN/uHJ+W/Xzrrab+9 asBVa05vT2W6n0KJ66zfCaeDM912mQ6SttscAwFoWDmdHlegiVqrlIG2ABxOvxxz L3dM3iSmlmQlzv9bThjo+nI4KFYh6m5wrZmAo5r/4q9CIJc21HVnTqkGOWJIZz6J 73lePJVSq5gYqaoGw3swFEA/MDkOx7baWKSoLQIDAQABAoIBAQCNBeolNp+JWJ76 gQ4fwLsknyXSV6sxYyhkDW4PEwwcTU06uqce0AAzXVffxne0fMe48x47+zqBgPbb 4huM+Pu8B9nfojUMr5TaYtl9Zbgpk3F8H7dT7LKOa6XrxvZTZrADSRc30+Z26zPN e9zTaf42Gvt0/l0Zs1BHwbaOXqO+XuwJ3/F9Sf3PQYWXD3EOWjpHDP/X/1vAs6lV SLkm6J/9KKE1m6I6LTYjIXuYt4SXybW6N2TSy54hhQtYcDUnIU2hR/PHVWKrGA0J kELgrtTNTdbML27O5gFWU4PLUEYTZ9fN11D6qUZKxLcPOiPPHXkiILMRCCnG5DYI ksBAU/YlAoGBAPxZO9VO18TYc8THV1nLKcvT2+1oSs1UcA2wNQMU55t910ZYinRa MRwUhMOf8Mv5wOeiZaRICQB1PnVWtDVmGECgPpK6jUxqAwn8rgJcnoafLGL5YKMY RVafTe6N5LXgCaOcJrk21wxs6v7ninEbUxxc575urOvZMBkymDw91dwbAoGBAPwa YRhKhrzFKZzdK0RadVjnxKvolUllpoqqg3XuvmeAJHAOAnaOgVWq68NAcp5FZJv0 2D2Up7TX8pjf9MofP1SJbcraKBpK4NzfNkA0dSdEi+FhVofAJ9umB2o5LW1n7sab UIrjsdzSJK/9Zb9yTTHPyibYzNEgaJV1HsbxfEFXAoGAYO2RmvRm0phll18OQVJV IpKk9kLKAKZ/R/K32hAsikBC8SVPQTPniyaifFWx81diblalff2hX4ipTf7Yx24I wMIMZuW7Im/R7QMef4+94G3Bad7p7JuE/qnAEHJ2OBnu+eYfxaK35XDsrq6XMazS NqHE7hOq3giVfgg+C12hCKMCgYEAtu9dbYcG5owbehxzfRI2/OCRsjz/t1bv1seM xVMND4XI6xb/apBWAZgZpIFrqrWoIBM3ptfsKipZe91ngBPUnL9s0Dolx452RVAj yctHB8uRxWYgqDkjsxtzXf1HnZBBkBS8CUzYj+hdfuddoeKLaY3invXLCiV+PpXS U4KAK9kCgYEAtSv0m5+Fg74BbAiFB6kCh11FYkW94YI6B/E2D/uVTD5dJhyEUFgZ cWsudXjMki8734WSpMBqBp/J8wG3C9ZS6IpQD+U7UXA+roB7Qr+j4TqtWfM+87Rh maOpG56uAyR0w5Z9BhwzA3VakibVk9KwDgZ29WtKFzuATLFnOtCS46E= -----END RSA PRIVATE KEY----- EOF chmod 600 ${VIRL_PKEY} # # The server must be reachable and have a "status" file with # the content "PRODUCTION" to be selected. # # If the server is not reachable or does not have the correct # status remove it from the array and start again. # # Abort if there are no more servers left in the array. # VIRL_PROD_SERVERS=() for index in "${!VIRL_SERVERS[@]}"; do virl_server_status=$(ssh ${SSH_OPTIONS} ${VIRL_USERNAME}@${VIRL_SERVERS[$index]} cat $VIRL_SERVER_STATUS_FILE 2>&1) echo VIRL HOST ${VIRL_SERVERS[$index]} status is \"$virl_server_status\" if [ "$virl_server_status" == "$VIRL_SERVER_EXPECTED_STATUS" ] then # Candidate is in good status. Add to array. VIRL_PROD_SERVERS+=(${VIRL_SERVERS[$index]}) fi done VIRL_SERVERS=("${VIRL_PROD_SERVERS[@]}") echo "VIRL servers in production: ${VIRL_SERVERS[@]}" num_hosts=${#VIRL_SERVERS[@]} if [ $num_hosts == 0 ] then echo "No more VIRL candidate hosts available, failing." exit 127 fi # Get the LOAD of each server based on number of active simulations (testcases) VIRL_SERVER_LOAD=() for index in "${!VIRL_SERVERS[@]}"; do VIRL_SERVER_LOAD[${index}]=$(ssh ${SSH_OPTIONS} ${VIRL_USERNAME}@${VIRL_SERVERS[$index]} "list-testcases | grep session | wc -l") done # Pick for each TEST_GROUP least loaded server VIRL_SERVER=() for index in "${!TEST_GROUPS[@]}"; do least_load_server_idx=$(echo "${VIRL_SERVER_LOAD[*]}" | tr -s ' ' '\n' | awk '{print($0" "NR)}' | sort -g -k1,1 | head -1 | cut -f2 -d' ') least_load_server=${VIRL_SERVERS[$least_load_server_idx-1]} VIRL_SERVER+=($least_load_server) # Adjusting load as we are not going run simulation immediately VIRL_SERVER_LOAD[$least_load_server_idx-1]=$((VIRL_SERVER_LOAD[$least_load_server_idx-1]+1)) done echo "Selected VIRL servers: ${VIRL_SERVER[@]}" # Temporarily download DPDK packages DMM_TAR_FILE="dmm_depends.tar.gz" cd dmm/scripts/ ./build.sh all cd - DPDK_DOWNLOAD_PATH=$(cat dmm/scripts/build_dpdk.sh | grep DPDK_DOWNLOAD_PATH= | cut -d "=" -f2) mv $DPDK_DOWNLOAD_PATH/dpdk-18.02.tar.xz . wget http://security.ubuntu.com/ubuntu/pool/main/n/numactl/libnuma1_2.0.11-1ubuntu1.1_amd64.deb wget http://security.ubuntu.com/ubuntu/pool/main/n/numactl/libnuma-dev_2.0.11-1ubuntu1.1_amd64.deb wget http://security.ubuntu.com/ubuntu/pool/main/e/ethtool/ethtool_4.5-1_amd64.deb wget http://security.ubuntu.com/ubuntu/pool/main/l/lsof/lsof_4.89+dfsg-0.1_amd64.deb tar zcf ${DMM_TAR_FILE} dpdk-18.02.tar.xz ./dmm/ libnuma*.deb VIRL_DIR_LOC="/tmp" cat ${VIRL_PKEY} # Copy the files to VIRL hosts DONE="" for index in "${!VIRL_SERVER[@]}"; do # Do not copy files in case they have already been copied to the VIRL host [[ "${DONE[@]}" =~ "${VIRL_SERVER[${index}]}" ]] && copy=0 || copy=1 if [ "${copy}" -eq "0" ]; then echo "DMM_TAR_FILE has already been copied to the VIRL host ${VIRL_SERVER[${index}]}" else scp ${SSH_OPTIONS} ${DMM_TAR_FILE} \ ${VIRL_USERNAME}@${VIRL_SERVER[${index}]}:${VIRL_DIR_LOC}/ result=$? if [ "${result}" -ne "0" ]; then echo "Failed to copy DMM_TAR_FILE to VIRL host ${VIRL_SERVER[${index}]}" echo ${result} exit ${result} else echo "DMM_TAR_FILE successfully copied to the VIRL host ${VIRL_SERVER[${index}]}" fi DONE+=(${VIRL_SERVER[${index}]}) fi done # Start a simulation on VIRL server function stop_virl_simulation { for index in "${!VIRL_SERVER[@]}"; do ssh ${SSH_OPTIONS} ${VIRL_USERNAME}@${VIRL_SERVER[${index}]}\ "stop-testcase ${VIRL_SID[${index}]}" done } # Upon script exit, cleanup the simulation execution trap stop_virl_simulation EXIT for index in "${!VIRL_SERVER[@]}"; do echo "Starting simulation nr. ${index} on VIRL server ${VIRL_SERVER[${index}]}" # Get given VIRL server limits for max. number of VMs and IPs max_ips=$(get_max_ip_nr ${VIRL_SERVER[${index}]}) max_ips_from_sims=$(($(get_max_sim_nr ${VIRL_SERVER[${index}]})*IPS_PER_SIMULATION)) # Set quota to lower value IP_QUOTA=$([ $max_ips -le $max_ips_from_sims ] && echo "$max_ips" || echo "$max_ips_from_sims") # Start the simulation VIRL_SID[${index}]=$(ssh ${SSH_OPTIONS} \ ${VIRL_USERNAME}@${VIRL_SERVER[${index}]} \ "start-testcase-DMM -vv --quota ${IP_QUOTA} --copy ${VIRL_TOPOLOGY} \ --release ${VIRL_RELEASE} ${VIRL_DIR_LOC}/${DMM_TAR_FILE}") # TODO: remove param ${DMM_TAR_FILE} when start-testcase script is # updated on all virl servers retval=$? if [ ${retval} -ne "0" ]; then echo "VIRL simulation start failed on ${VIRL_SERVER[${index}]}" exit ${retval} fi if [[ ! "${VIRL_SID[${index}]}" =~ session-[a-zA-Z0-9_]{6} ]]; then echo "No VIRL session ID reported." exit 127 fi echo "VIRL simulation nr. ${index} started on ${VIRL_SERVER[${index}]}" ssh_do ${VIRL_USERNAME}@${VIRL_SERVER[${index}]}\ cat /scratch/${VIRL_SID[${index}]}/topology.yaml # Download the topology file from VIRL session and rename it scp ${SSH_OPTIONS} \ ${VIRL_USERNAME}@${VIRL_SERVER[${index}]}:/scratch/${VIRL_SID[${index}]}/topology.yaml \ topologies/enabled/topology${index}.yaml retval=$? if [ ${retval} -ne "0" ]; then echo "Failed to copy topology file from VIRL simulation nr. ${index} on VIRL server ${VIRL_SERVER[${index}]}" exit ${retval} fi done echo ${VIRL_SID[@]} virtualenv --system-site-packages env . env/bin/activate echo pip install pip install -r ${SCRIPT_DIR}/requirements.txt for index in "${!VIRL_SERVER[@]}"; do pykwalify -s ${SCRIPT_DIR}/resources/topology_schemas/3_node_topology.sch.yaml \ -s ${SCRIPT_DIR}/resources/topology_schemas/topology.sch.yaml \ -d ${SCRIPT_DIR}/topologies/enabled/topology${index}.yaml \ -vvv if [ "$?" -ne "0" ]; then echo "Topology${index} schema validation failed." echo "However, the tests will start." fi done function run_test_set() { set +x OLDIFS=$IFS IFS="," nr=$(echo $1) rm -f ${LOG_PATH}/test_run${nr}.log exec &> >(while read line; do echo "$(date +'%H:%M:%S') $line" \ >> ${LOG_PATH}/test_run${nr}.log; done;) suite_str="" for suite in ${TEST_GROUPS[${nr}]}; do suite_str="${suite_str} --suite ${SUITE_PATH}.${suite}" done IFS=$OLDIFS echo "PYTHONPATH=`pwd` pybot -L TRACE -W 136\ -v TOPOLOGY_PATH:${SCRIPT_DIR}/topologies/enabled/topology${nr}.yaml \ ${suite_str} \ --include vm_envAND3_node_single_link_topo \ --include vm_envAND3_node_double_link_topo \ --exclude PERFTEST \ --exclude ${SKIP_PATCH} \ --noncritical EXPECTED_FAILING \ --output ${LOG_PATH}/log_test_set_run${nr} \ tests/" PYTHONPATH=`pwd` pybot -L TRACE -W 136\ -v TOPOLOGY_PATH:${SCRIPT_DIR}/topologies/enabled/topology${nr}.yaml \ ${suite_str} \ --include vm_envAND3_node_single_link_topo \ --include vm_envAND3_node_double_link_topo \ --exclude PERFTEST \ --exclude ${SKIP_PATCH} \ --noncritical EXPECTED_FAILING \ --output ${LOG_PATH}/log_test_set_run${nr} \ tests/ local local_run_rc=$? set -x echo ${local_run_rc} > ${LOG_PATH}/rc_test_run${nr} } set +x # Send to background an instance of the run_test_set() function for each number, # record the pid. for index in "${!VIRL_SERVER[@]}"; do run_test_set ${index} & pid=$! echo "Sent to background: Test_set${index} (pid=$pid)" pids[$pid]=$index done echo echo -n "Waiting..." # Watch the stable of background processes. # If a pid goes away, remove it from the array. while [ -n "${pids[*]}" ]; do for i in $(seq 0 9); do sleep 1 echo -n "." done for pid in "${!pids[@]}"; do if ! ps "$pid" >/dev/null; then echo -e "\n" echo "Test_set${pids[$pid]} with PID $pid finished." unset pids[$pid] fi done if [ -z "${!pids[*]}" ]; then break fi echo -n -e "\nStill waiting for test set(s): ${pids[*]} ..." done echo echo "All test set runs finished." echo set -x RC=0 for index in "${!VIRL_SERVER[@]}"; do echo "Test_set${index} log:" cat ${LOG_PATH}/test_run${index}.log RC_PARTIAL_RUN=$(cat ${LOG_PATH}/rc_test_run${index}) if [ -z "$RC_PARTIAL_RUN" ]; then echo "Failed to retrieve return code from test run ${index}" exit 1 fi RC=$((RC+RC_PARTIAL_RUN)) rm -f ${LOG_PATH}/rc_test_run${index} rm -f ${LOG_PATH}/test_run${index}.log echo done # Log the final result if [ "${RC}" -eq "0" ]; then set +x echo echo "========================================================================================================================================" echo "Final result of all test loops: | PASS |" echo "All critical tests have passed." echo "========================================================================================================================================" echo set -x else if [ "${RC}" -eq "1" ]; then HLP_STR="test has" else HLP_STR="tests have" fi set +x echo echo "========================================================================================================================================" echo "Final result of all test loops: | FAIL |" echo "${RC} critical ${HLP_STR} failed." echo "========================================================================================================================================" echo set -x fi echo Post-processing test data... partial_logs="" for index in "${!VIRL_SERVER[@]}"; do partial_logs="${partial_logs} ${LOG_PATH}/log_test_set_run${index}.xml" done # Rebot output post-processing rebot --noncritical EXPECTED_FAILING \ --output output.xml ${partial_logs} # Remove unnecessary log files rm -f ${partial_logs} # Archive JOB artifacts in jenkins for i in ${JOB_ARCHIVE_ARTIFACTS[@]}; do cp $( readlink -f ${i} | tr '\n' ' ' ) ${JOB_ARCHIVE_DIR}/ done # Archive JOB artifacts to logs.fd.io for i in ${LOG_ARCHIVE_ARTIFACTS[@]}; do cp $( readlink -f ${i} | tr '\n' ' ' ) ${LOG_ARCHIVE_DIR}/ done echo Post-processing finished. if [ ${RC} -eq 0 ]; then RETURN_STATUS=0 else RETURN_STATUS=1 fi exit ${RETURN_STATUS}