~canonical-platform-qa-jenkins/qa-jenkins-jobs/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# vim: sw=4 ts=4 et

# QA Jenkins Jobs
# Copyright 2016 Canonical Ltd.

# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.

# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.

# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.

- project:
    name: ubiquity-setup
    jobs:
      - 'ubiquity-setup'

- job:
    name: ubiquity-setup
    description: |
      Install required deps for the ubiquity tests.
    node: 'iso-testing'
    builders:
      - package-installer:
          to-install: 'bzr subunit'
      - shell: |
          pip3 install --user junit_xml

# The project stanza describes all jobs and parameters
- project:
    name: ubiquity
    flavor:
        - ubuntu
    release:
        - bionic:
            ubiquity_branch: 'lp:ubiquity'
        - xenial:
            ubiquity_branch: 'lp:~ubuntu-installer/ubiquity/xenial-proposed'
    arch:
        - amd64
        - i386
    test: !include: 'ubiquity_tests'
    jobs:
        - 'ubiquity_ap-{flavor}_{release}_{arch}-{test}'

# builder stanzas describe reusable build steps
- builder:
    name: run-ubiquity-test
    builders:
        - shell: |
            BRANCH="{ubiquity_branch}"
            BZRDIR=$WORKSPACE/ubiquity
            bzr branch $BRANCH $BZRDIR #TODO: look at using package instead

            ISO=/var/cache/utah/iso/{release}-{variant}-{arch}.iso
            TESTNAME={test}

            if [ ! -f "$ISO" ]; then
                echo "E: File $ISO does not exist. Aborting!"
                exit 1
            fi

            echo "I: Starting test $TESTNAME with image $ISO"
            FULLNAME="ubiquity_autopilot_tests.tests.{test}"
            $BZRDIR/autopilot/ubiquity-autopilot-runner/run-ubiquity-test -t $FULLNAME $ISO

- builder:
    name: generate-junit-files
    builders:
        - branch-bzr-project:
            project-url: 'lp:custom-grafana-integration'
            project-name: 'grafana-integration'
        - shell: |
            if ls {source_dir}/*.subunit; then
                for sfile in {source_dir}/*.subunit
                do
                    echo "Processing: ${{sfile}}"
                    new_xml_file="$WORKSPACE/junit.xml"
                    echo "Generating: ${{new_xml_file}}"
                    subunit2junitxml "${{sfile}}" > "${{new_xml_file}}" || true
                done
            else
                echo "ERROR: source directory does not exist"
                echo "Generating error file"
                FULLNAME="ubiquity_autopilot_tests.tests.{test}"
                python3 $WORKSPACE/grafana-integration/src/utils/xunit_creator.py $FULLNAME ERROR $WORKSPACE/junit.xml
            fi


- job-template:
    name: 'ubiquity_ap-{flavor}_{release}_{arch}-{test}'
    description: |
        Run ubiquity tests
        Defined in lp:qa-jenkins-jobs

    node: 'iso-testing'
    triggers:
        - reverse: # Trigger after the default test succeeds
            jobs: '{flavor}-{release}-desktop-{arch}-smoke-default'
            result: 'success'
    builders:
        - clear-artifacts:
        - echo-media-info:
            iso: '/var/cache/utah/iso/{release}-desktop-{arch}.iso'
        - run-ubiquity-test:
            release: '{release}'
            variant: 'desktop'
            arch: '{arch}'
            test: '{test}'
            ubiquity_branch: '{ubiquity_branch}'

    publishers:
        - archive-artifacts
        - postbuildscript:
            builders:
                - generate-junit-files:
                    source_dir: 'results/var/local/autopilot/junit'
                    test: '{test}'
                - grafana-info:
                    device: 'vm'
                    model: ''
                    os: '{flavor}'
                    release: '{release}'
                    arch: '{arch}'
                    class: 'ubiquity'
                    conf: ''
                - grafana-tests-upload:
                    results_type: 'xunit'
                    results_file: 'junit.xml'
                    info_file: 'global_info.json'
            script-only-if-succeeded: False
            script-only-if-failed: False
        - junit:
            results: 'junit.xml'