Testing in Github

Introduction

This guide is intended for XMPP Server developers who are building on Github Actions. It demonstrates how to add XMPP Interoperability and Standards Conformance tests integrated into a build & test pipeline. This assumes that you already have a pipeline established, and wish to add the additional checks.

The checks run as their own action within the pipeline, in which they’ll execute tests and output junit-esque and debugging output. The only prerequisite is that you’ve got a built server and have started it.

Assuming that you have a pre-existing pipeline that build your server and starts it for integration testing, then adding our Github Action is as easy as adding one step to your pipeline, like this:

- name: Run XMPP Interoperability Tests against CI server.
  uses: XMPP-Interop-Testing/xmpp-interop-tests-action@v1.6.0
  with:
    domain: 'shakespeare.lit'
    adminAccountUsername: 'juliet'
    adminAccountPassword: 'O_Romeo_Romeo!'

This example demonstrates one possible way to provision accounts. It assumes your server is running and accessible at shakespeare.lit, and that it already has an administrative account (one that is allowed to create other users, per XEP-0133) that uses the username juliet and the provided password. Other configuration methods are also available, and you can explore the full set of options in the sections below.

A Full Example

Assume that you have a pre-existing build pipeline that looks like this for building an XMPP server called “eXaMPPle”:

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Java
        uses: actions/setup-java@v4
      - name: Build with Maven
        run: mvn package
      - name: Stash the built artifacts
        uses: actions/upload-artifact@v4
        with:
          name: eXaMPPle
          path: target/example.jar

Here, you check out the code, set up some tooling, then run a process that builds, unit tests and produces a binary output, which we then archive as an artifact.

A second job that may already exist uses the build output, and launches a server to be used for integration testing.

  test:
    name: Compliance Tests
    needs: build # Sequential, not parallel to the build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout convenience scripts
        uses: actions/checkout@v4
        with:
          sparse-checkout: |
            ci-scripts

      - name: Download distribution artifact from build job
        uses: actions/download-artifact@v4
        with:
          name: eXaMPPle
          path: .

      - name: Start server from build job
        id: startServer
        uses: ./ci-scripts/launch-server # Launch the eXaMPPle server with test configs

      - name: Run eXaMMple integration tests against CI server
        run: ./ci-scripts/execute-tests # Run tests that already existed in your pipeline

We’ve added a second job to the end of the first which fetches a launch script and the freshly-built binary, runs the launch script to run the eXaMPPle server in the background, then calls some script to run whatever tests that you already had in your project.

The above combines into a pipeline that you may already have in your project, or something that you would add in preparation of running our Interoperability Tests. It is all highly specific to your project.

To run our Interoperability Tests, only one step needs to be added to this:

      - name: Run XMPP Interoperability Tests against CI server.
        uses: XMPP-Interop-Testing/xmpp-interop-tests-action@v1.6.0
        with:
          domain: 'shakespeare.lit'
          adminAccountUsername: 'juliet'
          adminAccountPassword: 'O_Romeo_Romeo!'

This step will use our Github Action to run the XMPP Interoperability Tests against your server. Look below for additional configuration options.

For completeness, here is the full pipeline, combining everything above:

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Java
        uses: actions/setup-java@v4
      - name: Build with Maven
        run: mvn package
      - name: Stash the built artifacts
        uses: actions/upload-artifact@v4
        with:
          name: eXaMPPle
          path: target/example.jar

  test:
    name: Compliance Tests
    needs: build # Sequential, not parallel to the build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout convenience scripts
        uses: actions/checkout@v4
        with:
          sparse-checkout: |
            ci-scripts

      - name: Download distribution artifact from build job
        uses: actions/download-artifact@v4
        with:
          name: eXaMPPle
          path: .

      - name: Start server from build job
        id: startServer
        uses: ./ci-scripts/launch-server # Launch the eXaMPPle server with test configs

      - name: Run eXaMMple integration tests against CI server
        run: ./ci-scripts/execute-tests # Run tests that already existed in your pipeline

      - name: Run XMPP Interoperability Tests against CI server
        uses: XMPP-Interop-Testing/xmpp-interop-tests-action@v1.6.0
        with:
          domain: 'shakespeare.lit'
          adminAccountUsername: 'juliet'
          adminAccountPassword: 'O_Romeo_Romeo!'

Configuration

Various options are available when calling xmpp_interop_tests_action, and whilst none of them are absolutely required, the defaults are unlikely to be perfect for everyone.

For the latest updates to the documentation of the configuration updates, consult the GitHub repository of the GitHub Action.

Option Description Default value
host IP address or DNS name of the XMPP service to run the tests on. 127.0.0.1
domain the XMPP domain name of server under test. example.org
timeout the amount of milliseconds after which an XMPP action (typically an IQ request) is considered timed out. 5000 (five seconds)
adminAccountUsername (optional) The account name of a pre-existing user that is allowed to create other users, per XEP-0133. See: “Provisioning Test Accounts -
adminAccountPassword (optional) The password of the admin account -
accountOneUsername (optional) The first account name of a set of three accounts used for testing. See: “Provisioning Test Accounts -
accountOnePassword (optional) The password of the accountOneUsername account. -
accountTwoUsername (optional) The second account name of a set of three accounts used for testing. See: “Provisioning Test Accounts -
accountTwoPassword (optional) The password of the accountTwoUserName account -
accountThreeUsername (optional) The third account name of a set of three accounts used for testing. See: “Provisioning Test Accounts -
accountThreePassword (optional) The password of the accountThreeUserName account -
disabledTests (optional) A comma-separated list of tests that are to be skipped. For example: EntityCapsTest,SoftwareInfoIntegrationTest -
disabledSpecifications (optional) A comma-separated list of specifications (not case-sensitive) that are to be skipped. For example: XEP-0045,XEP-0060 -
enabledTests (optional) A comma-separated list of tests that are the only ones to be run. For example: EntityCapsTest,SoftwareInfoIntegrationTest -
enabledSpecifications (optional) A comma-separated list of specifications (not case-sensitive) that are the only ones to be run. For example: XEP-0045,XEP-0060 -
logDir (optional) The directory in which the test output and logs are to be stored. This directory will be created, if it does not already exist. ./output

Provisioning Test Accounts

To be able to run the tests, the server that is being tested needs to be provisioned with test accounts. Three different mechanisms can be used for this:

  • Admin Account - By configuring the username and password of a pre-existing administrative user, using the adminAccountUsername and adminAccountPassword configuration options, three test accounts will be created using XEP-0133: Service Administration functionality.
  • Explicit Test Accounts - You can configure three pre-existing accounts that will be used for testing, using the accountOneUsername, accountOnePassword, accountTwoUsername, accountTwoPassword, accountThreeUsername and accountThreePassword configuration options.
  • In-Band Registration - If no admin account and no explicit tests accounts are provided, in-band registration (XEP-0077) will be used to provision accounts.

For more information on provisioning accounts, consult the ‘Test Account Provisioning’ guide.

Next steps

Now that you have integrated the XMPP Interoperability and Standards Conformance tests into your build pipeline, it is time to start working with the tests!

We’ve compiled the following resources to help you with any run-time challenges that you may run into:

  • Choosing what test to run - helps you choose how to disable specific tests (useful when you want to ignore a particular test for some reason).
  • Diagnose test failures - explains what you can do to find the reason that test is failing. Did we identify an issue in your server software? Find out!

Splash image courtesy of Roman Synkevych, Unsplash