---
- project:
    name: 'ttcn3-testsuites'
    concurrent: false
    disabled: false
    description: |
        Run the a testsuite from
        <a href="https://gitea.osmocom.org/osmocom/docker-playground">
          docker-playground.git</a>.<br>
        If this job ends in <code>-latest</code>, the job runs the latest
        stable versions of the Osmocom stack. Otherwise the nightly builds.<br>
        See <a href="https://osmocom.org/projects/cellular-infrastructure/wiki/Titan_TTCN3_Testsuites">
            TTCN3 Testsuite</a> for more information.
    timer: "@midnight"
    node: ttcn3
    wipe_workspace: true
    jobs:
      - "{job-name}"
    # Folders from docker-playground.git
    # timer: 10 per hour from 04:00 - 18:00, see jobs/README.adoc
    job-name:
      # debian nightly - order by time
      - ttcn3-msc-test:
          timer: H 03 * * *
      - nplab-m3ua-test:
          timer: H 04 * * *
      - nplab-sua-test:
          timer: H 04 * * *
      - ttcn3-ggsn-test:
          timer: H 04 * * *
      - ttcn3-ggsn-test-kernel:
          timer: H 04 * * *
          description: |
            Test osmo-ggsn master with the Debian kernel.
      - ttcn3-ggsn-test-kernel-net-next:
          timer: H 04 * * *
          # Cache the linux source tree in the workspace of one node
          wipe_workspace: false
          node: ttcn3-ggsn-test-kernel-git
          description: |
            Test osmo-ggsn master with the Linux kernel built from master of
            <a href="https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/">
              net-next.git</a>.
      - ttcn3-ggsn-test-kernel-torvalds:
          timer: H 04 * * *
          # Cache the linux source tree in the workspace of one node
          wipe_workspace: false
          node: ttcn3-ggsn-test-kernel-git
          description: |
            Test osmo-ggsn master with the Linux kernel built from master of
            <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/">
              torvalds/linux.git</a>.
      - ttcn3-ggsn-test-kernel-latest:
          timer: H 04 * * *
          description: |
            Test osmo-ggsn latest with the Debian kernel.
      - ttcn3-ggsn-test-kernel-latest-net-next:
          timer: H 04 * * *
          # Cache the linux source tree in the workspace of one node
          wipe_workspace: false
          node: ttcn3-ggsn-test-kernel-git
          description: |
            Test osmo-ggsn latest with the Linux kernel built from master of
            <a href="https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/">
              net-next.git</a>.
      - ttcn3-ggsn-test-kernel-latest-torvalds:
          timer: H 04 * * *
          # Cache the linux source tree in the workspace of one node
          wipe_workspace: false
          node: ttcn3-ggsn-test-kernel-git
          description: |
            Test osmo-ggsn latest with the Linux kernel built from master of
            <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/">
              torvalds/linux.git</a>.
      - ttcn3-ggsn-test-ogs:
          timer: H 04 * * *
          description: |
            Test open5gs-smfd + open5gs-upfd main.
          email: jenkins-notifications@lists.osmocom.org acetcom@gmail.com
      - ttcn3-pcu-test:
          timer: H 04 * * *
      - ttcn3-pcu-test-sns:
          timer: H 05 * * *
      - ttcn3-bsc-test:
          timer: H 05 * * *
      - ttcn3-bts-test:
          timer: H 05 * * *
      - ttcn3-bscnat-test:
          timer: H 05 * * *
          disabled: true
      - ttcn3-bsc-test-sccplite:
          timer: H 05 * * *
      - ttcn3-remsim-test:
          timer: H 05 * * *
      - ttcn3-stp-test:
          timer: H 06 * * *
      - ttcn3-sccp-test:
          timer: H 06 * * *
      - ttcn3-gbproxy-test:
          timer: H 06 * * *
      - ttcn3-gbproxy-test-fr:
          timer: H 06 * * *
          node: hdlc
      - ttcn3-ns-test:
          timer: H 06 * * *
      - ttcn3-ns-test-sns:
          timer: H 06 * * *
      - ttcn3-ns-test-fr:
          timer: H 06 * * *
          node: hdlc
      - ttcn3-ns-test-sgsn-sns:
          timer: H 06 * * *
      - ttcn3-pcap-client-test:
          timer: H 07 * * *
      - ttcn3-bsc-test-vamos:
          timer: H 07 * * *
      - ttcn3-hnbgw-test:
          timer: H 07 * * *
      - ttcn3-fr-test:
          timer: H 07 * * *
          node: hdlc
      - ttcn3-pgw-test:
          timer: H 07 * * *
          description: |
            Test open5gs-smfd + open5gs-upfd PGW main.
          email: jenkins-notifications@lists.osmocom.org acetcom@gmail.com
      - ttcn3-epdg-test:
          timer: H 07 * * *
          # osmo-epdg requires OTP and kernel >= debian12:
          node: build4-deb12build-ansible
      - ttcn3-s1gw-test:
          timer: H 07 * * *
          # osmo-s1gw requires OTP and kernel >= debian12:
          node: build4-deb12build-ansible
      - ttcn3-asterisk-ims-ue-test:
          timer: H 07 * * *

      # debian latest stable
      - nplab-m3ua-test-latest:
          timer: H 07 * * *
      - nplab-sua-test-latest:
          timer: H 08 * * *
      - ttcn3-ggsn-test-latest:
          timer: H 08 * * *
      - ttcn3-msc-test-latest:
          timer: H 08 * * *
      - ttcn3-pcu-test-latest:
          timer: H 08 * * *
      - ttcn3-pcu-test-sns-latest:
          timer: H 08 * * *
      - ttcn3-bsc-test-latest:
          timer: H 08 * * *
      - ttcn3-bts-test-latest:
          timer: H 08 * * *
      - ttcn3-bscnat-test-latest:
          timer: H 09 * * *
          disabled: true
      - ttcn3-bsc-test-sccplite-latest:
          timer: H 09 * * *
      - ttcn3-remsim-test-latest:
          timer: H 09 * * *
      - ttcn3-stp-test-latest:
          timer: H 09 * * *
      - ttcn3-sccp-test-latest:
          timer: H 09 * * *
      - ttcn3-gbproxy-test-latest:
          timer: H 09 * * *
      - ttcn3-gbproxy-test-fr-latest:
          timer: H 09 * * *
          node: hdlc
      - ttcn3-pcap-client-test-latest:
          timer: H 10 * * *
      - ttcn3-hnbgw-test-latest:
          timer: H 10 * * *
      - ttcn3-epdg-test-latest:
          timer: H 07 * * *
          # osmo-epdg requires OTP and kernel >= debian12:
          node: build4-deb12build-ansible

      # Jobs below use uppercase TTCN3-$DISTRO, so they get listed separately from the ttcn3-* (debian) jobs

      # centos7 nightly
      - TTCN3-centos7-pcap-client-test:
          timer: H 10 * * *

      # centos7 latest
      - TTCN3-centos7-pcap-client-test-latest:
          timer: H 10 * * *

      # With LIBOSMO_IO_BACKEND=IO_URING (OS#6357)
      - ttcn3-bsc-test-io_uring:
          timer: H 11 * * *
          node: ttcn3_with_linux_6.1_or_higher  # Runs out of memory on others (OS#6405)
      - ttcn3-msc-test-io_uring:
          timer: H 11 * * *
      - ttcn3-hnbgw-test-io_uring:
          timer: H 11 * * *
      - ttcn3-gbproxy-test-io_uring:
          timer: H 11 * * *
      - ttcn3-stp-test-io_uring:
          timer: H 11 * * *
      - ttcn3-bts-test-io_uring:
          timer: H 11 * * *

      # With sanitizer (OS#5301)
      - ttcn3-bsc-test-asan:
          timer: H 12 * * *
      - ttcn3-bts-test-asan:
          timer: H 12 * * *
      - ttcn3-gbproxy-test-asan:
          timer: H 12 * * *
      - ttcn3-ggsn-test-asan:
          timer: H 12 * * *
      - ttcn3-hnbgw-test-asan:
          timer: H 12 * * *
      - ttcn3-msc-test-asan:
          timer: H 13 * * *
      - ttcn3-pcap-client-test-asan:
          timer: H 13 * * *
      - ttcn3-pcu-test-asan:
          timer: H 13 * * *
      - ttcn3-remsim-test-asan:
          timer: H 13 * * *
      - ttcn3-sccp-test-asan:
          timer: H 13 * * *
      - ttcn3-stp-test-asan:
          timer: H 13 * * *


- job-template:
    name: '{job-name}'
    project-type: freestyle
    disabled: '{obj:disabled}'
    defaults: global
    description: '{obj:description}'
    node: '{obj:node}'
    parameters:
      - string:
          name: BRANCH
          description: |
                Branch of <code>docker-playground.git</code>.
                Only modify if you are hacking on the docker-playground scripts.
          default: '*/master'
    builders:
      - shell: |-
          export REGISTRY_HOST="registry.osmocom.org"

          # Translate job name to docker-playground dir and relevant
          # environment variables
          case "{job-name}" in
              ttcn3-ggsn-test-kernel)
                  DIR="ttcn3-ggsn-test"
                  export IMAGE_SUFFIX="master"
                  # Run against debian's kernel
                  export KERNEL_TEST=1
                  ;;
              ttcn3-ggsn-test-kernel-net-next)
                  DIR="ttcn3-ggsn-test"
                  export IMAGE_SUFFIX="master"
                  export KERNEL_TEST=1
                  export KERNEL_BUILD=1
                  export KERNEL_URL="https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git"
                  export KERNEL_REMOTE_NAME="net-next"
                  export KERNEL_BRANCH="main"
                  ;;
              ttcn3-ggsn-test-kernel-torvalds)
                  DIR="ttcn3-ggsn-test"
                  export IMAGE_SUFFIX="master"
                  export KERNEL_TEST=1
                  export KERNEL_BUILD=1
                  export KERNEL_URL="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git"
                  export KERNEL_REMOTE_NAME="torvalds"
                  export KERNEL_BRANCH="master"
                  ;;
              ttcn3-ggsn-test-kernel-latest)
                  DIR="ttcn3-ggsn-test"
                  export IMAGE_SUFFIX="latest"
                  export KERNEL_TEST=1
                  ;;
              ttcn3-ggsn-test-kernel-latest-net-next)
                  DIR="ttcn3-ggsn-test"
                  export IMAGE_SUFFIX="latest"
                  export KERNEL_TEST=1
                  export KERNEL_BUILD=1
                  export KERNEL_URL="https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git"
                  export KERNEL_REMOTE_NAME="net-next"
                  export KERNEL_BRANCH="main"
                  ;;
              ttcn3-ggsn-test-kernel-latest-torvalds)
                  DIR="ttcn3-ggsn-test"
                  export IMAGE_SUFFIX="latest"
                  export KERNEL_TEST=1
                  export KERNEL_BUILD=1
                  export KERNEL_URL="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git"
                  export KERNEL_REMOTE_NAME="torvalds"
                  export KERNEL_BRANCH="master"
                  ;;
              TTCN3-centos7-*-latest)
                  DIR="$(echo "{job-name}" | sed s/^TTCN3-centos7\-/ttcn3-/ | sed s/\-latest$//)"
                  export IMAGE_SUFFIX="latest-centos7"
                  ;;
              TTCN3-centos7-*)
                  DIR="$(echo "{job-name}" | sed s/^TTCN3-centos7\-/ttcn3-/)"
                  export IMAGE_SUFFIX="master-centos7"
                  ;;
              *-asan)
                  DIR="$(echo "{job-name}" | sed s/\-asan$//)"
                  export IMAGE_SUFFIX="asan"
                  export OSMOCOM_REPO_VERSION="asan"
                  ;;
              *-io_uring)
                  DIR="$(echo "{job-name}" | sed s/\-io_uring$//)"
                  # OS#6405: set memlock to unlimited for older kernels and
                  # enable io_uring syscalls in the seccomp profile
                  export DOCKER_ARGS="
                    -e LIBOSMO_IO_BACKEND=IO_URING
                    --ulimit memlock=-1
                    --security-opt seccomp=../seccomp_profile.json
                  "
                  ;;
              *-latest)
                  DIR="$(echo "{job-name}" | sed s/\-latest$//)"
                  export IMAGE_SUFFIX="latest"
                  ;;
              *)
                  DIR="{job-name}"
                  export IMAGE_SUFFIX="master"
                  ;;
          esac

          cd "$DIR"
          ./jenkins.sh
    scm:
      - git:
          branches:
            - '$BRANCH'
          url: https://gerrit.osmocom.org/docker-playground
          git-config-name: 'Jenkins Builder'
          git-config-email: 'jenkins@osmocom.org'
          wipe-workspace: "{obj:wipe_workspace}"
    triggers:
      - timed: "{obj:timer}"
    publishers:
      - junit:
          results: '**/junit-xml-*.log'
          allow-empty-results: false
      - email:
          notify-every-unstable-build: false
          recipients: '{obj:email}'
          send-to-individuals: false
      - archive:
          allow-empty: false
          artifacts: logs/**/*
          case-sensitive: true
          default-excludes: true
          fingerprint: false
          only-if-success: false
    properties:
    - build-discarder:
        days-to-keep: 30
        num-to-keep: 120
    wrappers:
    - ansicolor:
        colormap: xterm
    email: jenkins-notifications@lists.osmocom.org

# vim: expandtab tabstop=2 shiftwidth=2
