~cjohnston/+junk/settle

« back to all changes in this revision

Viewing changes to jenkins/job-creation/setup_jenkins.py

  • Committer: Paul Larson
  • Date: 2013-08-01 04:25:31 UTC
  • mfrom: (30.1.14 touch-runlists-new)
  • Revision ID: paul.larson@canonical.com-20130801042531-qe09p2ielng1h33m
Rework the way we run all touch jobs

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from distro_info import UbuntuDistroInfo
25
25
 
26
26
DEV_SERIES = UbuntuDistroInfo().devel()
27
 
TESTS = ["default",
28
 
         "security",
 
27
TESTS = ["flash",
 
28
         "default",
 
29
         "mediaplayer-app-autopilot",
 
30
         "gallery-app-autopilot",
 
31
         "webbrowser-app-autopilot",
 
32
         "unity8-app-autopilot",
 
33
         "friends-app-autopilot",
 
34
         "notes-app-autopilot",
 
35
         "camera-app-autopilot",
 
36
         "phone-app-autopilot",
 
37
         "share-app-autopilot",
29
38
         "sdk",
30
39
         "smem",
31
 
         "eventstat"]
 
40
         "master"]
 
41
 
 
42
def _job(device):
 
43
    return {
 
44
        'device': device.split('-', 2)[0],  # turn grouper-01 into grouper
 
45
        'device_name': device,
 
46
    }
 
47
 
 
48
DEVICES = [
 
49
    _job('mako-01'),
 
50
]
32
51
 
33
52
 
34
53
def _get_parser():
44
63
                        help="Dry run mode. Don't execute jenkins commands.")
45
64
    parser.add_argument("-u", "--username",
46
65
                        help="username to use when logging into Jenkins.")
 
66
    parser.add_argument("-P", "--publish", action="store_true",
 
67
                        help="Publish at the end of the job")
47
68
    parser.add_argument("-p", "--password",
48
69
                        help="username to use when logging into Jenkins")
 
70
    parser.add_argument("--prefix",
 
71
                        help="Prefix to add to the beginning of the job name")
49
72
    parser.add_argument("-j", "--jenkins", default="http://10.98.0.1:8080/",
50
73
                        help="URL of jenkins instance to configure jobs in.")
51
 
    parser.add_argument("-n", "--name", default="maguro-01",
52
 
                        help=("Device name where the job should be executed "
53
 
                              "(default=%(default)s)"))
 
74
    parser.add_argument("-n", "--name", action='append',
 
75
                        help=("Device names where the job should be executed."
 
76
                              " Can be used more than once."))
54
77
    parser.add_argument("-s", "--series", default=DEV_SERIES,
55
78
                        help=("series of Ubuntu to download "
56
79
                        "(default=%(default)s)"))
77
100
        trim_blocks=True)
78
101
 
79
102
 
80
 
def _get_job_name(args, testname):
81
 
    if (testname in ("default", "security", "sdk")):
82
 
        fmt = "{series}-touch-{type}-smoke-{testname}"
83
 
        return fmt.format(series=args.series,
84
 
            type=args.name[:args.name.index("-")],
 
103
def _get_job_name(args, device, testname):
 
104
    prefix=""
 
105
    if(args.prefix):
 
106
        prefix=args.prefix+"-"
 
107
    if (testname in ("eventstat", "smem")):
 
108
        fmt = "{prefix}{testname}-{series}-touch-armhf-install-idle-{type}"
 
109
        return fmt.format(prefix=prefix,
 
110
            series=args.series,
 
111
            testname=testname,
 
112
            type=device[:device.index("-")])
 
113
    else:
 
114
        fmt = "{prefix}{series}-touch-{type}-smoke-{testname}"
 
115
        return fmt.format(prefix=prefix,
 
116
            series=args.series,
 
117
            type=device[:device.index("-")],
85
118
            testname=testname)
86
 
    else:
87
 
        fmt = "{testname}-{series}-touch-armhf-install-idle-{type}"
88
 
        return fmt.format(series=args.series,
89
 
            testname=testname,
90
 
            type=args.name[:args.name.index("-")])
91
 
 
92
 
 
93
 
def _configure_job(instance, env, args, testname):
 
119
 
 
120
 
 
121
def _configure_job(instance, env, args, device, testname, project_names):
94
122
    tmpl_name = "touch-%s.xml.jinja2" % testname
95
123
    tmpl = env.get_template(tmpl_name)
96
 
    cfg = tmpl.render(name=args.name,
 
124
    cfg = tmpl.render(name=device,
97
125
                      series=args.series,
98
 
                      type=args.name[:args.name.index("-")],
99
 
                      testname=testname)
100
 
    jobname = _get_job_name(args, testname)
 
126
                      type=device[:device.index("-")],
 
127
                      testname=testname,
 
128
                      publish=args.publish,
 
129
                      projects=project_names)
 
130
    jobname = _get_job_name(args, device, testname)
101
131
    if args.dryrun:
102
132
        _dryrun_func(jobname, cfg)
103
133
        return
125
155
 
126
156
    env = _get_environment()
127
157
 
128
 
    for testname in TESTS:
129
 
        logging.debug("configuring job for %s" %testname)
130
 
        _configure_job(jenkins_inst, env, args, testname)
 
158
    device_list = args.name if args.name else DEVICES
 
159
    for device in device_list:
 
160
        project_names = []
 
161
        for testname in TESTS:
 
162
            if testname=="master":
 
163
                continue
 
164
            project_names.append(_get_job_name(args, device, testname))
 
165
        for testname in TESTS:
 
166
            logging.debug("configuring job for %s" %testname)
 
167
            _configure_job(jenkins_inst, env, args, device, testname,
 
168
                project_names)
131
169
 
132
170
if __name__ == '__main__':
133
171
    main()