nginx-vm-tests/nginx.sh

98 lines
2.1 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
dirn=$(dirname "$0")
source $dirn/common.sh
if [[ ! -f $dirn/SECRET.sh ]]; then
error "need to create SECRET.sh... see Readme"
exit 1
fi
source $dirn/SECRET.sh
# function that helps set parallelism in builds
# needs to strictly return 3 on VMs and strictly
# return a lot more on the hypervisor host.
function num_jobs() {
if [ ! $VM_PARALLEL ]; then
log "VM_PARALLEL not defined, defaulting to 3"
VM_PARALLEL=3
fi
if [ ! $HOST_PARALLEL ]; then
log "HOST_PARALLEL not defined, defaulting to 22"
HOST_PARALLEL=22
fi
which virsh >/dev/null && echo $HOST_PARALLEL || echo $VM_PARALLEL
}
# The following functions are all run on a VM
# Through an SSH connection. Make sure not to
# use any external functions in them.
function build_nginx() {
auto/configure \
--with-threads \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_v3_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_stub_status_module \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_ssl_preread_module \
--with-debug
make -j$(num_jobs)
}
function test_nginx() {
TEST_NGINX_VERBOSE=1 \
TEST_NGINX_CATLOG=1 \
prove -vw -j$(num_jobs) .
}
function clean_nginx() {
make clean
}
function build_otel() {
BSDFLG=""
if [[ $(uname) == "FreeBSD" ]] || [[ "$(grep "Fedora" /etc/issue)" ]]; then
BSDFLG="-DNGX_OTEL_GRPC=package"
fi
if [[ -d build ]]; then
rm -rf build
fi
mkdir -p build
cd build
cmake -DCMAKE_CXX_COMPILER=$(which g++) \
-DNGX_OTEL_NGINX_BUILD_DIR=../../nginx/objs \
$BSDFLG \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-D_LARGEFILE64_SOURCE" ..
make -j$(num_jobs)
}
function test_otel() {
pip install --break-system-packages -r tests/requirements.txt
pytest tests --maxfail=10 --nginx=../nginx/objs/nginx \
--module=build/ngx_otel_module.so
}
function clean_otel() {
rm -rf build
}