~mpontillo/maas/js-metrics-service

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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
[buildout]
parts =
  cli
  cli-test
  config-test
  coverage
  flake8
  parallel-test
  rack
  rack-test
  region
  region-test
  region-test-legacy
  repl
  sphinx
  testing-test
versions = versions
extends = versions.cfg
offline = false
newest = false

# Uncomment the following two lines and set allow-picked-versions=true
# to automatically update versions.cfg when building recipes.
# extensions = buildout-versions
# buildout_versions_file = versions.cfg

prefer-final = true
allow-picked-versions = false

[common]
extra-paths =
  ${buildout:directory}/etc
  ${buildout:directory}/src
  ${buildout:directory}
test-eggs =
  blessings
  coverage
  fixtures
  hypothesis
  ipdb
  nose
  nose-timer
  postgresfixture
  python-subunit
  testresources
  testscenarios
  testtools
initialization =
  ${common:path-munge}
  ${common:warnings}
  ${common:environment}
path-munge =
  import pathlib, sys
  # Eliminate argparse usage outside of the standard library. This is
  # needed because some deps <cough>unittest2<cough> explicitly require
  # argparse, which zc.buildout then dutifully installs. Unfortunately
  # argparse 1.1 from PyPI differs substantially to argparse 1.1 in the
  # standard library. For consistency we want the latter.
  p_argparse_egg = lambda path: pathlib.Path(path).match("*/argparse-*.egg")
  sys.path[:] = [path for path in sys.path if not p_argparse_egg(path)]
  # Sort system paths towards the end of sys.path so that deps defined
  # here are used in preference to those installed system-wide.
  p_sys_prefix = lambda path, p=pathlib.Path: p(sys.prefix) in p(path).parents
  sys.path.sort(key=p_sys_prefix)
environment =
  from os import environ
  environ.setdefault("MAAS_ROOT", "${buildout:directory}/.run")
warnings =
  from warnings import filterwarnings
  filterwarnings("ignore", category=RuntimeWarning, module="pkg_resources")
inject-test-options =
  # When running tests from a console show only dots, but when running
  # headless increase verbosity so we can see the test being run from a
  # log file. An `options` list must be defined ahead of the use of this
  # snippet.
  options += (
    ["--verbosity=1"]
    if sys.stdout.isatty() else
    ["--verbosity=2"]
  )
  sys.argv[1:1] = options

[database]
recipe = zc.recipe.egg
eggs = postgresfixture
extra-paths =
  ${common:extra-paths}
initialization =
  ${common:path-munge}
interpreter =
entry-points = database=postgresfixture.main:main
scripts = database

[parallel-test]
recipe = zc.recipe.egg
eggs =
  ${common:test-eggs}
entry-points =
  test.parallel=maastesting.parallel:main
scripts = test.parallel
extra-paths =
  ${common:extra-paths}

[region]
recipe = zc.recipe.egg
test-eggs =
  ${common:test-eggs}
  selenium
eggs =
  ${region:test-eggs}
entry-points =
  maas-region=maasserver:execute_from_command_line
  twistd.region=twisted.scripts.twistd:run
initialization =
  ${common:initialization}
  environ.setdefault("DJANGO_SETTINGS_MODULE", "maasserver.djangosettings.development")
scripts =
  maas-region
  twistd.region
extra-paths =
  ${common:extra-paths}

[region-test]
recipe = zc.recipe.egg
eggs =
  ${region:eggs}
  ${common:test-eggs}
entry-points =
  test.region=maastesting.noseplug:main
initialization =
  ${region:initialization}
  options = [
    "--with-crochet",
    "--with-resources",
    "--with-scenarios",
    "--with-select",
    "--select-dir=src/maasserver",
    "--select-dir=src/metadataserver",
    "--cover-package=maas,maasserver,metadataserver",
    "--cover-branches",
    # Reduce the logging level to INFO here as
    # DebuggingLoggerMiddleware logs the content of all the
    # requests at DEBUG level: we don't want this in the
    # tests as it's too verbose.
    "--logging-level=INFO",
    "--logging-clear-handlers",
    # Do not run tests tagged "legacy".
    "-a", "!legacy",
  ]
  ${common:inject-test-options}
  # Configure logging. TODO: Do this in a plugin.
  from provisioningserver import logger
  logger.configure(mode=logger.LoggingMode.COMMAND)
  # Limit concurrency in all thread-pools to ONE.
  from maasserver.utils import threads
  threads.install_default_pool(maxthreads=1)
  threads.install_database_unpool(maxthreads=1)
  # Disable all database connections in the reactor.
  from maasserver.utils import orm
  from twisted.internet import reactor
  assert not reactor.running, "The reactor has been started too early."
  reactor.callFromThread(orm.disable_all_database_connections)
  # Last and least, configure Django.
  import django; django.setup()
scripts = test.region
extra-paths =
  ${region:extra-paths}

[region-test-legacy]
recipe = zc.recipe.egg
eggs =
  ${region:eggs}
entry-points =
  test.region.legacy=maasserver:execute_from_command_line
initialization =
  ${region:initialization}
  environ.setdefault("MAAS_PREVENT_MIGRATIONS", "1")
  options = [
    "test",
    "--noinput",
    "--with-crochet",
    "--with-scenarios",
    "--with-select",
    "--select-dir=src/maasserver",
    "--select-dir=src/metadataserver",
    "--cover-package=maas,maasserver,metadataserver",
    "--cover-branches",
    # Reduce the logging level to INFO here as
    # DebuggingLoggerMiddleware logs the content of all the
    # requests at DEBUG level: we don't want this in the
    # tests as it's too verbose.
    "--logging-level=INFO",
    "--logging-clear-handlers",
    # Run only tests tagged "legacy".
    "-a", "legacy",
  ]
  ${common:inject-test-options}
scripts = test.region.legacy
extra-paths =
  ${region:extra-paths}

[cli]
recipe = zc.recipe.egg
eggs =
  ${region:eggs}
initialization =
  ${common:path-munge}
entry-points =
  maas=maascli:main
extra-paths =
  ${common:extra-paths}
scripts =
  maas

[cli-test]
recipe = zc.recipe.egg
eggs =
  ${cli:eggs}
  ${common:test-eggs}
entry-points =
  test.cli=maastesting.noseplug:main
initialization =
  ${common:path-munge}
  ${common:warnings}
  options = [
    "--with-resources",
    "--with-scenarios",
    "--with-select",
    "--select-dir=src/apiclient",
    "--select-dir=src/maascli",
    "--cover-package=apiclient,maascli",
    "--cover-branches",
  ]
  ${common:inject-test-options}
extra-paths = ${cli:extra-paths}
scripts =
  test.cli

[js-test]
recipe = zc.recipe.egg
eggs =
  ${common:test-eggs}
entry-points =
  test.js=maastesting.karma:run_karma
extra-paths =
  ${common:extra-paths}
scripts =
  test.js
initialization =
  ${common:initialization}

[testing-test]
recipe = zc.recipe.egg
eggs =
  ${common:test-eggs}
entry-points =
  test.testing=maastesting.noseplug:main
initialization =
  ${common:path-munge}
  ${common:warnings}
  options = [
    "--with-resources",
    "--with-scenarios",
    "--with-select",
    "--select-dir=src/maastesting",
    "--cover-package=maastesting",
    "--cover-branches",
  ]
  ${common:inject-test-options}
extra-paths =
  ${common:extra-paths}
scripts =
  test.testing

[rack]
recipe = zc.recipe.egg
eggs =
entry-points =
  maas-rack=provisioningserver.__main__:main
  twistd.rack=twisted.scripts.twistd:run
extra-paths =
  ${common:extra-paths}
scripts =
  maas-rack
  twistd.rack
initialization =
  ${common:initialization}
  environ.setdefault("MAAS_RACK_DEVELOP", "TRUE")

[rack-test]
recipe = zc.recipe.egg
eggs =
  ${rack:eggs}
  ${common:test-eggs}
entry-points =
  test.rack=maastesting.noseplug:main
initialization =
  ${common:initialization}
  options = [
    "--with-crochet",
    "--crochet-no-setup",
    "--with-resources",
    "--with-scenarios",
    "--with-select",
    "--select-dir=src/provisioningserver",
    "--cover-package=provisioningserver",
    "--cover-branches",
  ]
  ${common:inject-test-options}
extra-paths = ${rack:extra-paths}
scripts =
  test.rack

[e2e-test]
recipe = zc.recipe.egg
eggs =
  ${region:test-eggs}
entry-points =
  test.e2e=maastesting.protractor.runner:run_protractor
extra-paths =
  ${common:extra-paths}
scripts =
  test.e2e
initialization =
  ${common:path-munge}
  from os import environ
  environ.setdefault("MAAS_RACK_DEVELOP", "TRUE")
  environ.setdefault("MAAS_ROOT", "${buildout:directory}/.run-e2e")
  environ.setdefault("DJANGO_SETTINGS_MODULE", "maasserver.djangosettings.development")
  environ.setdefault("DEV_DB_NAME", "test_maas_e2e")
  environ.setdefault("MAAS_PREVENT_MIGRATIONS", "1")

[flake8]
recipe = zc.recipe.egg
eggs =
  flake8
entry-points =
  flake8=flake8.main.cli:main
initialization =
  ${common:path-munge}
  ${common:warnings}

[coverage]
recipe = zc.recipe.egg
eggs =
  coverage
entry-points =
  coverage=coverage.cmdline:main
initialization =
  ${common:path-munge}
  ${common:warnings}
scripts =
  coverage

[sphinx]
recipe = collective.recipe.sphinxbuilder
source = ${buildout:directory}/docs
build = ${buildout:directory}/docs/_build
extra-paths = ${common:extra-paths}
eggs =
  ${region:eggs}
  ${rack:eggs}

# Convenient REPLs with all eggs available.
[repl]
recipe = zc.recipe.egg
eggs =
  ${region:eggs}
  ${rack:eggs}
  ${common:test-eggs}
extra-paths = ${common:extra-paths}
interpreter = py
scripts = ipy
entry-points =
  ipy=IPython.terminal.ipapp:launch_new_instance
initialization =
  ${common:initialization}