---
- project:
    name: 'ttcn3-testsuites'
    concurrent: false
    disabled: false
    description: |
        Run the
        <a href="https://osmocom.org/projects/cellular-infrastructure/wiki/Titan_TTCN3_Testsuites">
          Osmocom TTCN3 Testsuite</a> for <code>{testsuite}</code>.<br>
        <br>
        Command:<br>
        <code>./testenv.py run {testsuite} --podman {args}</code><br>
        <br>
        Kernel:<br>
        <a href="https://jenkins.osmocom.org/jenkins/job/build-kernel-{kernel}/">
          <code>{kernel}</code>
        </a><br>
    timer: "@midnight"
    kernel: "none"
    node: ttcn3
    jobs:
      - "{job-name}"
    # timers: see jobs/README.adoc
    job-name:
      # ---------------------------------------------
      # Debian nightly
      # ---------------------------------------------
      - ttcn3-hnbgw-test:  # ~13 min
          testsuite: hnbgw
          args: -b osmocom:nightly -c all
          timer: H 08 * * *

      - ttcn3-bsc-test:  # ~96 min
          testsuite: bsc
          args: -b osmocom:nightly -c generic
          timer: H 08 * * *

      - ttcn3-bsc-test-sccplite:  # ~76 min
          testsuite: bsc
          args: -b osmocom:nightly -c sccplite
          timer: H 08 * * *

      - ttcn3-bsc-test-vamos:  # ~4 min
          testsuite: bsc
          args: -b osmocom:nightly -c vamos
          timer: H 08 * * *

      - ttcn3-pcu-test:  # ~14 min
          testsuite: pcu
          args: -b osmocom:nightly -c generic
          timer: H 08 * * *

      - ttcn3-pcu-test-sns:  # ~7 min
          testsuite: pcu
          args: -b osmocom:nightly -c sns
          timer: H 08 * * *

      - ttcn3-hlr-test:  # ~3 min
          testsuite: hlr
          args: -b osmocom:nightly
          timer: H 08 * * *

      - ttcn3-mgw-test:  # ~8 min
          testsuite: mgw
          args: -b osmocom:nightly
          timer: H 08 * * *

      - ttcn3-sip-test:  # ~2 min
          testsuite: sip
          args: -b osmocom:nightly
          timer: H 08 * * *

      - ttcn3-sgsn-test:  # ~15 min
          testsuite: sgsn
          args: -b osmocom:nightly -c generic
          timer: H 09 * * *

      - ttcn3-sgsn-test-sns:  # ~1 min
          testsuite: sgsn
          args: -b osmocom:nightly -c sns
          timer: H 09 * * *

      - ttcn3-smlc-test:  # ~2 min
          testsuite: smlc
          args: -b osmocom:nightly
          timer: H 09 * * *

      - ttcn3-cbc-test:  # ~6 min
          testsuite: cbc
          args: -b osmocom:nightly
          timer: H 09 * * *

      - ttcn3-stp-test:  # ~10 min
          testsuite: stp
          args: -b osmocom:nightly
          timer: H 09 * * *

      - ttcn3-hnodeb-test:  # ~1 min
          testsuite: hnodeb
          args: -b osmocom:nightly
          timer: H 09 * * *

      - ttcn3-dia2gsup-test:  # ~2 min
          testsuite: dia2gsup
          args: -b osmocom:nightly
          timer: H 09 * * *

      - ttcn3-upf-test:  # ~1 min
          testsuite: upf
          args: -b osmocom:nightly
          timer: H 09 * * *

      - ttcn3-hss-test-ogs:  # ~1 min
          testsuite: hss
          args: -b osmocom:nightly
          timer: H 09 * * *
          email: jenkins-notifications@lists.osmocom.org acetcom@gmail.com

      - ttcn3-mme-test-ogs:  # ~2 min
          testsuite: mme
          args: -b osmocom:nightly
          timer: H 09 * * *
          email: jenkins-notifications@lists.osmocom.org acetcom@gmail.com

      - ttcn3-pcrf-test-ogs:  # ~1 min
          testsuite: pcrf
          args: -b osmocom:nightly
          timer: H 09 * * *
          email: jenkins-notifications@lists.osmocom.org acetcom@gmail.com

      - ttcn3-s1gw-test:  # ~2 min
          testsuite: s1gw
          args: -b osmocom:nightly
          timer: H 09 * * *

      - ttcn3-ggsn-test:  # ~15 min
          testsuite: ggsn
          args: -b osmocom:nightly -c 'osmo_ggsn_*'
          timer: H 10 * * *

      - ttcn3-ggsn-test-kernel:  # ~10 min
          testsuite: ggsn
          args: -b osmocom:nightly -c 'osmo_ggsn_v*_only' --debian-kernel
          timer: H 10 * * *

      - ttcn3-ggsn-test-kernel-net-next:  # ~10 min
          testsuite: ggsn
          args: -b osmocom:nightly -c 'osmo_ggsn_v*_only' --custom-kernel
          kernel: net-next
          timer: H 10 * * *

      - ttcn3-ggsn-test-kernel-torvalds:  # ~10 min
          testsuite: ggsn
          args: -b osmocom:nightly -c 'osmo_ggsn_v*_only' --custom-kernel
          kernel: torvalds
          timer: H 10 * * *

      - ttcn3-ggsn-test-ogs:  # ~10 min
          testsuite: ggsn
          args: -b osmocom:nightly -c open5gs
          timer: H 10 * * *
          email: jenkins-notifications@lists.osmocom.org acetcom@gmail.com

      - ttcn3-pcap-client-test:  # ~1 min
          testsuite: pcap-client
          args: -b osmocom:nightly
          timer: H 10 * * *

      # ---------------------------------------------
      # Debian latest
      # ---------------------------------------------
      - ttcn3-pcu-test-latest:  # ~14 min
          testsuite: pcu
          args: -b osmocom:latest -c generic
          timer: H 12 * * *

      - ttcn3-pcu-test-sns-latest:  # ~8 min
          testsuite: pcu
          args: -b osmocom:latest -c sns
          timer: H 12 * * *

      - ttcn3-hlr-test-latest:  # ~3 min
          testsuite: hlr
          args: -b osmocom:latest
          timer: H 12 * * *

      - ttcn3-mgw-test-latest:  # ~8 min
          testsuite: mgw
          args: -b osmocom:latest
          timer: H 12 * * *

      - ttcn3-sip-test-latest:  # ~2 min
          testsuite: sip
          args: -b osmocom:latest
          timer: H 12 * * *

      - ttcn3-sgsn-test-latest:  # ~15 min
          testsuite: sgsn
          args: -b osmocom:latest -c generic
          timer: H 12 * * *

      - ttcn3-sgsn-test-sns-latest:  # ~1 min
          testsuite: sgsn
          args: -b osmocom:latest -c sns
          timer: H 12 * * *

      - ttcn3-smlc-test-latest:  # ~2 min
          testsuite: smlc
          args: -b osmocom:latest
          timer: H 12 * * *

      - ttcn3-cbc-test-latest:  # ~6 min
          testsuite: cbc
          args: -b osmocom:latest
          timer: H 12 * * *

      - ttcn3-stp-test-latest:  # ~10 min
          testsuite: stp
          args: -b osmocom:latest
          timer: H 12 * * *

      - ttcn3-hnbgw-test-latest:  # ~13 min
          testsuite: hnbgw
          args: -b osmocom:latest -c all
          timer: H 12 * * *

      - ttcn3-hnodeb-test-latest:  # ~1 min
          testsuite: hnodeb
          args: -b osmocom:latest
          timer: H 12 * * *

      - ttcn3-upf-test-latest:  # ~1 min
          testsuite: upf
          args: -b osmocom:latest
          timer: H 12 * * *
          disabled: true

      - ttcn3-s1gw-test-latest:  # ~2 min
          testsuite: s1gw
          args: -b osmocom:latest
          timer: H 12 * * *

      - ttcn3-ggsn-test-latest:  # ~15 min
          testsuite: ggsn
          args: -b osmocom:latest -c 'osmo_ggsn_*'
          timer: H 12 * * *

      - ttcn3-ggsn-test-kernel-latest:  # ~10 min
          testsuite: ggsn
          args: -b osmocom:latest -c 'osmo_ggsn_v*_only' --debian-kernel
          timer: H 12 * * *

      - ttcn3-ggsn-test-kernel-latest-net-next:  # ~10 min
          testsuite: ggsn
          args: -b osmocom:latest -c 'osmo_ggsn_v*_only' --custom-kernel
          kernel: net-next
          timer: H 12 * * *

      - ttcn3-ggsn-test-kernel-latest-torvalds:  # ~10 min
          testsuite: ggsn
          args: -b osmocom:latest -c 'osmo_ggsn_v*_only' --custom-kernel
          kernel: torvalds
          timer: H 12 * * *

      - ttcn3-bsc-test-latest:  # ~96 min
          testsuite: bsc
          args: -b osmocom:latest -c generic
          timer: H 12 * * *

      - ttcn3-bsc-test-sccplite-latest:  # ~76 min
          testsuite: bsc
          args: -b osmocom:latest -c sccplite
          timer: H 13 * * *

      - ttcn3-bsc-test-vamos-latest:  # ~3 min
          testsuite: bsc
          args: -b osmocom:latest -c vamos
          timer: H 13 * * *

      - ttcn3-pcap-client-test-latest:  # ~1 min
          testsuite: pcap-client
          args: -b osmocom:latest
          timer: H 13 * * *

      # ---------------------------------------------
      # Debian nightly + io_uring (OS#6357)
      # ---------------------------------------------
      - ttcn3-mgw-test-io_uring:  # ~8 min
          testsuite: mgw
          args: -b osmocom:nightly --io-uring
          timer: H 14 * * *

      - ttcn3-sgsn-test-io_uring:  # ~15 min
          testsuite: sgsn
          args: -b osmocom:nightly --io-uring -c generic
          timer: H 14 * * *

      - ttcn3-stp-test-io_uring:  # ~10 min
          testsuite: stp
          args: -b osmocom:nightly --io-uring
          timer: H 14 * * *

      - ttcn3-bsc-test-io_uring:  # ~96 min
          testsuite: bsc
          args: -b osmocom:nightly --io-uring -c generic
          timer: H 14 * * *

      - ttcn3-hnbgw-test-io_uring:  # ~13 min
          testsuite: hnbgw
          args: -b osmocom:nightly --io-uring -c all
          timer: H 14 * * *

      # ---------------------------------------------
      # Debian nightly + asan (OS#5301)
      # ---------------------------------------------
      - ttcn3-mgw-test-asan:  # ~8 min
          testsuite: mgw
          args: -b osmocom:nightly:asan
          timer: H 16 * * *

      - ttcn3-hlr-test-asan:  # ~3 min
          testsuite: hlr
          args: -b osmocom:nightly:asan
          timer: H 16 * * *

      - ttcn3-sip-test-asan:  # ~2 min
          testsuite: sip
          args: -b osmocom:nightly:asan
          timer: H 16 * * *

      - ttcn3-hnodeb-test-asan:  # ~1 min
          testsuite: hnodeb
          args: -b osmocom:nightly:asan
          timer: H 16 * * *

      - ttcn3-smlc-test-asan:  # ~2 min
          testsuite: smlc
          args: -b osmocom:nightly:asan
          timer: H 16 * * *

      - ttcn3-cbc-test-asan:  # ~6 min
          testsuite: cbc
          args: -b osmocom:nightly:asan
          timer: H 16 * * *

      - ttcn3-sgsn-test-asan:  # ~15 min
          testsuite: sgsn
          args: -b osmocom:nightly:asan -c generic
          timer: H 16 * * *

      - ttcn3-ggsn-test-asan:  # ~15 min
          testsuite: ggsn
          args: -b osmocom:nightly:asan -c 'osmo_ggsn_*'
          timer: H 16 * * *

      - ttcn3-stp-test-asan:  # ~10 min
          testsuite: stp
          args: -b osmocom:nightly:asan
          timer: H 16 * * *

      - ttcn3-pcu-test-asan:  # ~14 min
          testsuite: pcu
          args: -b osmocom:nightly:asan -c generic
          timer: H 16 * * *

      - ttcn3-pcu-test-sns-asan:  # ~8 min
          testsuite: pcu
          args: -b osmocom:nightly:asan -c sns
          timer: H 16 * * *

      - ttcn3-bsc-test-asan:  # ~96 min
          testsuite: bsc
          args: -b osmocom:nightly:asan -c generic
          timer: H 16 * * *

      - ttcn3-pcap-client-test-asan:  # ~1 min
          testsuite: pcap-client
          args: -b osmocom:nightly:asan
          timer: H 17 * * *

      - ttcn3-hnbgw-test-asan:  # ~13 min
          testsuite: hnbgw
          args: -b osmocom:nightly:asan -c all
          timer: H 17 * * *

- 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>osmo-ttcn3-hacks.git</code>
          default: 'master'
    builders:
      - copyartifact:
          project: "build-kernel-{kernel}"
          filter: "output/linux"
          flatten: true
          which-build: last-successful
          stable: true
      - shell: |-
          DISTRO="debian:bookworm"
          IMAGE="registry.osmocom.org/osmocom-build/"$(echo "$DISTRO" | tr : -)"-osmo-ttcn3-testenv"
          KERNEL="{kernel}"

          podman pull "$IMAGE"

          rm -rf logs _cache .linux

          if [ "$KERNEL" != "none" ]; then
            mv linux .linux
          fi

          set +x  # Don't output the color codes we set here
          export TESTENV_COLOR_DEBUG="$(printf '\e[0;94m')"  # light blue
          export TESTENV_COLOR_INFO="$(printf '\e[1;34m')"  # bold, blue
          export TESTENV_COLOR_WARNING="$(printf '\e[1;35m')"  # bold, purple
          export TESTENV_COLOR_ERROR="$(printf '\e[1;91m')"  # bold, red
          export TESTENV_COLOR_CRITICAL="$(printf '\e[1;91m')"  # bold, red
          export TESTENV_SOURCE_HIGHLIGHT_COLORS="esc"
          export TESTENV_NO_IMAGE_UP_TO_DATE_CHECK=1
          export TESTENV_NO_KVM=1
          set -x

          ./testenv.py run \
            {testsuite} \
            --podman \
            --cache "$PWD"/_cache \
            --ccache ~/ccache/testenv \
            --log-dir "$PWD"/logs \
            {args}

          # Free up space from downloaded apt packages, build artifacts etc.
          # The osmo-ttcn3-hacks deps dir and ccache are persistent.
          rm -rf _cache .linux

    scm:
      - git:
          branches:
            - '$BRANCH'
          url: https://gerrit.osmocom.org/osmo-ttcn3-hacks
          git-config-name: 'Jenkins Builder'
          git-config-email: 'jenkins@osmocom.org'
          wipe-workspace: false
    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