From: Terry Burton Date: Wed, 16 Dec 2020 20:11:23 +0000 (+0000) Subject: CI: Package tests including reuse of eapol_test tests in post-install context (#3789) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8f6a36d4986bb9442189169270066f6de1fcd5cc;p=thirdparty%2Ffreeradius-server.git CI: Package tests including reuse of eapol_test tests in post-install context (#3789) * CI: Package tests reusing eapol_test tests in post-install context * Allow eapol_test tests to be run in post-install context We want to minimise the requirements for the post-install environment so we use a simple top level Makefile to set things up. * Remove in-workflow checks for PAP and EAP-TLS auth --- diff --git a/.github/workflows/ci-deb.yml b/.github/workflows/ci-deb.yml index 031fb93f0c6..5846ffd1dcb 100644 --- a/.github/workflows/ci-deb.yml +++ b/.github/workflows/ci-deb.yml @@ -38,6 +38,10 @@ jobs: echo force-unsafe-io > /etc/dpkg/dpkg.cfg.d/02speedup echo 'man-db man-db/auto-update boolean false' | debconf-set-selections + # + # Required so that the checkout action uses git protocol rather than the GitHub REST API. + # make rpm requires the FR directory to be a git repository. + # - name: Install recent git run: | apt-get update @@ -85,6 +89,14 @@ jobs: mv libkqueue/*.deb debs mv *.deb debs + - name: Build eapol_test + run: | + apt-get install -y libnl-3-dev libnl-genl-3-dev + ./configure + make -j `nproc` eapol_test + mv scripts/ci/eapol_test/eapol_test ../debs + working-directory: freeradius + - name: Store DEBs uses: actions/upload-artifact@v2 with: @@ -116,6 +128,12 @@ jobs: steps: + # For pkill + - name: Install procps + run: | + apt-get update + apt-get install -y --no-install-recommends procps + - name: Load DEBs uses: actions/download-artifact@v2 with: @@ -128,10 +146,40 @@ jobs: - name: Install DEBs run: | - apt-get update find . -maxdepth 1 -name '*.deb' | xargs apt-get install -y --no-install-recommends - - name: Startup test + - name: Config test run: | freeradius -XC + # + # We now perform some post-install tests that depend on the availability + # of the source tree + # + - name: Install pre-built eapol_test + run: | + apt-get install -y libssl1.? libdbus-1-? libnl-3-200 libnl-genl-3-200 + mv eapol_test /usr/local/bin + chmod +x /usr/local/bin/eapol_test + + - uses: actions/checkout@v2 + with: + path: freeradius + + - name: Run the post-install test target + run: | + make -C raddb/certs + touch Make.inc + mkdir -p build/tests/eapol_test + echo "EAPOL_TEST=" $(which eapol_test) > build/tests/eapol_test/eapol_test.mk + make -f scripts/ci/package-test.mk package-test + working-directory: freeradius + + - name: Upload radius logs on failure + if: ${{ failure() }} + uses: actions/upload-artifact@v2 + with: + name: radius-logs-${{ matrix.env.NAME }}.tgz + path: | + /var/log/freeradius + freeradius/build/tests/eapol_test diff --git a/.github/workflows/ci-rpm.yml b/.github/workflows/ci-rpm.yml index 456bc451053..67c5bfc5f53 100644 --- a/.github/workflows/ci-rpm.yml +++ b/.github/workflows/ci-rpm.yml @@ -111,6 +111,7 @@ jobs: - name: Build RPMs run: | [ -r /opt/rh/devtoolset-8/enable ] && source /opt/rh/devtoolset-8/enable || : + ./configure make rpm working-directory: freeradius @@ -120,6 +121,14 @@ jobs: mv libkqueue/*.rpm rpms mv freeradius/rpmbuild/RPMS/x86_64/*.rpm rpms + - name: Build eapol_test + run: | + yum install -y libnl3-devel which + [ -r /opt/rh/devtoolset-8/enable ] && source /opt/rh/devtoolset-8/enable || : + make -j `nproc` eapol_test + mv scripts/ci/eapol_test/eapol_test ../rpms + working-directory: freeradius + - name: Store RPMs uses: actions/upload-artifact@v2 with: @@ -167,6 +176,12 @@ jobs: yum config-manager --enable PowerTools || : yum config-manager --enable powertools || : + # For pkill + - name: Enable procps-ng on Fedora + if: ${{ startsWith(matrix.env.NAME, 'fedora-') }} + run: | + yum install -y procps-ng + - name: Load RPMs uses: actions/download-artifact@v2 with: @@ -180,3 +195,34 @@ jobs: run: | radiusd -XC + # + # We now perform some post-install tests that depend on the availability + # of the source tree + # + - name: Install pre-built eapol_test + run: | + yum install -y libnl3 make gdb which + mv eapol_test /usr/local/bin + chmod +x /usr/local/bin/eapol_test + + - uses: actions/checkout@v2 + with: + path: freeradius + + - name: Run the post-install test target + run: | + make -C raddb/certs + touch Make.inc + mkdir -p build/tests/eapol_test + echo "EAPOL_TEST=" $(which eapol_test) > build/tests/eapol_test/eapol_test.mk + make -f scripts/ci/package-test.mk package-test + working-directory: freeradius + + - name: Upload radius logs on failure + if: ${{ failure() }} + uses: actions/upload-artifact@v2 + with: + name: radius-logs-${{ matrix.env.NAME }}.tgz + path: | + /var/log/radius + freeradius/build/tests/eapol_test diff --git a/scripts/ci/package-test.mk b/scripts/ci/package-test.mk new file mode 100644 index 00000000000..1d0a8716a60 --- /dev/null +++ b/scripts/ci/package-test.mk @@ -0,0 +1,53 @@ +# +# This Makefile performs some end to end tests against a package installed +# within the CI environment. +# +# It reuses the eapol_test build-time tests, but runs them against the assets +# installed by the distribution packaging. +# +# We want the run-time environment to be lean, typical of a fresh system +# installation so that we catch any missing runtime dependancies, assets +# missing from the packages, issues with the dynamic loader, etc. +# +# Therefore we skip the usual build framework so that we do not have so +# configure the build tree and so that our only dependency is some non-ancient +# version GNU Make. (Any version in a supported distribution will do.) +# + +ifeq "${VERBOSE}" "" + Q=@ +else + Q= +endif + + +# Provide what test.eap needs +top_srcdir:=. +BUILD_DIR:=build +DIR:=src/tests/eapol_test +OUTPUT:=$(BUILD_DIR)/tests/eapol_test + +ALL_TGTS:=$(addprefix rlm_eap_,$(notdir $(subst -,_,$(patsubst %.conf,%.la,$(wildcard $(DIR)/*.conf))))) + +# +# For the package tests we use the system version of radiusd on the standard +# port +# +RADIUSD_BIN:=$(shell which radiusd || which freeradius) +PORT:=1812 +SECRET:=testing123 + +# +# We assume a preinstalled version of eapol_test +# +EAPOL_TEST:=$(shell which eapol_test) + +# This Makefile, for meta-making +POST_INSTALL_MAKEFILE_ARG:=-f $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) + +POST_INSTALL_RADIUSD_BIN_ARG:=RADIUSD_BIN=$(RADIUSD_BIN) + +.PHONY: package-test +package-test: test.eap + +include $(DIR)/all.mk diff --git a/src/tests/eapol_test/all.mk b/src/tests/eapol_test/all.mk index 7f917b01268..c74d5f96104 100644 --- a/src/tests/eapol_test/all.mk +++ b/src/tests/eapol_test/all.mk @@ -87,8 +87,8 @@ test.eap.check: $(IGNORED_EAP_TYPES) | $(OUTPUT) $(GENERATED_CERT_FILES) # $(OUTPUT)/%.ok: $(DIR)/%.conf | $(GENERATED_CERT_FILES) @echo "EAPOL-TEST $(notdir $(patsubst %.conf,%,$<))" - ${Q}$(MAKE) --no-print-directory test.eap.radiusd_kill - ${Q}$(MAKE) --no-print-directory METHOD=$(basename $(notdir $@)) test.eap.radiusd_start + ${Q}$(MAKE) $(POST_INSTALL_MAKEFILE_ARG) --no-print-directory test.eap.radiusd_kill + ${Q}$(MAKE) $(POST_INSTALL_MAKEFILE_ARG) --no-print-directory METHOD=$(basename $(notdir $@)) test.eap.radiusd_start $(POST_INSTALL_RADIUSD_BIN_ARG) ${Q} [ -f $(dir $@)/radiusd.pid ] || exit 1 $(eval OUT := $(patsubst %.ok,%.log,$@)) $(eval KEY := $(shell grep key_mgmt=NONE $< | sed 's/key_mgmt=NONE/-n/')) @@ -100,15 +100,15 @@ $(OUTPUT)/%.ok: $(DIR)/%.conf | $(GENERATED_CERT_FILES) echo "Last entries in server log ($(RADIUS_LOG)):"; \ echo "--------------------------------------------------"; \ echo "$(EAPOL_TEST) -c \"$<\" -p $(PORT) -s $(SECRET)"; \ - $(MAKE) test.eap.radiusd_kill; \ + $(MAKE) $(POST_INSTALL_MAKEFILE_ARG) test.eap.radiusd_kill; \ echo "RADIUSD : OUTPUT=$(dir $@) TESTDIR=$(dir $<) METHOD=$(notdir $(patsubst %.conf,%,$<)) TEST_PORT=$(PORT) $(RADIUSD_BIN) -Pxxx -n servers -d $(dir $<)config -D share/dictionary/ -lstdout -f";\ echo "EAPOL : $(EAPOL_TEST) -c \"$<\" -p $(PORT) -s $(SECRET) $(KEY) "; \ echo " log is in $(OUT)"; \ rm -f $(BUILD_DIR)/tests/test.eap; \ - $(MAKE) --no-print-directory test.eap.radiusd_kill; \ + $(MAKE) $(POST_INSTALL_MAKEFILE_ARG) --no-print-directory test.eap.radiusd_kill; \ exit 1;\ fi - ${Q}$(MAKE) --no-print-directory test.eap.radiusd_stop + ${Q}$(MAKE) $(POST_INSTALL_MAKEFILE_ARG) --no-print-directory test.eap.radiusd_stop ${Q}touch $@ $(TEST): $(EAPOL_OK_FILES)