]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
CI: Package tests including reuse of eapol_test tests in post-install context (#3789)
authorTerry Burton <tez@terryburton.co.uk>
Wed, 16 Dec 2020 20:11:23 +0000 (20:11 +0000)
committerGitHub <noreply@github.com>
Wed, 16 Dec 2020 20:11:23 +0000 (14:11 -0600)
* 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

.github/workflows/ci-deb.yml
.github/workflows/ci-rpm.yml
scripts/ci/package-test.mk [new file with mode: 0644]
src/tests/eapol_test/all.mk

index 031fb93f0c61993e886a6f95e58ed570d80c9582..5846ffd1dcbbd46e988654fe832e3b0d85677038 100644 (file)
@@ -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
index 456bc45105399def8471b72d99049cdb50f52020..67c5bfc5f53ba3af00befa85d5bfb8bce5de3a8f 100644 (file)
@@ -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 (file)
index 0000000..1d0a871
--- /dev/null
@@ -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
index 7f917b01268503c64624b0ffdb387df7502c4e11..c74d5f96104ed6c7b504cfcfa029ac20fd10fcd5 100644 (file)
@@ -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)