- job:
    name: jdk13-terasort-benchmark-persist-results
    project-type: matrix
    defaults: global
    description: |
        * Writes results to /work/openjdk-testing/hadoop-terasort-benchmark-results.
    properties:
        - authorization:
            everyone-flat:
                - job-read
            openjdk-members:
                - job-extended-read
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 30
            num-to-keep: 10
            artifact-num-to-keep: 5
    disabled: true
    node: j12-qrep-01
    display-name: 'DELETE ME'
    axes:
        - axis:
            type: user-defined
            name: BUILD_TYPE
            values:
                - release
        - axis:
            type: slave
            name: label
            values:
                - j12-qrep-01
    execution-strategy:
        sequential: true
    wrappers:
        - workspace-cleanup:
            dirmatch: false
        - timestamps
        - matrix-tie-parent:
            node: j12-qrep-01
    builders:
        - copyartifact:
            project: jdk13-terasort-benchmark
            filter: 'out/terasort-results-${BUILD_TYPE}.csv'
            target: incoming
            flatten: true
        - shell: |
            #!/bin/bash

            set -exu

            PERSIST=$HOME/srv/openjdk13
            export BENCHMARK_RESULTS_DIR=$PERSIST/hadoop-terasort-benchmark-results
            new_results=incoming/BUILD_TYPE=${BUILD_TYPE},label=${label}/*.csv
            prev_results=$BENCHMARK_RESULTS_DIR/results.csv

            # Ensure persistent directory exists.
            mkdir -p $BENCHMARK_RESULTS_DIR

            # Tolerate missing results.csv file.
            if [ ! -f $prev_results ]; then
                touch $prev_results
            fi

            SCRIPT_DIR=$PERSIST/hadoop-test-scripts
            if [ -d $SCRIPT_DIR ]; then
                (cd $SCRIPT_DIR; git pull)
            else
                git clone https://git.linaro.org/leg/openjdk/hadoop-test-scripts.git $SCRIPT_DIR
            fi

            echo "Previous Results"
            echo "----------------"
            cat ${prev_results}
            echo

            cat ${new_results} >> ${prev_results}

            $SCRIPT_DIR/update-results-db
