---
- 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
      - nplab-m3ua-test:  # ~1 min
          timer: H 03 * * *
      - nplab-sua-test:  # ~1 min
          timer: H 03 * * *
      - ttcn3-gbproxy-test:  # ~15 min
          timer: H 03 * * *
      - ttcn3-gbproxy-test-fr:  # ~26 min
          timer: H 03 * * *
          node: hdlc
      - ttcn3-ns-test-fr:  # ~10 min
          timer: H 04 * * *
          node: hdlc
      - ttcn3-fr-test:  # ~ 10 min
          timer: H 04 * * *
          node: hdlc
      - ttcn3-pgw-test:  # ~7 min
          timer: H 04 * * *
          description: |
            Test open5gs-smfd + open5gs-upfd PGW main.
          email: jenkins-notifications@lists.osmocom.org acetcom@gmail.com
      - ttcn3-epdg-test:  # ~4 min
          timer: H 04 * * *
          # osmo-epdg requires OTP and kernel >= debian12:
          node: build4-deb12build-ansible
      - ttcn3-asterisk-ims-ue-test:  # ~19 min
          timer: H 04 * * *

      # debian latest stable
      - nplab-m3ua-test-latest:  # ~1 min
          timer: H 04 * * *
      - nplab-sua-test-latest:  # ~1 min
          timer: H 04 * * *
      - ttcn3-gbproxy-test-latest:  # ~15 min
          timer: H 05 * * *
      - ttcn3-gbproxy-test-fr-latest:  # ~23 min
          timer: H 05 * * *
          node: hdlc
      - ttcn3-epdg-test-latest:  # ~5 min
          timer: H 05 * * *
          # 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:  # ~1 min
          timer: H 05 * * *

      # centos7 latest
      - TTCN3-centos7-pcap-client-test-latest:  # ~1 min
          timer: H 05 * * *

      # With LIBOSMO_IO_BACKEND=IO_URING (OS#6357)
      - ttcn3-gbproxy-test-io_uring:  # ~15 min
          timer: H 05 * * *

      # BTS testsuites tend to fail with timeouts on heavy loads. Group them
      # here in a timeslot where jenkins nodes are otherwise not busy according
      # to stats in grafana to hopefully make the test results more stable.
      # Once we can replace faketrx with a rewrite (OS#6672), this should not
      # be necessary anymore.
      - ttcn3-bts-test-io_uring:  # ~135 min
          timer: 0 06 * * *
      - ttcn3-bts-test:  # ~135 min
          timer: 0 06 * * *
      - ttcn3-bts-test-latest:  # ~135 min
          timer: 0 06 * * *
      - ttcn3-bts-test-asan:  # ~135 min
          timer: 0 06 * * *

      # With sanitizer (OS#5301)
      - ttcn3-gbproxy-test-asan:  # ~15 min
          timer: H 07 * * *

- 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-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
