Devuan deployment of britney2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_autopkgtest.py 132 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651
  1. #!/usr/bin/python3
  2. # (C) 2014 - 2015 Canonical Ltd.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. import os
  9. import sys
  10. import fileinput
  11. import unittest
  12. import json
  13. import pprint
  14. import urllib.parse
  15. import apt_pkg
  16. import yaml
  17. PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  18. sys.path.insert(0, PROJECT_DIR)
  19. from tests import TestBase, mock_swift
  20. apt_pkg.init()
  21. # shortcut for test triggers
  22. def tr(s):
  23. return {'custom_environment': ['ADT_TEST_TRIGGERS=%s' % s]}
  24. ON_ALL_ARCHES = {'on-architectures': ['amd64', 'arm64', 'armhf', 'i386', 'powerpc', 'ppc64el'],
  25. 'on-unimportant-architectures': []}
  26. class T(TestBase):
  27. '''AMQP/cloud interface'''
  28. ################################################################
  29. # Common test code
  30. ################################################################
  31. def setUp(self):
  32. super().setUp()
  33. self.fake_amqp = os.path.join(self.data.path, 'amqp')
  34. # Set fake AMQP and Swift server
  35. for line in fileinput.input(self.britney_conf, inplace=True):
  36. if 'ADT_AMQP' in line:
  37. print('ADT_AMQP = file://%s' % self.fake_amqp)
  38. else:
  39. sys.stdout.write(line)
  40. # Set up sourceppa cache for testing
  41. self.sourceppa_cache = {
  42. 'gcc-5': {'2': ''},
  43. 'gcc-snapshot': {'2': ''},
  44. 'green': {'2': '', '1.1': '', '3': ''},
  45. 'lightgreen': {'2': '', '1.1~beta': '', '3': ''},
  46. 'linux-meta-64only': {'1': ''},
  47. 'linux-meta-lts-grumpy': {'1': ''},
  48. 'linux-meta': {'0.2': '', '1': '', '2': ''},
  49. 'linux': {'2': ''},
  50. 'newgreen': {'2': ''},
  51. }
  52. self.email_cache = {}
  53. for pkg, vals in self.sourceppa_cache.items():
  54. for version, empty in vals.items():
  55. self.email_cache.setdefault(pkg, {})
  56. self.email_cache[pkg][version] = True
  57. # create mock Swift server (but don't start it yet, as tests first need
  58. # to poke in results)
  59. self.swift = mock_swift.AutoPkgTestSwiftServer(port=18085)
  60. self.swift.set_results({})
  61. def tearDown(self):
  62. del self.swift
  63. def run_it(self, unstable_add, expect_status, expect_excuses={}):
  64. '''Run britney with some unstable packages and verify excuses.
  65. unstable_add is a list of (binpkgname, field_dict, testsuite_value)
  66. passed to TestData.add for "unstable".
  67. expect_status is a dict sourcename → (is_candidate, testsrc → arch → status)
  68. that is checked against the excuses YAML.
  69. expect_excuses is a dict sourcename → [(key, value), ...]
  70. matches that are checked against the excuses YAML.
  71. Return (output, excuses_dict, excuses_html).
  72. '''
  73. for (pkg, fields, testsuite) in unstable_add:
  74. self.data.add(pkg, True, fields, True, testsuite)
  75. self.sourceppa_cache.setdefault(pkg, {})
  76. if fields['Version'] not in self.sourceppa_cache[pkg]:
  77. self.sourceppa_cache[pkg][fields['Version']] = ''
  78. self.email_cache.setdefault(pkg, {})
  79. self.email_cache[pkg][fields['Version']] = True
  80. # Set up sourceppa cache for testing
  81. sourceppa_path = os.path.join(self.data.dirs[True], 'SourcePPA')
  82. with open(sourceppa_path, 'w', encoding='utf-8') as sourceppa:
  83. sourceppa.write(json.dumps(self.sourceppa_cache))
  84. email_path = os.path.join(self.data.dirs[True], 'EmailCache')
  85. with open(email_path, 'w', encoding='utf-8') as email:
  86. email.write(json.dumps(self.email_cache))
  87. self.swift.start()
  88. (excuses_yaml, excuses_html, out) = self.run_britney()
  89. self.swift.stop()
  90. # convert excuses to source indexed dict
  91. excuses_dict = {}
  92. for s in yaml.safe_load(excuses_yaml)['sources']:
  93. excuses_dict[s['source']] = s
  94. if 'SHOW_EXCUSES' in os.environ:
  95. print('------- excuses -----')
  96. pprint.pprint(excuses_dict, width=200)
  97. if 'SHOW_HTML' in os.environ:
  98. print('------- excuses.html -----\n%s\n' % excuses_html)
  99. if 'SHOW_OUTPUT' in os.environ:
  100. print('------- output -----\n%s\n' % out)
  101. for src, (is_candidate, testmap) in expect_status.items():
  102. self.assertEqual(excuses_dict[src]['is-candidate'], is_candidate,
  103. src + ': ' + pprint.pformat(excuses_dict[src]))
  104. for testsrc, archmap in testmap.items():
  105. for arch, status in archmap.items():
  106. self.assertEqual(excuses_dict[src]['policy_info']['autopkgtest'][testsrc][arch][0],
  107. status,
  108. excuses_dict[src]['policy_info']['autopkgtest'][testsrc])
  109. for src, matches in expect_excuses.items():
  110. for k, v in matches:
  111. if isinstance(excuses_dict[src][k], list):
  112. self.assertIn(v, excuses_dict[src][k])
  113. else:
  114. self.assertEqual(excuses_dict[src][k], v)
  115. self.amqp_requests = set()
  116. try:
  117. with open(self.fake_amqp) as f:
  118. for line in f:
  119. self.amqp_requests.add(line.strip())
  120. os.unlink(self.fake_amqp)
  121. except IOError:
  122. pass
  123. try:
  124. with open(os.path.join(self.data.path, 'data/testing/state/autopkgtest-pending.json')) as f:
  125. self.pending_requests = json.load(f)
  126. except IOError:
  127. self.pending_requests = None
  128. self.assertNotIn('FIXME', out)
  129. return (out, excuses_dict, excuses_html)
  130. ################################################################
  131. # Tests for generic packages
  132. ################################################################
  133. def test_no_request_for_uninstallable(self):
  134. '''Does not request a test for an uninstallable package'''
  135. self.data.add_default_packages(lightgreen=False)
  136. exc = self.run_it(
  137. # uninstallable unstable version
  138. [('lightgreen', {'Version': '1.1~beta', 'Depends': 'libc6 (>= 0.9), libgreen1 (>= 2)'}, 'autopkgtest')],
  139. {'lightgreen': (False, {})},
  140. {'lightgreen': [('old-version', '1'), ('new-version', '1.1~beta'),
  141. ('reason', 'depends'),
  142. ('excuses', 'lightgreen/amd64 unsatisfiable Depends: libgreen1 (>= 2)')
  143. ]
  144. })[1]
  145. # autopkgtest should not be triggered for uninstallable pkg
  146. self.assertEqual(exc['lightgreen']['policy_info']['autopkgtest'], {'verdict': 'REJECTED_TEMPORARILY'})
  147. self.assertEqual(self.pending_requests, {})
  148. self.assertEqual(self.amqp_requests, set())
  149. with open(os.path.join(self.data.path, 'output', 'output.txt')) as f:
  150. upgrade_out = f.read()
  151. self.assertNotIn('accepted:', upgrade_out)
  152. self.assertIn('SUCCESS (0/0)', upgrade_out)
  153. def test_no_wait_for_always_failed_test(self):
  154. '''We do not need to wait for results for tests which have always failed'''
  155. self.data.add_default_packages(darkgreen=False)
  156. # The package has failed before, and with a trigger too on amd64
  157. self.swift.set_results({'autopkgtest-testing': {
  158. 'testing/i386/d/darkgreen/20150101_100000@': (4, 'green 1'),
  159. 'testing/amd64/d/darkgreen/20150101_100000@': (4, 'green 1', tr('failedbefore/1')),
  160. }})
  161. exc = self.run_it(
  162. [('darkgreen', {'Version': '2'}, 'autopkgtest')],
  163. {'darkgreen': (True, {'darkgreen': {'i386': 'RUNNING-ALWAYSFAIL', 'amd64': 'RUNNING-ALWAYSFAIL'}})},
  164. )[1]
  165. # the test should still be triggered though
  166. self.assertEqual(exc['darkgreen']['policy_info']['autopkgtest'],
  167. {'darkgreen': {
  168. 'amd64': ['RUNNING-ALWAYSFAIL',
  169. 'https://autopkgtest.ubuntu.com/status/pending',
  170. 'https://autopkgtest.ubuntu.com/packages/d/darkgreen/testing/amd64',
  171. None,
  172. None],
  173. 'i386': ['RUNNING-ALWAYSFAIL',
  174. 'https://autopkgtest.ubuntu.com/status/pending',
  175. 'https://autopkgtest.ubuntu.com/packages/d/darkgreen/testing/i386',
  176. None,
  177. None]},
  178. 'verdict': 'PASS'})
  179. self.assertEqual(self.pending_requests,
  180. {'darkgreen/2': {'darkgreen': ['amd64', 'i386']}})
  181. self.assertEqual(
  182. self.amqp_requests,
  183. set(['debci-testing-amd64:darkgreen {"triggers": ["darkgreen/2"]}',
  184. 'debci-testing-i386:darkgreen {"triggers": ["darkgreen/2"]}']))
  185. with open(os.path.join(self.data.path, 'output', 'output.txt')) as f:
  186. upgrade_out = f.read()
  187. self.assertIn('accepted: darkgreen', upgrade_out)
  188. self.assertIn('SUCCESS (1/0)', upgrade_out)
  189. def test_dropped_test_not_run(self):
  190. '''New version of a package drops its autopkgtest'''
  191. self.data.add_default_packages(green=False)
  192. # green has passed on amd64 before
  193. # lightgreen has passed on i386, therefore we should block on it returning
  194. self.swift.set_results({'autopkgtest-testing': {
  195. 'testing/amd64/g/green/20150101_100000@': (0, 'green 4', tr('green/1')),
  196. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  197. }})
  198. self.run_it(
  199. [('libgreen1', {'Version': '2', 'Source': 'green'}, None)],
  200. {'green': (False, {'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'}})
  201. },
  202. {'green': [('old-version', '1'), ('new-version', '2'),
  203. ('reason', 'autopkgtest')]})
  204. # we expect the package's reverse dependencies' tests to get triggered,
  205. # but *not* the package itself since it has no autopkgtest any more
  206. self.assertEqual(
  207. self.amqp_requests,
  208. set(['debci-testing-i386:lightgreen {"triggers": ["green/2"]}',
  209. 'debci-testing-amd64:lightgreen {"triggers": ["green/2"]}',
  210. 'debci-testing-i386:darkgreen {"triggers": ["green/2"]}',
  211. 'debci-testing-amd64:darkgreen {"triggers": ["green/2"]}']))
  212. # ... and that they get recorded as pending
  213. expected_pending = {'green/2': {'darkgreen': ['amd64', 'i386'],
  214. 'lightgreen': ['amd64', 'i386']}}
  215. self.assertEqual(self.pending_requests, expected_pending)
  216. def test_multi_rdepends_with_tests_all_running(self):
  217. '''Multiple reverse dependencies with tests (all running)'''
  218. self.data.add_default_packages(green=False)
  219. # green has passed before on i386 only, therefore ALWAYSFAIL on amd64
  220. self.swift.set_results({'autopkgtest-testing': {
  221. 'testing/i386/g/green/20150101_100000@': (0, 'green 1', tr('passedbefore/1')),
  222. }})
  223. self.run_it(
  224. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  225. {'green': (False, {'green': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'},
  226. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  227. 'darkgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  228. })
  229. },
  230. {'green': [('old-version', '1'), ('new-version', '2'),
  231. ('reason', 'autopkgtest')]})
  232. # we expect the package's and its reverse dependencies' tests to get
  233. # triggered
  234. self.assertEqual(
  235. self.amqp_requests,
  236. set(['debci-testing-i386:green {"triggers": ["green/2"]}',
  237. 'debci-testing-amd64:green {"triggers": ["green/2"]}',
  238. 'debci-testing-i386:lightgreen {"triggers": ["green/2"]}',
  239. 'debci-testing-amd64:lightgreen {"triggers": ["green/2"]}',
  240. 'debci-testing-i386:darkgreen {"triggers": ["green/2"]}',
  241. 'debci-testing-amd64:darkgreen {"triggers": ["green/2"]}']))
  242. # ... and that they get recorded as pending
  243. expected_pending = {'green/2': {'darkgreen': ['amd64', 'i386'],
  244. 'green': ['amd64', 'i386'],
  245. 'lightgreen': ['amd64', 'i386']}}
  246. self.assertEqual(self.pending_requests, expected_pending)
  247. # if we run britney again this should *not* trigger any new tests
  248. self.run_it([], {'green': (False, {})})
  249. self.assertEqual(self.amqp_requests, set())
  250. # but the set of pending tests doesn't change
  251. self.assertEqual(self.pending_requests, expected_pending)
  252. def test_multi_rdepends_with_tests_all_pass(self):
  253. '''Multiple reverse dependencies with tests (all pass)'''
  254. self.data.add_default_packages(green=False)
  255. # green has passed before on i386 only, therefore ALWAYSFAIL on amd64
  256. self.swift.set_results({'autopkgtest-testing': {
  257. 'testing/i386/g/green/20150101_100000@': (0, 'green 1', tr('passedbefore/1')),
  258. }})
  259. # first run requests tests and marks them as pending
  260. exc = self.run_it(
  261. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest'),
  262. # a reverse dep that does not exist in testing should not be triggered
  263. ('brittle', {'Depends': 'libgreen1'}, 'autopkgtest')],
  264. {'green': (False, {'green': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'},
  265. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  266. 'darkgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  267. })
  268. },
  269. {'green': [('old-version', '1'), ('new-version', '2')]})[1]
  270. self.assertNotIn('brittle', exc['green']['policy_info']['autopkgtest'])
  271. # second run collects the results
  272. self.swift.set_results({'autopkgtest-testing': {
  273. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  274. 'testing/amd64/d/darkgreen/20150101_100001@': (0, 'darkgreen 1', tr('green/2')),
  275. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/2')),
  276. 'testing/amd64/l/lightgreen/20150101_100101@': (0, 'lightgreen 1', tr('green/2')),
  277. # version in testing fails
  278. 'testing/i386/g/green/20150101_020000@': (4, 'green 1', tr('green/1')),
  279. 'testing/amd64/g/green/20150101_020000@': (4, 'green 1', tr('green/1')),
  280. # version in unstable succeeds
  281. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  282. 'testing/amd64/g/green/20150101_100201@': (0, 'green 2', tr('green/2')),
  283. # new "brittle" succeeds
  284. 'testing/i386/b/brittle/20150101_100200@': (0, 'brittle 1', tr('brittle/1')),
  285. 'testing/amd64/b/brittle/20150101_100201@': (0, 'brittle 1', tr('brittle/1')),
  286. }})
  287. out = self.run_it(
  288. [],
  289. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  290. 'lightgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  291. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  292. }),
  293. 'brittle': (True, {'brittle/1': {'amd64': 'PASS', 'i386': 'PASS'}})
  294. },
  295. {'green': [('old-version', '1'), ('new-version', '2')]}
  296. )[0]
  297. # all tests ran, there should be no more pending ones
  298. self.assertEqual(self.pending_requests, {})
  299. # not expecting any failures to retrieve from swift
  300. self.assertNotIn('Failure', out, out)
  301. # caches the results and triggers
  302. with open(os.path.join(self.data.path, 'data/testing/state/autopkgtest-results.cache')) as f:
  303. res = json.load(f)
  304. self.assertEqual(res['green/1']['green']['amd64'],
  305. ['FAIL', '1', '20150101_020000@', 1420077600])
  306. self.assertEqual(set(res['green/2']), {'darkgreen', 'green', 'lightgreen'})
  307. self.assertEqual(res['green/2']['lightgreen']['i386'],
  308. ['PASS', '1', '20150101_100100@', 1420106460])
  309. # third run should not trigger any new tests, should all be in the
  310. # cache
  311. self.swift.set_results({})
  312. out = self.run_it(
  313. [],
  314. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  315. 'lightgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  316. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  317. })
  318. })[0]
  319. self.assertEqual(self.amqp_requests, set())
  320. self.assertEqual(self.pending_requests, {})
  321. self.assertNotIn('Failure', out, out)
  322. def test_multi_rdepends_with_tests_mixed(self):
  323. '''Multiple reverse dependencies with tests (mixed results)'''
  324. self.data.add_default_packages(green=False)
  325. # green has passed before on i386 only, therefore ALWAYSFAIL on amd64
  326. self.swift.set_results({'autopkgtest-testing': {
  327. 'testing/i386/g/green/20150101_100000@': (0, 'green 1', tr('passedbefore/1')),
  328. }})
  329. # first run requests tests and marks them as pending
  330. self.run_it(
  331. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  332. {'green': (False, {'green': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'},
  333. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  334. 'darkgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  335. })
  336. },
  337. {'green': [('old-version', '1'), ('new-version', '2')]})
  338. # second run collects the results
  339. self.swift.set_results({'autopkgtest-testing': {
  340. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  341. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  342. 'testing/amd64/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  343. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  344. 'testing/amd64/g/green/20150101_100201@': (4, 'green 2', tr('green/2')),
  345. # unrelated results (wrong trigger), ignore this!
  346. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/1')),
  347. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('blue/1')),
  348. }})
  349. out = self.run_it(
  350. [],
  351. {'green': (False, {'green/2': {'amd64': 'ALWAYSFAIL', 'i386': 'PASS'},
  352. 'lightgreen/1': {'amd64': 'REGRESSION', 'i386': 'RUNNING'},
  353. 'darkgreen/1': {'amd64': 'RUNNING', 'i386': 'PASS'},
  354. })
  355. })[0]
  356. self.assertIn('Update Excuses generation completed', out)
  357. # not expecting any failures to retrieve from swift
  358. self.assertNotIn('Failure', out)
  359. # there should be some pending ones
  360. self.assertEqual(self.pending_requests,
  361. {'green/2': {'darkgreen': ['amd64'], 'lightgreen': ['i386']}})
  362. def test_results_without_triggers(self):
  363. '''Old results without recorded triggers'''
  364. self.data.add_default_packages(green=False)
  365. self.swift.set_results({'autopkgtest-testing': {
  366. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1'),
  367. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1'),
  368. 'testing/amd64/l/lightgreen/20150101_100101@': (4, 'lightgreen 1'),
  369. 'testing/i386/g/green/20150101_100100@': (0, 'green 1', tr('passedbefore/1')),
  370. 'testing/i386/g/green/20150101_100200@': (0, 'green 2'),
  371. 'testing/amd64/g/green/20150101_100201@': (4, 'green 2'),
  372. }})
  373. # none of the above results should be accepted
  374. self.run_it(
  375. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  376. {'green': (False, {'green': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'},
  377. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  378. 'darkgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  379. })
  380. })
  381. # there should be some pending ones
  382. self.assertEqual(self.pending_requests,
  383. {'green/2': {'lightgreen': ['amd64', 'i386'],
  384. 'green': ['amd64', 'i386'],
  385. 'darkgreen': ['amd64', 'i386']}})
  386. def test_multi_rdepends_with_tests_regression(self):
  387. '''Multiple reverse dependencies with tests (regression)'''
  388. self.data.add_default_packages(green=False)
  389. self.swift.set_results({'autopkgtest-testing': {
  390. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  391. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  392. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  393. 'testing/i386/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  394. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  395. 'testing/amd64/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  396. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  397. 'testing/amd64/g/green/20150101_100200@': (0, 'green 2', tr('green/1')),
  398. 'testing/amd64/g/green/20150101_100201@': (4, 'green 2', tr('green/2')),
  399. }})
  400. out, exc, _ = self.run_it(
  401. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  402. {'green': (False, {'green/2': {'amd64': 'REGRESSION', 'i386': 'PASS'},
  403. 'lightgreen/1': {'amd64': 'REGRESSION', 'i386': 'REGRESSION'},
  404. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  405. })
  406. },
  407. {'green': [('old-version', '1'), ('new-version', '2')]}
  408. )
  409. # should have links to log and history, but no artifacts (as this is
  410. # not a PPA)
  411. self.assertEqual(exc['green']['policy_info']['autopkgtest']['lightgreen/1']['amd64'][:4],
  412. ['REGRESSION',
  413. 'http://localhost:18085/autopkgtest-testing/testing/amd64/l/lightgreen/20150101_100101@/log.gz',
  414. 'https://autopkgtest.ubuntu.com/packages/l/lightgreen/testing/amd64',
  415. None])
  416. # should have retry link for the regressions (not a stable URL, test
  417. # seaprately)
  418. link = urllib.parse.urlparse(exc['green']['policy_info']['autopkgtest']['lightgreen/1']['amd64'][4])
  419. self.assertEqual(link.netloc, 'autopkgtest.ubuntu.com')
  420. self.assertEqual(link.path, '/request.cgi')
  421. self.assertEqual(urllib.parse.parse_qs(link.query),
  422. {'release': ['testing'], 'arch': ['amd64'],
  423. 'package': ['lightgreen'], 'trigger': ['green/2']})
  424. # we already had all results before the run, so this should not trigger
  425. # any new requests
  426. self.assertEqual(self.amqp_requests, set())
  427. self.assertEqual(self.pending_requests, {})
  428. # not expecting any failures to retrieve from swift
  429. self.assertNotIn('Failure', out, out)
  430. def test_multi_rdepends_with_tests_regression_last_pass(self):
  431. '''Multiple reverse dependencies with tests (regression), last one passes
  432. This ensures that we don't just evaluate the test result of the last
  433. test, but all of them.
  434. '''
  435. self.data.add_default_packages(green=False)
  436. self.swift.set_results({'autopkgtest-testing': {
  437. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  438. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  439. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/2')),
  440. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/2')),
  441. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  442. 'testing/amd64/g/green/20150101_100200@': (0, 'green 2', tr('green/1')),
  443. 'testing/amd64/g/green/20150101_100201@': (4, 'green 2', tr('green/2')),
  444. }})
  445. out = self.run_it(
  446. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  447. {'green': (False, {'green/2': {'amd64': 'REGRESSION', 'i386': 'PASS'},
  448. 'lightgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  449. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  450. })
  451. },
  452. {'green': [('old-version', '1'), ('new-version', '2')]}
  453. )[0]
  454. self.assertEqual(self.pending_requests, {})
  455. # not expecting any failures to retrieve from swift
  456. self.assertNotIn('Failure', out, out)
  457. def test_multi_rdepends_with_tests_always_failed(self):
  458. '''Multiple reverse dependencies with tests (always failed)'''
  459. self.data.add_default_packages(green=False)
  460. self.swift.set_results({'autopkgtest-testing': {
  461. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  462. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  463. 'testing/i386/l/lightgreen/20150101_100100@': (4, 'lightgreen 1', tr('green/1')),
  464. 'testing/i386/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  465. 'testing/amd64/l/lightgreen/20150101_100100@': (4, 'lightgreen 1', tr('green/1')),
  466. 'testing/amd64/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  467. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  468. 'testing/amd64/g/green/20150101_100200@': (4, 'green 2', tr('green/1')),
  469. 'testing/amd64/g/green/20150101_100201@': (4, 'green 2', tr('green/2')),
  470. }})
  471. out = self.run_it(
  472. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  473. {'green': (True, {'green/2': {'amd64': 'ALWAYSFAIL', 'i386': 'PASS'},
  474. 'lightgreen/1': {'amd64': 'ALWAYSFAIL', 'i386': 'ALWAYSFAIL'},
  475. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  476. })
  477. },
  478. {'green': [('old-version', '1'), ('new-version', '2')]}
  479. )[0]
  480. self.assertEqual(self.pending_requests, {})
  481. # not expecting any failures to retrieve from swift
  482. self.assertNotIn('Failure', out, out)
  483. def test_multi_rdepends_arch_specific(self):
  484. '''Multiple reverse dependencies with arch specific tests'''
  485. self.data.add_default_packages(green=False)
  486. # green has passed before on amd64, doesn't exist on i386
  487. self.swift.set_results({'autopkgtest-testing': {
  488. 'testing/amd64/g/green64/20150101_100000@': (0, 'green64 0.1', tr('passedbefore/1')),
  489. }})
  490. self.data.add('green64', False, {'Depends': 'libc6 (>= 0.9), libgreen1',
  491. 'Architecture': 'amd64'},
  492. testsuite='autopkgtest')
  493. # first run requests tests and marks them as pending
  494. self.run_it(
  495. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  496. {'green': (False, {'green': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  497. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  498. 'darkgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  499. 'green64': {'amd64': 'RUNNING'},
  500. })
  501. })
  502. self.assertEqual(
  503. self.amqp_requests,
  504. set(['debci-testing-i386:green {"triggers": ["green/2"]}',
  505. 'debci-testing-amd64:green {"triggers": ["green/2"]}',
  506. 'debci-testing-i386:lightgreen {"triggers": ["green/2"]}',
  507. 'debci-testing-amd64:lightgreen {"triggers": ["green/2"]}',
  508. 'debci-testing-i386:darkgreen {"triggers": ["green/2"]}',
  509. 'debci-testing-amd64:darkgreen {"triggers": ["green/2"]}',
  510. 'debci-testing-amd64:green64 {"triggers": ["green/2"]}']))
  511. self.assertEqual(self.pending_requests,
  512. {'green/2': {'lightgreen': ['amd64', 'i386'],
  513. 'darkgreen': ['amd64', 'i386'],
  514. 'green64': ['amd64'],
  515. 'green': ['amd64', 'i386']}})
  516. # second run collects the results
  517. self.swift.set_results({'autopkgtest-testing': {
  518. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  519. 'testing/amd64/d/darkgreen/20150101_100001@': (0, 'darkgreen 1', tr('green/2')),
  520. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/2')),
  521. 'testing/amd64/l/lightgreen/20150101_100101@': (0, 'lightgreen 1', tr('green/2')),
  522. # version in testing fails
  523. 'testing/i386/g/green/20150101_020000@': (4, 'green 1', tr('green/1')),
  524. 'testing/amd64/g/green/20150101_020000@': (4, 'green 1', tr('green/1')),
  525. # version in unstable succeeds
  526. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  527. 'testing/amd64/g/green/20150101_100201@': (0, 'green 2', tr('green/2')),
  528. # only amd64 result for green64
  529. 'testing/amd64/g/green64/20150101_100200@': (0, 'green64 1', tr('green/2')),
  530. }})
  531. out = self.run_it(
  532. [],
  533. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  534. 'lightgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  535. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  536. 'green64/1': {'amd64': 'PASS'},
  537. })
  538. },
  539. {'green': [('old-version', '1'), ('new-version', '2')]}
  540. )[0]
  541. # all tests ran, there should be no more pending ones
  542. self.assertEqual(self.amqp_requests, set())
  543. self.assertEqual(self.pending_requests, {})
  544. # not expecting any failures to retrieve from swift
  545. self.assertNotIn('Failure', out, out)
  546. def test_unbuilt(self):
  547. '''Unbuilt package should not trigger tests or get considered'''
  548. self.data.add_default_packages(green=False)
  549. self.data.add_src('green', True, {'Version': '2', 'Testsuite': 'autopkgtest'})
  550. self.data.add('libgreen1', True, {'Source': 'green',
  551. 'Depends': 'libc6 (>= 0.9)'},
  552. testsuite='autopkgtest', add_src=False)
  553. self.data.add('green', True, {'Depends': 'libc6 (>= 0.9), libgreen1',
  554. 'Conflicts': 'blue'},
  555. testsuite='autopkgtest', add_src=False)
  556. exc = self.run_it(
  557. # uninstallable unstable version
  558. [],
  559. {'green': (False, {})},
  560. {'green': [('old-version', '1'), ('new-version', '2'),
  561. ('missing-builds', ON_ALL_ARCHES),
  562. ]
  563. })[1]
  564. # autopkgtest should not be triggered for unbuilt pkg
  565. self.assertEqual(exc['green']['policy_info']['autopkgtest'], {'verdict': 'REJECTED_TEMPORARILY'})
  566. self.assertEqual(self.amqp_requests, set())
  567. self.assertEqual(self.pending_requests, {})
  568. def test_unbuilt_not_in_testing(self):
  569. '''Unbuilt package should not trigger tests or get considered (package not in testing)'''
  570. self.data.add_default_packages(green=False)
  571. self.sourceppa_cache['lime'] = {'1': ''}
  572. self.data.add_src('lime', True, {'Version': '1', 'Testsuite': 'autopkgtest'})
  573. exc = self.run_it(
  574. # unbuilt unstable version
  575. [],
  576. {'lime': (False, {})},
  577. {'lime': [('old-version', '-'), ('new-version', '1'),
  578. ('reason', 'no-binaries'),
  579. ]
  580. })[1]
  581. # autopkgtest should not be triggered for unbuilt pkg
  582. self.assertEqual(exc['lime']['policy_info']['autopkgtest'], {'verdict': 'REJECTED_TEMPORARILY'})
  583. self.assertEqual(self.amqp_requests, set())
  584. self.assertEqual(self.pending_requests, {})
  585. def test_partial_unbuilt(self):
  586. '''Unbuilt package on some arches should not trigger tests on those arches'''
  587. self.data.add_default_packages(green=False)
  588. self.data.add_src('green', True, {'Version': '2', 'Testsuite': 'autopkgtest'})
  589. self.data.add('libgreen1', True, {'Version': '2', 'Source': 'green', 'Architecture': 'i386'}, add_src=False)
  590. self.data.add('green', True, {'Depends': 'libc6 (>= 0.9), libgreen1',
  591. 'Conflicts': 'blue'},
  592. testsuite='autopkgtest', add_src=False)
  593. self.swift.set_results({'autopkgtest-testing': {
  594. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  595. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/2')),
  596. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  597. }})
  598. exc = self.run_it(
  599. [],
  600. {'green': (False, {})},
  601. {'green': [('old-version', '1'), ('new-version', '2'),
  602. ('missing-builds', {'on-architectures': ['amd64', 'arm64', 'armhf', 'powerpc', 'ppc64el'],
  603. 'on-unimportant-architectures': []})
  604. ]
  605. })[1]
  606. # autopkgtest should not be triggered on arches with unbuilt pkg
  607. self.assertEqual(exc['green']['policy_info']['autopkgtest']['verdict'], 'REJECTED_TEMPORARILY')
  608. self.assertEqual(self.amqp_requests, set())
  609. self.assertEqual(self.pending_requests, {})
  610. def test_partial_unbuilt_block(self):
  611. '''Unbuilt blocked package on some arches should not trigger tests on those arches'''
  612. self.data.add_default_packages(green=False)
  613. self.create_hint('freeze', 'block-all source')
  614. self.data.add_src('green', True, {'Version': '2', 'Testsuite': 'autopkgtest'})
  615. self.data.add('libgreen1', True, {'Version': '2', 'Source': 'green', 'Architecture': 'i386'}, add_src=False)
  616. self.data.add('green', True, {'Depends': 'libc6 (>= 0.9), libgreen1',
  617. 'Conflicts': 'blue'},
  618. testsuite='autopkgtest', add_src=False)
  619. self.swift.set_results({'autopkgtest-testing': {
  620. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  621. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/2')),
  622. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  623. }})
  624. exc = self.run_it(
  625. [],
  626. {'green': (False, {})},
  627. {'green': [('old-version', '1'), ('new-version', '2'),
  628. ('missing-builds', {'on-architectures': ['amd64', 'arm64', 'armhf', 'powerpc', 'ppc64el'],
  629. 'on-unimportant-architectures': []})
  630. ]
  631. })[1]
  632. # autopkgtest should not be triggered on arches with unbuilt pkg
  633. self.assertEqual(exc['green']['policy_info']['autopkgtest']['verdict'], 'REJECTED_TEMPORARILY')
  634. self.assertEqual(self.amqp_requests, set())
  635. self.assertEqual(self.pending_requests, {})
  636. def test_rdepends_unbuilt(self):
  637. '''Unbuilt reverse dependency'''
  638. self.data.add_default_packages(green=False, lightgreen=False)
  639. # old lightgreen fails, thus new green should be held back
  640. self.swift.set_results({'autopkgtest-testing': {
  641. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/1.1')),
  642. 'testing/amd64/d/darkgreen/20150101_100001@': (0, 'darkgreen 1', tr('green/1.1')),
  643. 'testing/i386/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('green/1')),
  644. 'testing/i386/l/lightgreen/20150101_100100@': (4, 'lightgreen 1', tr('green/1.1')),
  645. 'testing/amd64/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('green/1')),
  646. 'testing/amd64/l/lightgreen/20150101_100100@': (4, 'lightgreen 1', tr('green/1.1')),
  647. 'testing/i386/g/green/20150101_020000@': (0, 'green 1', tr('green/1')),
  648. 'testing/amd64/g/green/20150101_020000@': (0, 'green 1', tr('green/1')),
  649. 'testing/i386/g/green/20150101_100200@': (0, 'green 1.1', tr('green/1.1')),
  650. 'testing/amd64/g/green/20150101_100201@': (0, 'green 1.1', tr('green/1.1')),
  651. }})
  652. # add unbuilt lightgreen; should run tests against the old version
  653. self.data.add_src('lightgreen', True, {'Version': '2', 'Testsuite': 'autopkgtest'})
  654. self.data.add('lightgreen', True, {'Depends': 'libgreen1'},
  655. testsuite='autopkgtest', add_src=False)
  656. self.run_it(
  657. [('libgreen1', {'Version': '1.1', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  658. {'green': (False, {'green/1.1': {'amd64': 'PASS', 'i386': 'PASS'},
  659. 'lightgreen/1': {'amd64': 'REGRESSION', 'i386': 'REGRESSION'},
  660. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  661. }),
  662. 'lightgreen': (False, {}),
  663. },
  664. {'green': [('old-version', '1'), ('new-version', '1.1')],
  665. 'lightgreen': [('old-version', '1'), ('new-version', '2'),
  666. ('missing-builds', ON_ALL_ARCHES)],
  667. }
  668. )
  669. self.assertEqual(self.amqp_requests, set())
  670. self.assertEqual(self.pending_requests, {})
  671. # next run should not trigger any new requests
  672. self.run_it([], {'green': (False, {}), 'lightgreen': (False, {})})
  673. self.assertEqual(self.amqp_requests, set())
  674. self.assertEqual(self.pending_requests, {})
  675. # now lightgreen 2 gets built, should trigger a new test run
  676. self.data.remove_all(True)
  677. self.data.add('libc6', True)
  678. self.data.add('darkgreen', True, {'Depends': 'libgreen1'},
  679. testsuite='autopkgtest-pkg-foo')
  680. self.data.add('blue', True, {'Depends': 'libc6 (>= 0.9)',
  681. 'Conflicts': 'green'},
  682. testsuite='specialtest')
  683. self.data.add('black', True, {},
  684. testsuite='autopkgtest')
  685. self.data.add('grey', True, {},
  686. testsuite='autopkgtest')
  687. self.run_it(
  688. [('libgreen1', {'Version': '1.1', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest'),
  689. ('lightgreen', {'Version': '2'}, 'autopkgtest')],
  690. {})
  691. self.assertEqual(self.amqp_requests,
  692. set(['debci-testing-amd64:lightgreen {"triggers": ["lightgreen/2"]}',
  693. 'debci-testing-i386:lightgreen {"triggers": ["lightgreen/2"]}']))
  694. # next run collects the results
  695. self.swift.set_results({'autopkgtest-testing': {
  696. 'testing/i386/l/lightgreen/20150101_100200@': (0, 'lightgreen 2', tr('lightgreen/2')),
  697. 'testing/amd64/l/lightgreen/20150101_102000@': (0, 'lightgreen 2', tr('lightgreen/2')),
  698. }})
  699. self.run_it(
  700. [],
  701. # green hasn't changed, the above re-run was for trigger lightgreen/2
  702. {'green': (False, {'green/1.1': {'amd64': 'PASS', 'i386': 'PASS'},
  703. 'lightgreen/1': {'amd64': 'REGRESSION', 'i386': 'REGRESSION'},
  704. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  705. }),
  706. 'lightgreen': (True, {'lightgreen/2': {'amd64': 'PASS', 'i386': 'PASS'}}),
  707. },
  708. {'green': [('old-version', '1'), ('new-version', '1.1')],
  709. 'lightgreen': [('old-version', '1'), ('new-version', '2')],
  710. }
  711. )
  712. self.assertEqual(self.amqp_requests, set())
  713. self.assertEqual(self.pending_requests, {})
  714. def test_rdepends_unbuilt_unstable_only(self):
  715. '''Unbuilt reverse dependency which is not in testing'''
  716. self.data.add_default_packages(green=False)
  717. self.swift.set_results({'autopkgtest-testing': {
  718. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  719. 'testing/amd64/d/darkgreen/20150101_100001@': (0, 'darkgreen 1', tr('green/2')),
  720. 'testing/i386/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('green/2')),
  721. 'testing/amd64/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('green/2')),
  722. 'testing/i386/g/green/20150101_020000@': (0, 'green 1', tr('green/1')),
  723. 'testing/amd64/g/green/20150101_020000@': (0, 'green 1', tr('green/1')),
  724. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  725. 'testing/amd64/g/green/20150101_100201@': (0, 'green 2', tr('green/2')),
  726. }})
  727. # run britney once to pick up previous results
  728. self.run_it(
  729. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  730. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'}})})
  731. # add new uninstallable brokengreen; should not run test at all
  732. exc = self.run_it(
  733. [('brokengreen', {'Version': '1', 'Depends': 'libgreen1, nonexisting'}, 'autopkgtest')],
  734. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'}}),
  735. 'brokengreen': (False, {}),
  736. },
  737. {'green': [('old-version', '1'), ('new-version', '2')],
  738. 'brokengreen': [('old-version', '-'), ('new-version', '1'),
  739. ('reason', 'depends'),
  740. ('excuses', 'brokengreen/amd64 unsatisfiable Depends: nonexisting')],
  741. })[1]
  742. # autopkgtest should not be triggered for uninstallable pkg
  743. self.assertEqual(exc['brokengreen']['policy_info']['autopkgtest'], {'verdict': 'REJECTED_TEMPORARILY'})
  744. self.assertEqual(self.amqp_requests, set())
  745. def test_rdepends_unbuilt_new_version_result(self):
  746. '''Unbuilt reverse dependency gets test result for newer version
  747. This might happen if the autopkgtest infrastructure runs the unstable
  748. source tests against the testing binaries. Even if that gets done
  749. properly it might still happen that at the time of the britney run the
  750. package isn't built yet, but it is once the test gets run.
  751. '''
  752. self.data.add_default_packages(green=False, lightgreen=False)
  753. # old lightgreen fails, thus new green should be held back
  754. self.swift.set_results({'autopkgtest-testing': {
  755. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/1.1')),
  756. 'testing/amd64/d/darkgreen/20150101_100001@': (0, 'darkgreen 1', tr('green/1.1')),
  757. 'testing/i386/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('green/1')),
  758. 'testing/i386/l/lightgreen/20150101_100100@': (4, 'lightgreen 1', tr('green/1.1')),
  759. 'testing/amd64/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('green/1')),
  760. 'testing/amd64/l/lightgreen/20150101_100100@': (4, 'lightgreen 1', tr('green/1.1')),
  761. 'testing/i386/g/green/20150101_020000@': (0, 'green 1', tr('green/1')),
  762. 'testing/amd64/g/green/20150101_020000@': (0, 'green 1', tr('green/1')),
  763. 'testing/i386/g/green/20150101_100200@': (0, 'green 1.1', tr('green/1.1')),
  764. 'testing/amd64/g/green/20150101_100201@': (0, 'green 1.1', tr('green/1.1')),
  765. }})
  766. # add unbuilt lightgreen; should run tests against the old version
  767. self.data.add_src('lightgreen', True, {'Version': '2', 'Testsuite': 'autopkgtest'})
  768. self.data.add('lightgreen', True, {'Depends': 'libgreen1'},
  769. testsuite='autopkgtest', add_src=False)
  770. self.run_it(
  771. [('libgreen1', {'Version': '1.1', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  772. {'green': (False, {'green/1.1': {'amd64': 'PASS', 'i386': 'PASS'},
  773. 'lightgreen/1': {'amd64': 'REGRESSION', 'i386': 'REGRESSION'},
  774. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  775. }),
  776. 'lightgreen': (False, {}),
  777. },
  778. {'green': [('old-version', '1'), ('new-version', '1.1')],
  779. 'lightgreen': [('old-version', '1'), ('new-version', '2'),
  780. ('missing-builds', ON_ALL_ARCHES)]
  781. }
  782. )
  783. self.assertEqual(self.amqp_requests, set())
  784. self.assertEqual(self.pending_requests, {})
  785. # lightgreen 2 stays unbuilt in britney, but we get a test result for it
  786. self.swift.set_results({'autopkgtest-testing': {
  787. 'testing/i386/l/lightgreen/20150101_100200@': (0, 'lightgreen 2', tr('green/1.1')),
  788. 'testing/amd64/l/lightgreen/20150101_102000@': (0, 'lightgreen 2', tr('green/1.1')),
  789. }})
  790. self.run_it(
  791. [],
  792. {'green': (True, {'green/1.1': {'amd64': 'PASS', 'i386': 'PASS'},
  793. 'lightgreen/2': {'amd64': 'PASS', 'i386': 'PASS'},
  794. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  795. }),
  796. 'lightgreen': (False, {}),
  797. },
  798. {'green': [('old-version', '1'), ('new-version', '1.1')],
  799. 'lightgreen': [('old-version', '1'), ('new-version', '2'),
  800. ('missing-builds', ON_ALL_ARCHES)]
  801. }
  802. )
  803. self.assertEqual(self.amqp_requests, set())
  804. self.assertEqual(self.pending_requests, {})
  805. # next run should not trigger any new requests
  806. self.run_it([], {'green': (True, {}), 'lightgreen': (False, {})})
  807. self.assertEqual(self.amqp_requests, set())
  808. self.assertEqual(self.pending_requests, {})
  809. def test_rdepends_unbuilt_new_version_fail(self):
  810. '''Unbuilt reverse dependency gets failure for newer version'''
  811. self.data.add_default_packages(green=False, lightgreen=False)
  812. self.swift.set_results({'autopkgtest-testing': {
  813. 'testing/i386/l/lightgreen/20150101_100101@': (0, 'lightgreen 1', tr('lightgreen/1')),
  814. }})
  815. # add unbuilt lightgreen; should request tests against the old version
  816. self.data.add_src('lightgreen', True, {'Version': '2', 'Testsuite': 'autopkgtest'})
  817. self.data.add('lightgreen', True, {'Depends': 'libgreen1'},
  818. testsuite='autopkgtest', add_src=False)
  819. self.run_it(
  820. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  821. {'green': (False, {'green': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  822. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'},
  823. 'darkgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  824. }),
  825. 'lightgreen': (False, {}),
  826. },
  827. {'green': [('old-version', '1'), ('new-version', '2')],
  828. 'lightgreen': [('old-version', '1'), ('new-version', '2'),
  829. ('missing-builds', ON_ALL_ARCHES)],
  830. }
  831. )
  832. self.assertEqual(len(self.amqp_requests), 6)
  833. # we only get a result for lightgreen 2, not for the requested 1
  834. self.swift.set_results({'autopkgtest-testing': {
  835. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  836. 'testing/amd64/d/darkgreen/20150101_100001@': (0, 'darkgreen 1', tr('green/2')),
  837. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 0.5', tr('green/1')),
  838. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 0.5', tr('green/1')),
  839. 'testing/i386/l/lightgreen/20150101_100200@': (4, 'lightgreen 2', tr('green/2')),
  840. 'testing/amd64/l/lightgreen/20150101_100200@': (4, 'lightgreen 2', tr('green/2')),
  841. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  842. 'testing/amd64/g/green/20150101_100201@': (0, 'green 2', tr('green/2')),
  843. }})
  844. self.run_it(
  845. [],
  846. {'green': (False, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  847. 'lightgreen/2': {'amd64': 'REGRESSION', 'i386': 'REGRESSION'},
  848. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  849. }),
  850. 'lightgreen': (False, {}),
  851. },
  852. {'green': [('old-version', '1'), ('new-version', '2')],
  853. 'lightgreen': [('old-version', '1'), ('new-version', '2'),
  854. ('missing-builds', ON_ALL_ARCHES)],
  855. }
  856. )
  857. self.assertEqual(self.amqp_requests, set())
  858. self.assertEqual(self.pending_requests, {})
  859. # next run should not trigger any new requests
  860. self.run_it([], {'green': (False, {}), 'lightgreen': (False, {})})
  861. self.assertEqual(self.pending_requests, {})
  862. self.assertEqual(self.amqp_requests, set())
  863. # # def test_same_version_binary_in_unstable(self):
  864. # # '''binary from new architecture in unstable with testing version'''
  865. # #
  866. # # # Invalid dataset in Debian and Ubuntu: ... ARCHITECTURE all != i386
  867. # # self.data.add('lightgreen', False)
  868. # #
  869. # # # i386 is in testing already, but amd64 just recently built and is in unstable
  870. # # self.data.add_src('brown', False, {'Testsuite': 'autopkgtest'})
  871. # # self.data.add_src('brown', True, {'Testsuite': 'autopkgtest'})
  872. # # self.data.add('brown', False, {'Architecture': 'i386'}, add_src=False)
  873. # # self.data.add('brown', True, {}, add_src=False)
  874. # #
  875. # # exc = self.run_it(
  876. # # # we need some other package to create unstable Sources
  877. # # [('lightgreen', {'Version': '2'}, 'autopkgtest')],
  878. # # {'brown': (True, {})}
  879. # # )[1]
  880. # # self.assertEqual(exc['brown']['item-name'], 'brown/amd64')
  881. def test_package_pair_running(self):
  882. '''Two packages in unstable that need to go in together (running)'''
  883. self.data.add_default_packages(green=False, lightgreen=False)
  884. # green has passed before on i386 only, therefore ALWAYSFAIL on amd64
  885. self.swift.set_results({'autopkgtest-testing': {
  886. 'testing/i386/g/green/20150101_100000@': (0, 'green 1', tr('passedbefore/1')),
  887. }})
  888. self.run_it(
  889. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest'),
  890. ('lightgreen', {'Version': '2', 'Depends': 'libgreen1 (>= 2)'}, 'autopkgtest')],
  891. {'green': (False, {'green': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'},
  892. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  893. 'darkgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  894. }),
  895. 'lightgreen': (False, {'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'}}),
  896. },
  897. {'green': [('old-version', '1'), ('new-version', '2')],
  898. 'lightgreen': [('old-version', '1'), ('new-version', '2')],
  899. })
  900. # we expect the package's and its reverse dependencies' tests to get
  901. # triggered; lightgreen should be triggered for each trigger
  902. self.assertEqual(
  903. self.amqp_requests,
  904. set(['debci-testing-i386:green {"triggers": ["green/2"]}',
  905. 'debci-testing-amd64:green {"triggers": ["green/2"]}',
  906. 'debci-testing-i386:lightgreen {"triggers": ["green/2"]}',
  907. 'debci-testing-amd64:lightgreen {"triggers": ["green/2"]}',
  908. 'debci-testing-i386:lightgreen {"triggers": ["lightgreen/2 green/2"]}',
  909. 'debci-testing-amd64:lightgreen {"triggers": ["lightgreen/2 green/2"]}',
  910. 'debci-testing-i386:darkgreen {"triggers": ["green/2"]}',
  911. 'debci-testing-amd64:darkgreen {"triggers": ["green/2"]}']))
  912. # ... and that they get recorded as pending
  913. self.assertEqual(self.pending_requests,
  914. {'lightgreen/2': {'lightgreen': ['amd64', 'i386']},
  915. 'green/2': {'darkgreen': ['amd64', 'i386'],
  916. 'green': ['amd64', 'i386'],
  917. 'lightgreen': ['amd64', 'i386']}})
  918. def test_binary_from_new_source_package_running(self):
  919. '''building an existing binary for a new source package (running)'''
  920. self.data.add_default_packages(green=False)
  921. self.run_it(
  922. [('libgreen1', {'Version': '2', 'Source': 'newgreen', 'Depends': 'libc6'}, 'autopkgtest')],
  923. {'newgreen': (True, {'newgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  924. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  925. 'darkgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  926. }),
  927. },
  928. {'newgreen': [('old-version', '-'), ('new-version', '2')]})
  929. self.assertEqual(len(self.amqp_requests), 8)
  930. self.assertEqual(self.pending_requests,
  931. {'newgreen/2': {'darkgreen': ['amd64', 'i386'],
  932. 'green': ['amd64', 'i386'],
  933. 'lightgreen': ['amd64', 'i386'],
  934. 'newgreen': ['amd64', 'i386']}})
  935. def test_blacklisted_fail(self):
  936. '''blacklisted packages return exit code 99 and version blacklisted,
  937. check they are handled correctly'''
  938. self.data.add_default_packages(black=False, grey=False)
  939. self.data.add('brown', False, {'Depends': 'grey'}, testsuite='autopkgtest')
  940. self.data.add('brown', True, {'Depends': 'grey'}, testsuite='autopkgtest')
  941. self.swift.set_results({'autopkgtest-testing': {
  942. 'testing/amd64/b/black/20150101_100000@': (0, 'black 1', tr('black/1')),
  943. 'testing/amd64/b/black/20150102_100000@': (99, 'black blacklisted', tr('black/2')),
  944. 'testing/amd64/g/grey/20150101_100000@': (99, 'grey blacklisted', tr('grey/1')),
  945. 'testing/amd64/b/brown/20150101_100000@': (99, 'brown blacklisted', tr('grey/2')),
  946. }})
  947. self.run_it(
  948. [('black', {'Version': '2'}, 'autopkgtest'),
  949. ('grey', {'Version': '2'}, 'autopkgtest')],
  950. {'black': (False, {'black/blacklisted': {'amd64': 'REGRESSION'},
  951. 'black': {'i386': 'RUNNING-ALWAYSFAIL'}}),
  952. 'grey': (True, {'grey': {'amd64': 'RUNNING-ALWAYSFAIL'},
  953. 'brown/blacklisted': {'amd64': 'ALWAYSFAIL'},
  954. 'brown': {'i386': 'RUNNING-ALWAYSFAIL'}})
  955. })
  956. self.assertEqual(len(self.amqp_requests), 4)
  957. self.assertEqual(self.pending_requests,
  958. {'black/2': {'black': ['i386']},
  959. 'grey/2': {'grey': ['amd64', 'i386'],
  960. 'brown': ['i386']}})
  961. def test_blacklisted_force(self):
  962. '''blacklisted packages return exit code 99 and version all, check they
  963. are handled correctly'''
  964. self.data.add_default_packages(black=False)
  965. self.swift.set_results({'autopkgtest-testing': {
  966. 'testing/amd64/b/black/20150101_100000@': (0, 'black 1', tr('black/1')),
  967. 'testing/amd64/b/black/20150102_100000@': (99, 'black blacklisted', tr('black/2')),
  968. 'testing/i386/b/black/20150101_100000@': (0, 'black 1', tr('black/1')),
  969. 'testing/i386/b/black/20150102_100000@': (99, 'black blacklisted', tr('black/2')),
  970. }})
  971. self.create_hint('autopkgtest', 'force-badtest black/blacklisted')
  972. self.run_it(
  973. [('black', {'Version': '2'}, 'autopkgtest')],
  974. {'black': (True, {'black/blacklisted': {'amd64': 'IGNORE-FAIL',
  975. 'i386': 'IGNORE-FAIL'}})
  976. },
  977. {'black': [('old-version', '1'), ('new-version', '2')]})
  978. self.assertEqual(len(self.amqp_requests), 0)
  979. def test_binary_from_new_source_package_pass(self):
  980. '''building an existing binary for a new source package (pass)'''
  981. self.data.add_default_packages(green=False)
  982. self.swift.set_results({'autopkgtest-testing': {
  983. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('newgreen/2')),
  984. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('newgreen/2')),
  985. 'testing/i386/g/green/20150101_100000@': (0, 'green 1', tr('newgreen/2')),
  986. 'testing/amd64/g/green/20150101_100000@': (0, 'green 1', tr('newgreen/2')),
  987. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('newgreen/2')),
  988. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('newgreen/2')),
  989. 'testing/i386/n/newgreen/20150101_100200@': (0, 'newgreen 2', tr('newgreen/2')),
  990. 'testing/amd64/n/newgreen/20150101_100201@': (0, 'newgreen 2', tr('newgreen/2')),
  991. }})
  992. self.run_it(
  993. [('libgreen1', {'Version': '2', 'Source': 'newgreen', 'Depends': 'libc6'}, 'autopkgtest')],
  994. {'newgreen': (True, {'newgreen/2': {'amd64': 'PASS', 'i386': 'PASS'},
  995. 'lightgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  996. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  997. 'green/1': {'amd64': 'PASS', 'i386': 'PASS'},
  998. }),
  999. },
  1000. {'newgreen': [('old-version', '-'), ('new-version', '2')]})
  1001. self.assertEqual(self.amqp_requests, set())
  1002. self.assertEqual(self.pending_requests, {})
  1003. def test_result_from_older_version(self):
  1004. '''test result from older version than the uploaded one'''
  1005. self.data.add_default_packages(darkgreen=False)
  1006. self.swift.set_results({'autopkgtest-testing': {
  1007. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('darkgreen/1')),
  1008. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('darkgreen/1')),
  1009. }})
  1010. self.run_it(
  1011. [('darkgreen', {'Version': '2', 'Depends': 'libc6 (>= 0.9), libgreen1'}, 'autopkgtest')],
  1012. {'darkgreen': (False, {'darkgreen': {'amd64': 'RUNNING', 'i386': 'RUNNING'}})})
  1013. self.assertEqual(
  1014. self.amqp_requests,
  1015. set(['debci-testing-i386:darkgreen {"triggers": ["darkgreen/2"]}',
  1016. 'debci-testing-amd64:darkgreen {"triggers": ["darkgreen/2"]}']))
  1017. self.assertEqual(self.pending_requests,
  1018. {'darkgreen/2': {'darkgreen': ['amd64', 'i386']}})
  1019. # second run gets the results for darkgreen 2
  1020. self.swift.set_results({'autopkgtest-testing': {
  1021. 'testing/i386/d/darkgreen/20150101_100010@': (0, 'darkgreen 2', tr('darkgreen/2')),
  1022. 'testing/amd64/d/darkgreen/20150101_100010@': (0, 'darkgreen 2', tr('darkgreen/2')),
  1023. }})
  1024. self.run_it(
  1025. [],
  1026. {'darkgreen': (True, {'darkgreen/2': {'amd64': 'PASS', 'i386': 'PASS'}})})
  1027. self.assertEqual(self.amqp_requests, set())
  1028. self.assertEqual(self.pending_requests, {})
  1029. # next run sees a newer darkgreen, should re-run tests
  1030. self.data.remove_all(True)
  1031. self.data.add('libc6', True)
  1032. self.data.add('libgreen1', True, {'Source': 'green',
  1033. 'Depends': 'libc6 (>= 0.9)'},
  1034. testsuite='autopkgtest')
  1035. self.data.add('green', True, {'Depends': 'libc6 (>= 0.9), libgreen1',
  1036. 'Conflicts': 'blue'},
  1037. testsuite='autopkgtest')
  1038. self.data.add('lightgreen', True, {'Depends': 'libgreen1'},
  1039. testsuite='autopkgtest')
  1040. self.data.add('blue', True, {'Depends': 'libc6 (>= 0.9)',
  1041. 'Conflicts': 'green'},
  1042. testsuite='specialtest')
  1043. self.data.add('black', True, {},
  1044. testsuite='autopkgtest')
  1045. self.data.add('grey', True, {},
  1046. testsuite='autopkgtest')
  1047. self.run_it(
  1048. [('darkgreen', {'Version': '3', 'Depends': 'libc6 (>= 0.9), libgreen1'}, 'autopkgtest')],
  1049. {'darkgreen': (False, {'darkgreen': {'amd64': 'RUNNING', 'i386': 'RUNNING'}})})
  1050. self.assertEqual(
  1051. self.amqp_requests,
  1052. set(['debci-testing-i386:darkgreen {"triggers": ["darkgreen/3"]}',
  1053. 'debci-testing-amd64:darkgreen {"triggers": ["darkgreen/3"]}']))
  1054. self.assertEqual(self.pending_requests,
  1055. {'darkgreen/3': {'darkgreen': ['amd64', 'i386']}})
  1056. def test_old_result_from_rdep_version(self):
  1057. '''re-runs reverse dependency test on new versions'''
  1058. self.data.add_default_packages(green=False)
  1059. self.swift.set_results({'autopkgtest-testing': {
  1060. 'testing/i386/g/green/20150101_100000@': (0, 'green 1', tr('green/1')),
  1061. 'testing/amd64/g/green/20150101_100000@': (0, 'green 1', tr('green/1')),
  1062. 'testing/i386/g/green/20150101_100010@': (0, 'green 2', tr('green/2')),
  1063. 'testing/amd64/g/green/20150101_100010@': (0, 'green 2', tr('green/2')),
  1064. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1065. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1066. 'testing/i386/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('green/2')),
  1067. 'testing/amd64/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('green/2')),
  1068. }})
  1069. self.run_it(
  1070. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1071. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1072. 'lightgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1073. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1074. }),
  1075. })
  1076. self.assertEqual(self.amqp_requests, set())
  1077. self.assertEqual(self.pending_requests, {})
  1078. self.data.remove_all(True)
  1079. # second run: new version re-triggers all tests
  1080. self.run_it(
  1081. [('libgreen1', {'Version': '3', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1082. {'green': (False, {'green': {'amd64': 'RUNNING', 'i386': 'RUNNING'},
  1083. 'lightgreen': {'amd64': 'RUNNING', 'i386': 'RUNNING'},
  1084. 'darkgreen': {'amd64': 'RUNNING', 'i386': 'RUNNING'},
  1085. }),
  1086. })
  1087. self.assertEqual(len(self.amqp_requests), 6)
  1088. self.assertEqual(self.pending_requests,
  1089. {'green/3': {'darkgreen': ['amd64', 'i386'],
  1090. 'green': ['amd64', 'i386'],
  1091. 'lightgreen': ['amd64', 'i386']}})
  1092. # third run gets the results for green and lightgreen, darkgreen is
  1093. # still running
  1094. self.swift.set_results({'autopkgtest-testing': {
  1095. 'testing/i386/g/green/20150101_100020@': (0, 'green 3', tr('green/3')),
  1096. 'testing/amd64/g/green/20150101_100020@': (0, 'green 3', tr('green/3')),
  1097. 'testing/i386/l/lightgreen/20150101_100010@': (0, 'lightgreen 1', tr('green/3')),
  1098. 'testing/amd64/l/lightgreen/20150101_100010@': (0, 'lightgreen 1', tr('green/3')),
  1099. }})
  1100. self.run_it(
  1101. [],
  1102. {'green': (False, {'green/3': {'amd64': 'PASS', 'i386': 'PASS'},
  1103. 'lightgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1104. 'darkgreen': {'amd64': 'RUNNING', 'i386': 'RUNNING'},
  1105. }),
  1106. })
  1107. self.assertEqual(self.amqp_requests, set())
  1108. self.assertEqual(self.pending_requests,
  1109. {'green/3': {'darkgreen': ['amd64', 'i386']}})
  1110. # fourth run finally gets the new darkgreen result
  1111. self.swift.set_results({'autopkgtest-testing': {
  1112. 'testing/i386/d/darkgreen/20150101_100010@': (0, 'darkgreen 1', tr('green/3')),
  1113. 'testing/amd64/d/darkgreen/20150101_100010@': (0, 'darkgreen 1', tr('green/3')),
  1114. }})
  1115. self.run_it(
  1116. [],
  1117. {'green': (True, {'green/3': {'amd64': 'PASS', 'i386': 'PASS'},
  1118. 'lightgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1119. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1120. }),
  1121. })
  1122. self.assertEqual(self.amqp_requests, set())
  1123. self.assertEqual(self.pending_requests, {})
  1124. def test_different_versions_on_arches(self):
  1125. '''different tested package versions on different architectures'''
  1126. self.data.add_default_packages(green=False)
  1127. self.swift.set_results({'autopkgtest-testing': {
  1128. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('passedbefore/1')),
  1129. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('passedbefore/1')),
  1130. }})
  1131. # first run: no results yet
  1132. self.run_it(
  1133. [('libgreen1', {'Version': '2', 'Source': 'green'}, 'autopkgtest')],
  1134. {'green': (False, {'darkgreen': {'amd64': 'RUNNING', 'i386': 'RUNNING'}})})
  1135. # second run: i386 result has version 1.1
  1136. self.swift.set_results({'autopkgtest-testing': {
  1137. 'testing/i386/d/darkgreen/20150101_100010@': (0, 'darkgreen 1.1', tr('green/2'))
  1138. }})
  1139. self.run_it(
  1140. [],
  1141. {'green': (False, {'darkgreen': {'amd64': 'RUNNING'},
  1142. 'darkgreen/1.1': {'i386': 'PASS'},
  1143. })})
  1144. # third run: amd64 result has version 1.2
  1145. self.swift.set_results({'autopkgtest-testing': {
  1146. 'testing/amd64/d/darkgreen/20150101_100010@': (0, 'darkgreen 1.2', tr('green/2')),
  1147. }})
  1148. self.run_it(
  1149. [],
  1150. {'green': (True, {'darkgreen/1.2': {'amd64': 'PASS'},
  1151. 'darkgreen/1.1': {'i386': 'PASS'},
  1152. })})
  1153. def test_tmpfail(self):
  1154. '''tmpfail results'''
  1155. self.data.add_default_packages(lightgreen=False)
  1156. # one tmpfail result without testpkg-version, should be ignored
  1157. self.swift.set_results({'autopkgtest-testing': {
  1158. 'testing/i386/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('lightgreen/1')),
  1159. 'testing/i386/l/lightgreen/20150101_100101@': (16, None, tr('lightgreen/2')),
  1160. 'testing/amd64/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('lightgreen/1')),
  1161. 'testing/amd64/l/lightgreen/20150101_100101@': (16, 'lightgreen 2', tr('lightgreen/2')),
  1162. }})
  1163. self.run_it(
  1164. [('lightgreen', {'Version': '2', 'Depends': 'libgreen1 (>= 1)'}, 'autopkgtest')],
  1165. {'lightgreen': (False, {'lightgreen/2': {'amd64': 'REGRESSION', 'i386': 'RUNNING'}})})
  1166. self.assertEqual(self.pending_requests,
  1167. {'lightgreen/2': {'lightgreen': ['i386']}})
  1168. # one more tmpfail result, should not confuse britney with None version
  1169. self.swift.set_results({'autopkgtest-testing': {
  1170. 'testing/i386/l/lightgreen/20150101_100201@': (16, None, tr('lightgreen/2')),
  1171. }})
  1172. self.run_it(
  1173. [],
  1174. {'lightgreen': (False, {'lightgreen/2': {'amd64': 'REGRESSION', 'i386': 'RUNNING'}})})
  1175. with open(os.path.join(self.data.path, 'data/testing/state/autopkgtest-results.cache')) as f:
  1176. contents = f.read()
  1177. self.assertNotIn('null', contents)
  1178. self.assertNotIn('None', contents)
  1179. def test_rerun_failure(self):
  1180. '''manually re-running failed tests gets picked up'''
  1181. self.data.add_default_packages(green=False)
  1182. # first run fails
  1183. self.swift.set_results({'autopkgtest-testing': {
  1184. 'testing/i386/g/green/20150101_100000@': (0, 'green 2', tr('green/1')),
  1185. 'testing/i386/g/green/20150101_100101@': (4, 'green 2', tr('green/2')),
  1186. 'testing/amd64/g/green/20150101_100000@': (0, 'green 2', tr('green/1')),
  1187. 'testing/amd64/g/green/20150101_100101@': (4, 'green 2', tr('green/2')),
  1188. 'testing/i386/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('green/1')),
  1189. 'testing/i386/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  1190. 'testing/amd64/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('green/1')),
  1191. 'testing/amd64/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  1192. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1193. 'testing/amd64/d/darkgreen/20150101_100001@': (0, 'darkgreen 1', tr('green/2')),
  1194. }})
  1195. self.run_it(
  1196. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1197. {'green': (False, {'green/2': {'amd64': 'REGRESSION', 'i386': 'REGRESSION'},
  1198. 'lightgreen/1': {'amd64': 'REGRESSION', 'i386': 'REGRESSION'},
  1199. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1200. }),
  1201. })
  1202. self.assertEqual(self.pending_requests, {})
  1203. # re-running test manually succeeded (note: darkgreen result should be
  1204. # cached already)
  1205. self.swift.set_results({'autopkgtest-testing': {
  1206. 'testing/i386/g/green/20150101_100201@': (0, 'green 2', tr('green/2')),
  1207. 'testing/amd64/g/green/20150101_100201@': (0, 'green 2', tr('green/2')),
  1208. 'testing/i386/l/lightgreen/20150101_100201@': (0, 'lightgreen 1', tr('green/2')),
  1209. 'testing/amd64/l/lightgreen/20150101_100201@': (0, 'lightgreen 1', tr('green/2')),
  1210. }})
  1211. self.run_it(
  1212. [],
  1213. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1214. 'lightgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1215. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1216. }),
  1217. })
  1218. self.assertEqual(self.pending_requests, {})
  1219. def test_new_runs_dont_clobber_pass(self):
  1220. '''passing once is sufficient
  1221. If a test succeeded once for a particular version and trigger,
  1222. subsequent failures (which might be triggered by other unstable
  1223. uploads) should not invalidate the PASS, as that new failure is the
  1224. fault of the new upload, not the original one.
  1225. '''
  1226. self.data.add_default_packages(libc6=False)
  1227. # new libc6 works fine with green
  1228. self.swift.set_results({'autopkgtest-testing': {
  1229. 'testing/i386/g/green/20150101_100000@': (0, 'green 1', tr('libc6/2')),
  1230. 'testing/amd64/g/green/20150101_100000@': (0, 'green 1', tr('libc6/2')),
  1231. }})
  1232. self.run_it(
  1233. [('libc6', {'Version': '2'}, None)],
  1234. {'libc6': (True, {'green/1': {'amd64': 'PASS', 'i386': 'PASS'}})})
  1235. self.assertEqual(self.pending_requests, {})
  1236. self.data.remove_all(True)
  1237. self.data.add('libc6', True, {'Version': '2'})
  1238. self.data.add('lightgreen', True, {'Depends': 'libgreen1'},
  1239. testsuite='autopkgtest')
  1240. self.data.add('blue', True, {'Depends': 'libc6 (>= 0.9)',
  1241. 'Conflicts': 'green'},
  1242. testsuite='specialtest')
  1243. self.data.add('black', True, {},
  1244. testsuite='autopkgtest')
  1245. self.data.add('grey', True, {},
  1246. testsuite='autopkgtest')
  1247. # new green fails; that's not libc6's fault though, so it should stay
  1248. # valid
  1249. self.swift.set_results({'autopkgtest-testing': {
  1250. 'testing/i386/g/green/20150101_100100@': (4, 'green 2', tr('green/2')),
  1251. 'testing/amd64/g/green/20150101_100100@': (4, 'green 2', tr('green/2')),
  1252. }})
  1253. self.run_it(
  1254. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1255. {'green': (False, {'green/2': {'amd64': 'REGRESSION', 'i386': 'REGRESSION'}}),
  1256. 'libc6': (True, {'green/1': {'amd64': 'PASS', 'i386': 'PASS'}}),
  1257. })
  1258. self.assertEqual(
  1259. self.amqp_requests,
  1260. set(['debci-testing-i386:darkgreen {"triggers": ["green/2"]}',
  1261. 'debci-testing-amd64:darkgreen {"triggers": ["green/2"]}',
  1262. 'debci-testing-i386:lightgreen {"triggers": ["green/2"]}',
  1263. 'debci-testing-amd64:lightgreen {"triggers": ["green/2"]}',
  1264. ]))
  1265. def test_remove_from_unstable(self):
  1266. '''broken package gets removed from unstable'''
  1267. self.data.add_default_packages(green=False, lightgreen=False)
  1268. self.swift.set_results({'autopkgtest-testing': {
  1269. 'testing/i386/g/green/20150101_100101@': (0, 'green 1', tr('green/1')),
  1270. 'testing/amd64/g/green/20150101_100101@': (0, 'green 1', tr('green/1')),
  1271. 'testing/i386/g/green/20150101_100201@': (0, 'green 2', tr('green/2')),
  1272. 'testing/amd64/g/green/20150101_100201@': (0, 'green 2', tr('green/2')),
  1273. 'testing/i386/l/lightgreen/20150101_100101@': (0, 'lightgreen 1', tr('green/1')),
  1274. 'testing/amd64/l/lightgreen/20150101_100101@': (0, 'lightgreen 1', tr('green/1')),
  1275. 'testing/i386/l/lightgreen/20150101_100201@': (4, 'lightgreen 2', tr('green/2 lightgreen/2')),
  1276. 'testing/amd64/l/lightgreen/20150101_100201@': (4, 'lightgreen 2', tr('green/2 lightgreen/2')),
  1277. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1278. 'testing/amd64/d/darkgreen/20150101_100001@': (0, 'darkgreen 1', tr('green/2')),
  1279. }})
  1280. self.run_it(
  1281. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest'),
  1282. ('lightgreen', {'Version': '2', 'Depends': 'libgreen1 (>= 2)'}, 'autopkgtest')],
  1283. {'green': (False, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1284. 'lightgreen/2': {'amd64': 'REGRESSION', 'i386': 'REGRESSION'},
  1285. }),
  1286. })
  1287. self.assertEqual(self.pending_requests, {})
  1288. self.assertEqual(self.amqp_requests, set())
  1289. # remove new lightgreen by resetting archive indexes, and re-adding
  1290. # green
  1291. self.data.remove_all(True)
  1292. self.swift.set_results({'autopkgtest-testing': {
  1293. # add new result for lightgreen 1
  1294. 'testing/i386/l/lightgreen/20150101_100301@': (0, 'lightgreen 1', tr('green/2')),
  1295. 'testing/amd64/l/lightgreen/20150101_100301@': (0, 'lightgreen 1', tr('green/2')),
  1296. }})
  1297. # next run should re-trigger lightgreen 1 to test against green/2
  1298. exc = self.run_it(
  1299. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1300. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1301. 'lightgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1302. }),
  1303. })[1]
  1304. self.assertNotIn('lightgreen 2', exc['green']['policy_info']['autopkgtest'])
  1305. # should not trigger new requests
  1306. self.assertEqual(self.pending_requests, {})
  1307. self.assertEqual(self.amqp_requests, set())
  1308. # but the next run should not trigger anything new
  1309. self.run_it(
  1310. [],
  1311. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1312. 'lightgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1313. }),
  1314. })
  1315. self.assertEqual(self.pending_requests, {})
  1316. self.assertEqual(self.amqp_requests, set())
  1317. # # def test_multiarch_dep(self):
  1318. # # '''multi-arch dependency'''
  1319. # # # needs changes in britney2/installability/builder.py
  1320. # #
  1321. # # self.data.add_default_packages(lightgreen=False)
  1322. # #
  1323. # # # lightgreen has passed before on i386 only, therefore ALWAYSFAIL on amd64
  1324. # # self.swift.set_results({'autopkgtest-testing': {
  1325. # # 'testing/i386/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('passedbefore/1')),
  1326. # # }})
  1327. # #
  1328. # # self.data.add('rainbow', False, {'Depends': 'lightgreen:any'},
  1329. # # testsuite='autopkgtest')
  1330. # # self.data.add('rainbow', True, {'Depends': 'lightgreen:any'},
  1331. # # testsuite='autopkgtest')
  1332. # #
  1333. # # self.run_it(
  1334. # # [('lightgreen', {'Version': '2'}, 'autopkgtest')],
  1335. # # {'lightgreen': (False, {'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'},
  1336. # # 'rainbow': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1337. # # }),
  1338. # # },
  1339. # # {'lightgreen': [('old-version', '1'), ('new-version', '2')]}
  1340. # # )
  1341. def test_nbs(self):
  1342. '''source-less binaries do not cause harm'''
  1343. self.data.add_default_packages(green=False)
  1344. # NBS in testing
  1345. self.data.add('liboldgreen0', False, add_src=False)
  1346. # NBS in unstable
  1347. self.data.add('liboldgreen1', True, add_src=False)
  1348. self.run_it(
  1349. [('libgreen1', {'Version': '2', 'Source': 'green'}, 'autopkgtest')],
  1350. {'green': (True, {'green': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1351. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1352. 'darkgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1353. }),
  1354. },
  1355. {'green': [('old-version', '1'), ('new-version', '2')]})
  1356. def test_newer_version_in_testing(self):
  1357. '''Testing version is newer than in unstable'''
  1358. self.data.add_default_packages(lightgreen=False)
  1359. exc = self.run_it(
  1360. [('lightgreen', {'Version': '0.9~beta'}, 'autopkgtest')],
  1361. {'lightgreen': (False, {})},
  1362. {'lightgreen': [('old-version', '1'), ('new-version', '0.9~beta'),
  1363. ('reason', 'newerintesting'),
  1364. ('excuses', 'ALERT: lightgreen is newer in the target suite (1 0.9~beta)')
  1365. ]
  1366. })[1]
  1367. # autopkgtest should not be triggered
  1368. self.assertNotIn('autopkgtest', exc['lightgreen'].get('policy_info', {}))
  1369. self.assertEqual(self.pending_requests, {})
  1370. self.assertEqual(self.amqp_requests, set())
  1371. def test_testsuite_triggers(self):
  1372. '''Testsuite-Triggers'''
  1373. self.data.add_default_packages(lightgreen=False)
  1374. self.swift.set_results({'autopkgtest-testing': {
  1375. 'testing/i386/r/rainbow/20150101_100000@': (0, 'rainbow 1', tr('passedbefore/1')),
  1376. }})
  1377. self.data.add('rainbow', False, testsuite='autopkgtest',
  1378. srcfields={'Testsuite-Triggers': 'unicorn, lightgreen, sugar'})
  1379. self.run_it(
  1380. [('lightgreen', {'Version': '2'}, 'autopkgtest')],
  1381. {'lightgreen': (False, {'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1382. 'rainbow': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'},
  1383. }),
  1384. }
  1385. )
  1386. def test_huge_number_of_tests(self):
  1387. '''package triggers huge number of tests'''
  1388. self.data.add_default_packages(green=False)
  1389. for i in range(30):
  1390. self.data.add('green%i' % i, False, {'Depends': 'libgreen1'}, testsuite='autopkgtest')
  1391. self.run_it(
  1392. [('libgreen1', {'Version': '2', 'Source': 'green'}, 'autopkgtest')],
  1393. {'green': (True, {'green': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1394. 'green0': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1395. 'green29': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1396. })
  1397. },
  1398. )
  1399. # requests should all go into the -huge queues
  1400. self.assertEqual([x for x in self.amqp_requests if 'huge' not in x], [])
  1401. for i in range(30):
  1402. for arch in ['i386', 'amd64']:
  1403. self.assertIn('debci-huge-testing-%s:green%i {"triggers": ["green/2"]}' %
  1404. (arch, i), self.amqp_requests)
  1405. ################################################################
  1406. # Tests for hint processing
  1407. ################################################################
  1408. def test_hint_force_badtest(self):
  1409. '''force-badtest hint'''
  1410. self.data.add_default_packages(green=False)
  1411. self.swift.set_results({'autopkgtest-testing': {
  1412. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1413. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1414. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  1415. 'testing/i386/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  1416. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  1417. 'testing/amd64/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  1418. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  1419. 'testing/amd64/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  1420. }})
  1421. self.create_hint('autopkgtest', 'force-badtest lightgreen/1')
  1422. self.run_it(
  1423. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1424. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1425. 'lightgreen/1': {'amd64': 'IGNORE-FAIL', 'i386': 'IGNORE-FAIL'},
  1426. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1427. }),
  1428. },
  1429. {'green': [('old-version', '1'), ('new-version', '2')]
  1430. })
  1431. def test_hint_force_badtest_multi_version(self):
  1432. '''force-badtest hint'''
  1433. self.data.add_default_packages(green=False)
  1434. self.swift.set_results({'autopkgtest-testing': {
  1435. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1436. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1437. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  1438. 'testing/i386/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  1439. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  1440. 'testing/amd64/l/lightgreen/20150101_100101@': (4, 'lightgreen 2', tr('green/2')),
  1441. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  1442. 'testing/amd64/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  1443. }})
  1444. self.create_hint('autopkgtest', 'force-badtest lightgreen/1')
  1445. self.run_it(
  1446. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1447. {'green': (False, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1448. 'lightgreen/1': {'i386': 'IGNORE-FAIL'},
  1449. 'lightgreen/2': {'amd64': 'REGRESSION'},
  1450. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1451. }),
  1452. },
  1453. {'green': [('old-version', '1'), ('new-version', '2')]
  1454. })
  1455. # hint the version on amd64 too
  1456. self.create_hint('autopkgtest', 'force-badtest lightgreen/2')
  1457. self.run_it(
  1458. [],
  1459. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1460. 'lightgreen/1': {'i386': 'IGNORE-FAIL'},
  1461. 'lightgreen/2': {'amd64': 'IGNORE-FAIL'},
  1462. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1463. }),
  1464. },
  1465. {'green': [('old-version', '1'), ('new-version', '2')]
  1466. })
  1467. def test_hint_force_badtest_different_version(self):
  1468. '''force-badtest hint with non-matching version'''
  1469. self.data.add_default_packages(green=False)
  1470. self.swift.set_results({'autopkgtest-testing': {
  1471. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1472. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1473. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  1474. 'testing/i386/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  1475. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  1476. 'testing/amd64/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  1477. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  1478. 'testing/amd64/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  1479. }})
  1480. # lower hint version should not apply
  1481. self.create_hint('autopkgtest', 'force-badtest lightgreen/0.1')
  1482. exc = self.run_it(
  1483. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1484. {'green': (False, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1485. 'lightgreen/1': {'amd64': 'REGRESSION', 'i386': 'REGRESSION'},
  1486. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1487. }),
  1488. },
  1489. {'green': [('reason', 'autopkgtest')]}
  1490. )[1]
  1491. self.assertNotIn('forced-reason', exc['green'])
  1492. # higher hint version should apply
  1493. self.create_hint('autopkgtest', 'force-badtest lightgreen/3')
  1494. self.run_it(
  1495. [],
  1496. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1497. 'lightgreen/1': {'amd64': 'IGNORE-FAIL', 'i386': 'IGNORE-FAIL'},
  1498. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1499. }),
  1500. },
  1501. {}
  1502. )
  1503. def test_hint_force_badtest_arch(self):
  1504. '''force-badtest hint for architecture instead of version'''
  1505. self.data.add_default_packages(green=False)
  1506. self.swift.set_results({'autopkgtest-testing': {
  1507. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1508. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1509. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  1510. 'testing/i386/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  1511. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  1512. 'testing/amd64/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  1513. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  1514. 'testing/amd64/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  1515. }})
  1516. self.create_hint('autopkgtest', 'force-badtest lightgreen/amd64/all')
  1517. self.run_it(
  1518. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1519. {'green': (False, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1520. 'lightgreen/1': {'amd64': 'IGNORE-FAIL', 'i386': 'REGRESSION'},
  1521. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1522. }),
  1523. },
  1524. {'green': [('old-version', '1'), ('new-version', '2')]
  1525. })
  1526. # hint i386 too, then it should become valid
  1527. self.create_hint('autopkgtest', 'force-badtest lightgreen/i386/all')
  1528. self.run_it(
  1529. [],
  1530. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1531. 'lightgreen/1': {'amd64': 'IGNORE-FAIL', 'i386': 'IGNORE-FAIL'},
  1532. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1533. }),
  1534. },
  1535. {'green': [('old-version', '1'), ('new-version', '2')]
  1536. })
  1537. def test_hint_force_badtest_running(self):
  1538. '''force-badtest hint on running test'''
  1539. self.data.add_default_packages(green=False)
  1540. self.swift.set_results({'autopkgtest-testing': {
  1541. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1542. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1543. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  1544. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  1545. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  1546. 'testing/amd64/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  1547. }})
  1548. self.create_hint('autopkgtest', 'force-badtest lightgreen/1')
  1549. self.run_it(
  1550. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1551. {'green': (True, {'green/2': {'amd64': 'PASS', 'i386': 'PASS'},
  1552. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1553. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1554. }),
  1555. },
  1556. {'green': [('old-version', '1'), ('new-version', '2')]
  1557. })
  1558. def test_hint_force_skiptest(self):
  1559. '''force-skiptest hint'''
  1560. self.data.add_default_packages(green=False)
  1561. self.create_hint('autopkgtest', 'force-skiptest green/2')
  1562. # regression of green, darkgreen ok, lightgreen running
  1563. self.swift.set_results({'autopkgtest-testing': {
  1564. 'testing/i386/g/green/20150101_100000@': (0, 'green 1', tr('passedbefore/1')),
  1565. 'testing/i386/g/green/20150101_100200@': (4, 'green 2', tr('green/2')),
  1566. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1567. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  1568. }})
  1569. self.run_it(
  1570. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1571. {'green': (True, {'green/2': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'REGRESSION'},
  1572. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1573. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1574. }),
  1575. },
  1576. {'green': [('old-version', '1'), ('new-version', '2'),
  1577. ('reason', 'skiptest'),
  1578. ('excuses', 'Should wait for tests relating to green 2, but forced by autopkgtest')]
  1579. })
  1580. def test_hint_force_skiptest_different_version(self):
  1581. '''force-skiptest hint with non-matching version'''
  1582. self.data.add_default_packages(green=False)
  1583. # green has passed before on i386 only, therefore ALWAYSFAIL on amd64
  1584. self.swift.set_results({'autopkgtest-testing': {
  1585. 'testing/i386/g/green/20150101_100000@': (0, 'green 1', tr('passedbefore/1')),
  1586. }})
  1587. self.create_hint('autopkgtest', 'force-skiptest green/1')
  1588. exc = self.run_it(
  1589. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1590. {'green': (False, {'green': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'},
  1591. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1592. 'darkgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1593. }),
  1594. },
  1595. {'green': [('reason', 'autopkgtest')]}
  1596. )[1]
  1597. self.assertNotIn('forced-reason', exc['green'])
  1598. def test_hint_blockall_runs_tests(self):
  1599. '''block-all hint still runs tests'''
  1600. self.data.add_default_packages(lightgreen=False)
  1601. self.create_hint('freeze', 'block-all source')
  1602. self.swift.set_results({'autopkgtest-testing': {
  1603. 'testing/i386/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('passedbefore/1')),
  1604. 'testing/amd64/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('passedbefore/1')),
  1605. }})
  1606. self.run_it(
  1607. [('lightgreen', {'Version': '2'}, 'autopkgtest')],
  1608. {'lightgreen': (False, {'lightgreen': {'amd64': 'RUNNING', 'i386': 'RUNNING'}})}
  1609. )
  1610. self.swift.set_results({'autopkgtest-testing': {
  1611. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 2', tr('lightgreen/2')),
  1612. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 2', tr('lightgreen/2')),
  1613. }})
  1614. self.run_it(
  1615. [],
  1616. {'lightgreen': (False, {'lightgreen/2': {'amd64': 'PASS', 'i386': 'PASS'}})},
  1617. {'lightgreen': [('reason', 'block')]}
  1618. )
  1619. ################################################################
  1620. # Tests for non-hint policies (Ubuntu only)
  1621. ################################################################
  1622. # # def test_lp_bug_block(self):
  1623. # # self.data.add_default_packages(darkgreen=False)
  1624. # #
  1625. # # with open(os.path.join(self.data.path, 'data/unstable/Blocks'), 'w') as f:
  1626. # # f.write('darkgreen 12345 1471505000\ndarkgreen 98765 1471500000\n')
  1627. # #
  1628. # # exc = self.run_it(
  1629. # # [('darkgreen', {'Version': '2'}, 'autopkgtest')],
  1630. # # {'darkgreen': (False, {'darkgreen': {'i386': 'RUNNING-ALWAYSFAIL', 'amd64': 'RUNNING-ALWAYSFAIL'}})},
  1631. # # {'darkgreen': [('reason', 'block'),
  1632. # # ('excuses', 'Not touching package as requested in <a href="https://launchpad.net/bugs/12345">bug 12345</a> on Thu Aug 18 07:23:20 2016'),
  1633. # # ('is-candidate', False),
  1634. # # ]
  1635. # # }
  1636. # # )[1]
  1637. # # self.assertEqual(exc['darkgreen']['policy_info']['block-bugs'],
  1638. # # {'12345': 1471505000, '98765': 1471500000})
  1639. ################################################################
  1640. # Kernel related tests
  1641. ################################################################
  1642. def test_detect_dkms_autodep8(self):
  1643. '''DKMS packages are autopkgtested (via autodep8)'''
  1644. self.data.add('dkms', False, {})
  1645. self.data.add('fancy-dkms', False, {'Source': 'fancy', 'Depends': 'dkms (>= 1)'}, testsuite='autopkgtest-pkg-dkms')
  1646. self.swift.set_results({'autopkgtest-testing': {
  1647. 'testing/i386/f/fancy/20150101_100101@': (0, 'fancy 0.1', tr('passedbefore/1'))
  1648. }})
  1649. self.run_it(
  1650. [('dkms', {'Version': '2'}, None)],
  1651. {'dkms': (False, {'fancy': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'}})},
  1652. {'dkms': [('old-version', '1'), ('new-version', '2')]})
  1653. def test_kernel_triggers_dkms(self):
  1654. '''DKMS packages get triggered by kernel uploads'''
  1655. self.data.add('dkms', False, {})
  1656. self.data.add('fancy-dkms', False, {'Source': 'fancy', 'Depends': 'dkms (>= 1)'}, testsuite='autopkgtest-pkg-dkms')
  1657. self.run_it(
  1658. [('linux-image-generic', {'Source': 'linux-meta'}, None),
  1659. ('linux-image-grumpy-generic', {'Source': 'linux-meta-lts-grumpy'}, None),
  1660. ('linux-image-64only', {'Source': 'linux-meta-64only', 'Architecture': 'amd64'}, None),
  1661. ],
  1662. {'linux-meta': (True, {'fancy': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'}}),
  1663. 'linux-meta-lts-grumpy': (True, {'fancy': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'}}),
  1664. 'linux-meta-64only': (True, {'fancy': {'amd64': 'RUNNING-ALWAYSFAIL'}}),
  1665. })
  1666. # one separate test should be triggered for each kernel
  1667. self.assertEqual(
  1668. self.amqp_requests,
  1669. set(['debci-testing-i386:fancy {"triggers": ["linux-meta/1"]}',
  1670. 'debci-testing-amd64:fancy {"triggers": ["linux-meta/1"]}',
  1671. 'debci-testing-i386:fancy {"triggers": ["linux-meta-lts-grumpy/1"]}',
  1672. 'debci-testing-amd64:fancy {"triggers": ["linux-meta-lts-grumpy/1"]}',
  1673. 'debci-testing-amd64:fancy {"triggers": ["linux-meta-64only/1"]}']))
  1674. # ... and that they get recorded as pending
  1675. self.assertEqual(self.pending_requests,
  1676. {'linux-meta-lts-grumpy/1': {'fancy': ['amd64', 'i386']},
  1677. 'linux-meta/1': {'fancy': ['amd64', 'i386']},
  1678. 'linux-meta-64only/1': {'fancy': ['amd64']}})
  1679. def test_dkms_results_per_kernel(self):
  1680. '''DKMS results get mapped to the triggering kernel version'''
  1681. self.data.add('dkms', False, {})
  1682. self.data.add('fancy-dkms', False, {'Source': 'fancy', 'Depends': 'dkms (>= 1)'}, testsuite='autopkgtest-pkg-dkms')
  1683. # works against linux-meta and -64only, fails against grumpy i386, no
  1684. # result yet for grumpy amd64
  1685. self.swift.set_results({'autopkgtest-testing': {
  1686. 'testing/amd64/f/fancy/20150101_100301@': (0, 'fancy 0.5', tr('passedbefore/1')),
  1687. 'testing/i386/f/fancy/20150101_100101@': (0, 'fancy 1', tr('linux-meta/1')),
  1688. 'testing/amd64/f/fancy/20150101_100101@': (0, 'fancy 1', tr('linux-meta/1')),
  1689. 'testing/amd64/f/fancy/20150101_100201@': (0, 'fancy 1', tr('linux-meta-64only/1')),
  1690. 'testing/i386/f/fancy/20150101_100301@': (4, 'fancy 1', tr('linux-meta-lts-grumpy/1')),
  1691. }})
  1692. self.run_it(
  1693. [('linux-image-generic', {'Source': 'linux-meta'}, None),
  1694. ('linux-image-grumpy-generic', {'Source': 'linux-meta-lts-grumpy'}, None),
  1695. ('linux-image-64only', {'Source': 'linux-meta-64only', 'Architecture': 'amd64'}, None),
  1696. ],
  1697. {'linux-meta': (True, {'fancy/1': {'amd64': 'PASS', 'i386': 'PASS'}}),
  1698. 'linux-meta-lts-grumpy': (False, {'fancy/1': {'amd64': 'RUNNING', 'i386': 'ALWAYSFAIL'}}),
  1699. 'linux-meta-64only': (True, {'fancy/1': {'amd64': 'PASS'}}),
  1700. })
  1701. self.assertEqual(self.pending_requests,
  1702. {'linux-meta-lts-grumpy/1': {'fancy': ['amd64']}})
  1703. def test_dkms_results_per_kernel_old_results(self):
  1704. '''DKMS results get mapped to the triggering kernel version, old results'''
  1705. self.data.add('dkms', False, {})
  1706. self.data.add('fancy-dkms', False, {'Source': 'fancy', 'Depends': 'dkms (>= 1)'}, testsuite='autopkgtest-pkg-dkms')
  1707. # works against linux-meta and -64only, fails against grumpy i386, no
  1708. # result yet for grumpy amd64
  1709. self.swift.set_results({'autopkgtest-testing': {
  1710. # old results without trigger info
  1711. 'testing/i386/f/fancy/20140101_100101@': (0, 'fancy 1', {}),
  1712. 'testing/amd64/f/fancy/20140101_100101@': (8, 'fancy 1', {}),
  1713. # current results with triggers
  1714. 'testing/i386/f/fancy/20150101_100101@': (0, 'fancy 1', tr('linux-meta/1')),
  1715. 'testing/amd64/f/fancy/20150101_100101@': (0, 'fancy 1', tr('linux-meta/1')),
  1716. 'testing/amd64/f/fancy/20150101_100201@': (0, 'fancy 1', tr('linux-meta-64only/1')),
  1717. 'testing/i386/f/fancy/20150101_100301@': (4, 'fancy 1', tr('linux-meta-lts-grumpy/1')),
  1718. }})
  1719. self.run_it(
  1720. [('linux-image-generic', {'Source': 'linux-meta'}, None),
  1721. ('linux-image-grumpy-generic', {'Source': 'linux-meta-lts-grumpy'}, None),
  1722. ('linux-image-64only', {'Source': 'linux-meta-64only', 'Architecture': 'amd64'}, None),
  1723. ],
  1724. {'linux-meta': (True, {'fancy/1': {'amd64': 'PASS', 'i386': 'PASS'}}),
  1725. # we don't have an explicit result for amd64
  1726. 'linux-meta-lts-grumpy': (False, {'fancy/1': {'amd64': 'RUNNING', 'i386': 'ALWAYSFAIL'}}),
  1727. 'linux-meta-64only': (True, {'fancy/1': {'amd64': 'PASS'}}),
  1728. })
  1729. self.assertEqual(self.pending_requests,
  1730. {'linux-meta-lts-grumpy/1': {'fancy': ['amd64']}})
  1731. # # def test_kernel_triggered_tests(self):
  1732. # # '''linux, lxc, glibc, systemd, snapd tests get triggered by linux-meta* uploads'''
  1733. # #
  1734. # # self.data.add('libc6-dev', False, {'Source': 'glibc', 'Depends': 'linux-libc-dev'},
  1735. # # testsuite='autopkgtest')
  1736. # # self.data.add('libc6-dev', True, {'Source': 'glibc', 'Depends': 'linux-libc-dev'},
  1737. # # testsuite='autopkgtest')
  1738. # # self.data.add('lxc', False, {}, testsuite='autopkgtest')
  1739. # # self.data.add('lxc', True, {}, testsuite='autopkgtest')
  1740. # # self.data.add('systemd', False, {}, testsuite='autopkgtest')
  1741. # # self.data.add('systemd', True, {}, testsuite='autopkgtest')
  1742. # # self.data.add('snapd', False, {}, testsuite='autopkgtest')
  1743. # # self.data.add('snapd', True, {}, testsuite='autopkgtest')
  1744. # # self.data.add('linux-image-1', False, {'Source': 'linux'}, testsuite='autopkgtest')
  1745. # # self.data.add('linux-image-1', True, {'Source': 'linux'}, testsuite='autopkgtest')
  1746. # # self.data.add('linux-libc-dev', False, {'Source': 'linux'}, testsuite='autopkgtest')
  1747. # # self.data.add('linux-image', False, {'Source': 'linux-meta', 'Depends': 'linux-image-1'})
  1748. # #
  1749. # # self.swift.set_results({'autopkgtest-testing': {
  1750. # # 'testing/amd64/l/lxc/20150101_100101@': (0, 'lxc 0.1', tr('passedbefore/1'))
  1751. # # }})
  1752. # #
  1753. # # exc = self.run_it(
  1754. # # [('linux-image', {'Version': '2', 'Depends': 'linux-image-2', 'Source': 'linux-meta'}, None),
  1755. # # ('linux-image-64only', {'Source': 'linux-meta-64only', 'Architecture': 'amd64'}, None),
  1756. # # ('linux-image-2', {'Version': '2', 'Source': 'linux'}, 'autopkgtest'),
  1757. # # ('linux-libc-dev', {'Version': '2', 'Source': 'linux'}, 'autopkgtest'),
  1758. # # ],
  1759. # # {'linux-meta': (False, {'lxc': {'amd64': 'RUNNING', 'i386': 'RUNNING-ALWAYSFAIL'},
  1760. # # 'glibc': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1761. # # 'linux': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1762. # # 'systemd': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1763. # # 'snapd': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  1764. # # }),
  1765. # # 'linux-meta-64only': (False, {'lxc': {'amd64': 'RUNNING'}}),
  1766. # # 'linux': (False, {}),
  1767. # # })[1]
  1768. # # # the kernel itself should not trigger tests; we want to trigger
  1769. # # # everything from -meta
  1770. # # self.assertEqual(exc['linux']['policy_info']['autopkgtest'], {})
  1771. # # def test_kernel_waits_on_meta(self):
  1772. # # '''linux waits on linux-meta'''
  1773. # #
  1774. # # self.data.add('dkms', False, {})
  1775. # # self.data.add('dkms', True, {})
  1776. # # self.data.add('fancy-dkms', False, {'Source': 'fancy', 'Depends': 'dkms (>= 1)'})
  1777. # # self.data.add('fancy-dkms', True, {'Source': 'fancy', 'Depends': 'dkms (>= 1)'})
  1778. # # self.data.add('linux-image-generic', False, {'Version': '0.1', 'Source': 'linux-meta', 'Depends': 'linux-image-1'})
  1779. # # self.data.add('linux-image-1', False, {'Source': 'linux'}, testsuite='autopkgtest')
  1780. # # self.data.add('linux-firmware', False, {'Source': 'linux-firmware'}, testsuite='autopkgtest')
  1781. # #
  1782. # # self.swift.set_results({'autopkgtest-testing': {
  1783. # # 'testing/i386/f/fancy/20150101_090000@': (0, 'fancy 0.5', tr('passedbefore/1')),
  1784. # # 'testing/i386/l/linux/20150101_100000@': (0, 'linux 2', tr('linux-meta/0.2')),
  1785. # # 'testing/amd64/l/linux/20150101_100000@': (0, 'linux 2', tr('linux-meta/0.2')),
  1786. # # 'testing/i386/l/linux-firmware/20150101_100000@': (0, 'linux-firmware 2', tr('linux-firmware/2')),
  1787. # # 'testing/amd64/l/linux-firmware/20150101_100000@': (0, 'linux-firmware 2', tr('linux-firmware/2')),
  1788. # # }})
  1789. # #
  1790. # # self.run_it(
  1791. # # [('linux-image-generic', {'Version': '0.2', 'Source': 'linux-meta', 'Depends': 'linux-image-2'}, None),
  1792. # # ('linux-image-2', {'Version': '2', 'Source': 'linux'}, 'autopkgtest'),
  1793. # # ('linux-firmware', {'Version': '2', 'Source': 'linux-firmware'}, 'autopkgtest'),
  1794. # # ],
  1795. # # {'linux-meta': (False, {'fancy': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'},
  1796. # # 'linux/2': {'amd64': 'PASS', 'i386': 'PASS'}
  1797. # # }),
  1798. # # # no tests, but should wait on linux-meta
  1799. # # 'linux': (False, {}),
  1800. # # # this one does not have a -meta, so don't wait
  1801. # # 'linux-firmware': (True, {'linux-firmware/2': {'amd64': 'PASS', 'i386': 'PASS'}}),
  1802. # # },
  1803. # # {'linux': [('reason', 'depends'),
  1804. # # ('excuses', 'Invalidated by dependency'),
  1805. # # ('dependencies', {'blocked-by': ['linux-meta']})]
  1806. # # }
  1807. # # )
  1808. # #
  1809. # # # now linux-meta is ready to go
  1810. # # self.swift.set_results({'autopkgtest-testing': {
  1811. # # 'testing/i386/f/fancy/20150101_100000@': (0, 'fancy 1', tr('linux-meta/0.2')),
  1812. # # 'testing/amd64/f/fancy/20150101_100000@': (0, 'fancy 1', tr('linux-meta/0.2')),
  1813. # # }})
  1814. # # self.run_it(
  1815. # # [],
  1816. # # {'linux-meta': (True, {'fancy/1': {'amd64': 'PASS', 'i386': 'PASS'},
  1817. # # 'linux/2': {'amd64': 'PASS', 'i386': 'PASS'}}),
  1818. # # 'linux': (True, {}),
  1819. # # 'linux-firmware': (True, {'linux-firmware/2': {'amd64': 'PASS', 'i386': 'PASS'}}),
  1820. # # },
  1821. # # {'linux': [('dependencies', {'migrate-after': ['linux-meta']})]
  1822. # # }
  1823. # # )
  1824. ################################################################
  1825. # Tests for special-cased packages
  1826. ################################################################
  1827. def test_gcc(self):
  1828. '''gcc only triggers some key packages'''
  1829. self.data.add('binutils', False, {}, testsuite='autopkgtest')
  1830. self.data.add('linux', False, {}, testsuite='autopkgtest')
  1831. self.data.add('notme', False, {'Depends': 'libgcc1'}, testsuite='autopkgtest')
  1832. # binutils has passed before on i386 only, therefore ALWAYSFAIL on amd64
  1833. self.swift.set_results({'autopkgtest-testing': {
  1834. 'testing/i386/b/binutils/20150101_100000@': (0, 'binutils 1', tr('passedbefore/1')),
  1835. }})
  1836. exc = self.run_it(
  1837. [('libgcc1', {'Source': 'gcc-5', 'Version': '2'}, None)],
  1838. {'gcc-5': (False, {'binutils': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'},
  1839. 'linux': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'}})})[1]
  1840. self.assertNotIn('notme 1', exc['gcc-5']['policy_info']['autopkgtest'])
  1841. def test_gcc_hastest(self):
  1842. """gcc triggers itself when it has a testsuite"""
  1843. self.data.add('gcc-7', False, {}, testsuite='autopkgtest')
  1844. # gcc-7 has passed before on i386 only, therefore ALWAYSFAIL on amd64
  1845. self.swift.set_results({'autopkgtest-series': {
  1846. 'series/i386/g/gcc-7/20150101_100000@': (0, 'gcc-7 1', tr('passedbefore/1')),
  1847. }})
  1848. exc = self.run_it(
  1849. [('gcc-7', {'Source': 'gcc-7', 'Version': '2'}, 'autopkgtest')],
  1850. {'gcc-7': (True, {'gcc-7': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'}})})[1]
  1851. self.assertIn('gcc-7', exc['gcc-7']['policy_info']['autopkgtest'])
  1852. def test_alternative_gcc(self):
  1853. '''alternative gcc does not trigger anything'''
  1854. self.data.add('binutils', False, {}, testsuite='autopkgtest')
  1855. self.data.add('notme', False, {'Depends': 'libgcc1'}, testsuite='autopkgtest')
  1856. exc = self.run_it(
  1857. [('libgcc1', {'Source': 'gcc-snapshot', 'Version': '2'}, None)],
  1858. {'gcc-snapshot': (True, {})})[1]
  1859. self.assertEqual(exc['gcc-snapshot']['policy_info']['autopkgtest'], {'verdict': 'PASS'})
  1860. ################################################################
  1861. # Tests for non-default ADT_* configuration modes
  1862. ################################################################
  1863. def test_disable_adt(self):
  1864. '''Run without autopkgtest requests'''
  1865. # Disable AMQP server config, to ensure we don't touch them with ADT
  1866. # disabled
  1867. for line in fileinput.input(self.britney_conf, inplace=True):
  1868. if line.startswith('ADT_ENABLE'):
  1869. print('ADT_ENABLE = no')
  1870. elif not line.startswith('ADT_AMQP') and not line.startswith('ADT_SWIFT_URL'):
  1871. sys.stdout.write(line)
  1872. self.data.add_default_packages(green=False)
  1873. exc = self.run_it(
  1874. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1875. {'green': (True, {})},
  1876. {'green': [('old-version', '1'), ('new-version', '2')]})[1]
  1877. self.assertNotIn('autopkgtest', exc['green']['policy_info'])
  1878. self.assertEqual(self.amqp_requests, set())
  1879. self.assertEqual(self.pending_requests, None)
  1880. def test_ppas(self):
  1881. '''Run test requests with additional PPAs'''
  1882. self.data.add_default_packages(lightgreen=False)
  1883. for line in fileinput.input(self.britney_conf, inplace=True):
  1884. if line.startswith('ADT_PPAS'):
  1885. print('ADT_PPAS = joe/foo awesome-developers/staging')
  1886. else:
  1887. sys.stdout.write(line)
  1888. exc = self.run_it(
  1889. [('lightgreen', {'Version': '2'}, 'autopkgtest')],
  1890. {'lightgreen': (True, {'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL'}})},
  1891. {'lightgreen': [('old-version', '1'), ('new-version', '2')]}
  1892. )[1]
  1893. self.assertEqual(exc['lightgreen']['policy_info']['autopkgtest'],
  1894. {'lightgreen': {
  1895. 'amd64': ['RUNNING-ALWAYSFAIL',
  1896. 'https://autopkgtest.ubuntu.com/status/pending',
  1897. None,
  1898. None,
  1899. None],
  1900. 'i386': ['RUNNING-ALWAYSFAIL',
  1901. 'https://autopkgtest.ubuntu.com/status/pending',
  1902. None,
  1903. None,
  1904. None]},
  1905. 'verdict': 'PASS'})
  1906. for arch in ['i386', 'amd64']:
  1907. self.assertTrue(
  1908. ('debci-ppa-testing-%s:lightgreen {"triggers": ["lightgreen/2"], '
  1909. '"ppas": ["joe/foo", "awesome-developers/staging"]}') % arch in self.amqp_requests or
  1910. ('debci-ppa-testing-%s:lightgreen {"ppas": ["joe/foo", '
  1911. '"awesome-developers/staging"], "triggers": ["lightgreen/2"]}') % arch in self.amqp_requests,
  1912. self.amqp_requests)
  1913. self.assertEqual(len(self.amqp_requests), 2)
  1914. # add results to PPA specific swift container
  1915. self.swift.set_results({'autopkgtest-testing-awesome-developers-staging': {
  1916. 'testing/i386/l/lightgreen/20150101_100000@': (0, 'lightgreen 1', tr('passedbefore/1')),
  1917. 'testing/i386/l/lightgreen/20150101_100100@': (4, 'lightgreen 2', tr('lightgreen/2')),
  1918. 'testing/amd64/l/lightgreen/20150101_100101@': (0, 'lightgreen 2', tr('lightgreen/2')),
  1919. }})
  1920. exc = self.run_it(
  1921. [],
  1922. {'lightgreen': (False, {'lightgreen/2': {'i386': 'REGRESSION', 'amd64': 'PASS'}})},
  1923. {'lightgreen': [('old-version', '1'), ('new-version', '2')]}
  1924. )[1]
  1925. self.assertEqual(
  1926. exc['lightgreen']['policy_info']['autopkgtest'],
  1927. {'lightgreen/2': {
  1928. 'amd64': [
  1929. 'PASS',
  1930. 'http://localhost:18085/autopkgtest-testing-awesome-developers-staging/'
  1931. 'testing/amd64/l/lightgreen/20150101_100101@/log.gz',
  1932. None,
  1933. 'http://localhost:18085/autopkgtest-testing-awesome-developers-staging/'
  1934. 'testing/amd64/l/lightgreen/20150101_100101@/artifacts.tar.gz',
  1935. None],
  1936. 'i386': [
  1937. 'REGRESSION',
  1938. 'http://localhost:18085/autopkgtest-testing-awesome-developers-staging/'
  1939. 'testing/i386/l/lightgreen/20150101_100100@/log.gz',
  1940. None,
  1941. 'http://localhost:18085/autopkgtest-testing-awesome-developers-staging/'
  1942. 'testing/i386/l/lightgreen/20150101_100100@/artifacts.tar.gz',
  1943. 'https://autopkgtest.ubuntu.com/request.cgi?release=testing&arch=i386&package=lightgreen&'
  1944. 'trigger=lightgreen%2F2&ppa=joe%2Ffoo&ppa=awesome-developers%2Fstaging']},
  1945. 'verdict': 'REJECTED_PERMANENTLY'})
  1946. self.assertEqual(self.amqp_requests, set())
  1947. self.assertEqual(self.pending_requests, {})
  1948. def test_disable_upgrade_tester(self):
  1949. '''Run without second stage upgrade tester'''
  1950. self.data.add_default_packages(green=False)
  1951. self.data.add('green', True, {'Depends': 'libc6 (>= 0.9), libgreen1',
  1952. 'Conflicts': 'blue', 'Version': '2'},
  1953. testsuite='autopkgtest')
  1954. self.data.compute_migrations = '--no-compute-migrations'
  1955. self.run_it(
  1956. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  1957. {})[1]
  1958. self.assertFalse(os.path.exists(os.path.join(self.data.path, 'output', 'output.txt')))
  1959. self.assertNotEqual(self.amqp_requests, set())
  1960. # must still record pending tests
  1961. # ## Not sure why this doesn't work in the debian env.
  1962. # # self.assertEqual(self.pending_requests, {'green/2': {'green': ['amd64', 'i386'],
  1963. # # 'darkgreen': ['amd64', 'i386'],
  1964. # # 'lightgreen': ['amd64', 'i386']}})
  1965. def test_shared_results_cache(self):
  1966. '''Run with shared r/o autopkgtest-results.cache'''
  1967. self.data.add_default_packages(lightgreen=False)
  1968. # first run to create autopkgtest-results.cache
  1969. self.swift.set_results({'autopkgtest-testing': {
  1970. 'testing/i386/l/lightgreen/20150101_100000@': (0, 'lightgreen 2', tr('lightgreen/2')),
  1971. 'testing/amd64/l/lightgreen/20150101_100000@': (0, 'lightgreen 2', tr('lightgreen/2')),
  1972. }})
  1973. self.run_it(
  1974. [('lightgreen', {'Version': '2', 'Depends': 'libc6'}, 'autopkgtest')],
  1975. {'lightgreen': (True, {'lightgreen/2': {'i386': 'PASS', 'amd64': 'PASS'}})},
  1976. )
  1977. # move and remember original contents
  1978. local_path = os.path.join(self.data.path, 'data/testing/state/autopkgtest-results.cache')
  1979. shared_path = os.path.join(self.data.path, 'shared_results.cache')
  1980. os.rename(local_path, shared_path)
  1981. with open(shared_path) as f:
  1982. orig_contents = f.read()
  1983. # enable shared cache
  1984. for line in fileinput.input(self.britney_conf, inplace=True):
  1985. if 'ADT_SHARED_RESULTS_CACHE' in line:
  1986. print('ADT_SHARED_RESULTS_CACHE = %s' % shared_path)
  1987. else:
  1988. sys.stdout.write(line)
  1989. # second run, should now not update cache
  1990. self.swift.set_results({'autopkgtest-testing': {
  1991. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 3', tr('lightgreen/3')),
  1992. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 3', tr('lightgreen/3')),
  1993. }})
  1994. self.data.remove_all(True)
  1995. self.run_it(
  1996. [('lightgreen', {'Version': '3', 'Depends': 'libc6'}, 'autopkgtest')],
  1997. {'lightgreen': (True, {'lightgreen/3': {'i386': 'PASS', 'amd64': 'PASS'}})},
  1998. )
  1999. # leaves autopkgtest-results.cache untouched
  2000. self.assertFalse(os.path.exists(local_path))
  2001. with open(shared_path) as f:
  2002. self.assertEqual(orig_contents, f.read())
  2003. ################################################################
  2004. # Tests for source ppa grouping
  2005. ################################################################
  2006. # # def test_sourceppa_policy(self):
  2007. # # '''Packages from same source PPA get rejected for failed peer policy'''
  2008. # #
  2009. # # self.data.add_default_packages(green=False)
  2010. # #
  2011. # # ppa = 'devel/~ci-train-ppa-service/+archive/NNNN'
  2012. # # self.sourceppa_cache['green'] = {'2': ppa}
  2013. # # self.sourceppa_cache['red'] = {'2': ppa}
  2014. # # with open(os.path.join(self.data.path, 'data/unstable/Blocks'), 'w') as f:
  2015. # # f.write('green 12345 1471505000\ndarkgreen 98765 1471500000\n')
  2016. # #
  2017. # # exc = self.run_it(
  2018. # # [('green', {'Version': '2'}, 'autopkgtest'),
  2019. # # ('red', {'Version': '2'}, 'autopkgtest'),
  2020. # # ('gcc-5', {}, 'autopkgtest')],
  2021. # # {'green': (False, {'green': {'i386': 'RUNNING-ALWAYSFAIL', 'amd64': 'RUNNING-ALWAYSFAIL'}}),
  2022. # # 'red': (False, {'red': {'i386': 'RUNNING-ALWAYSFAIL', 'amd64': 'RUNNING-ALWAYSFAIL'}}),
  2023. # # 'gcc-5': (True, {}),
  2024. # # },
  2025. # # {'green': [('reason', 'block')],
  2026. # # 'red': [('reason', 'source-ppa')]}
  2027. # # )[1]
  2028. # # self.assertEqual(exc['red']['policy_info']['source-ppa'], {'red': ppa, 'green': ppa})
  2029. # #
  2030. # # with open(os.path.join(self.data.path, 'data/unstable/SourcePPA')) as f:
  2031. # # res = json.load(f)
  2032. # # self.assertEqual(res, {'red': {'2': ppa},
  2033. # # 'green': {'2': ppa},
  2034. # # 'gcc-5': {'1': ''}})
  2035. # # def test_sourceppa_missingbuild(self):
  2036. # # '''Packages from same source PPA get rejected for failed peer FTBFS'''
  2037. # #
  2038. # # self.data.add_default_packages(green=False)
  2039. # #
  2040. # # ppa = 'devel/~ci-train-ppa-service/+archive/ZZZZ'
  2041. # # self.sourceppa_cache['green'] = {'2': ppa}
  2042. # # self.sourceppa_cache['red'] = {'2': ppa}
  2043. # #
  2044. # # self.data.add_src('green', True, {'Version': '2', 'Testsuite': 'autopkgtest'})
  2045. # # self.data.add('libgreen1', True, {'Version': '2', 'Source': 'green', 'Architecture': 'i386'}, add_src=False)
  2046. # # self.data.add('green', True, {'Version': '2', 'Source': 'green'}, add_src=False)
  2047. # #
  2048. # # exc = self.run_it(
  2049. # # [('red', {'Version': '2'}, 'autopkgtest')],
  2050. # # {'green': (False, {}), 'red': (False, {})},
  2051. # # {'green': [('missing-builds', {'on-architectures': ['amd64', 'arm64', 'armhf', 'powerpc', 'ppc64el'],
  2052. # # 'on-unimportant-architectures': []})],
  2053. # # 'red': [('reason', 'source-ppa')]}
  2054. # # )[1]
  2055. # # self.assertEqual(exc['red']['policy_info']['source-ppa'], {'red': ppa, 'green': ppa})
  2056. def test_swift_url_is_file(self):
  2057. '''Run without swift but with debci file (as Debian does)'''
  2058. '''Based on test_multi_rdepends_with_tests_regression'''
  2059. '''Multiple reverse dependencies with tests (regression)'''
  2060. debci_file = os.path.join(self.data.path, 'debci.output')
  2061. # Don't use swift but debci output file
  2062. for line in fileinput.input(self.britney_conf, inplace=True):
  2063. if line.startswith('ADT_SWIFT_URL'):
  2064. print('ADT_SWIFT_URL = file://%s' % debci_file)
  2065. else:
  2066. sys.stdout.write(line)
  2067. with open(debci_file, 'w') as f:
  2068. f.write('''
  2069. {
  2070. "until": 12345,
  2071. "results": [
  2072. {"trigger": "green/2", "package": "darkgreen", "arch": "i386", "version": "1", "status": "pass",
  2073. "run_id": "100000", "suite": "testing", "updated_at": "2018-10-04T11:18:00.000Z"},
  2074. {"trigger": "green/2", "package": "darkgreen", "arch": "amd64", "version": "1", "status": "pass",
  2075. "run_id": "100000", "suite": "testing", "updated_at": "2018-10-04T11:18:01.000Z"},
  2076. {"trigger": "green/1", "package": "lightgreen", "arch": "i386", "version": "1", "status": "pass",
  2077. "run_id": "101000", "suite": "testing", "updated_at": "2018-10-04T11:18:02.000Z"},
  2078. {"trigger": "green/2", "package": "lightgreen", "arch": "i386", "version": "1", "status": "fail",
  2079. "run_id": "101001", "suite": "testing", "updated_at": "2018-10-04T11:18:03.000Z"},
  2080. {"trigger": "green/1", "package": "lightgreen", "arch": "amd64", "version": "1", "status": "pass",
  2081. "run_id": "101000", "suite": "testing", "updated_at": "2018-10-04T11:18:04.000Z"},
  2082. {"trigger": "green/2", "package": "lightgreen", "arch": "amd64", "version": "1", "status": "fail",
  2083. "run_id": "101001", "suite": "testing", "updated_at": "2018-10-04T11:18:05.000Z"},
  2084. {"trigger": "green/2", "package": "green", "arch": "i386", "version": "2", "status": "pass",
  2085. "run_id": "102000", "suite": "testing", "updated_at": "2018-10-04T11:18:06.000Z"},
  2086. {"trigger": "green/1", "package": "green", "arch": "amd64", "version": "2", "status": "pass",
  2087. "run_id": "102000", "suite": "testing", "updated_at": "2018-10-04T11:18:07.000Z"},
  2088. {"trigger": "green/2", "package": "green", "arch": "amd64", "version": "2", "status": "fail",
  2089. "run_id": "102001", "suite": "testing", "updated_at": "2018-10-04T11:18:08.000Z"}
  2090. ]
  2091. }
  2092. ''')
  2093. self.data.add_default_packages(green=False)
  2094. out, exc, _ = self.run_it(
  2095. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  2096. {'green': (False, {'green/2': {'amd64': 'REGRESSION', 'i386': 'PASS'},
  2097. 'lightgreen/1': {'amd64': 'REGRESSION', 'i386': 'REGRESSION'},
  2098. 'darkgreen/1': {'amd64': 'PASS', 'i386': 'PASS'},
  2099. })
  2100. },
  2101. {'green': [('old-version', '1'), ('new-version', '2')]}
  2102. )
  2103. # should have links to log and history, but no artifacts (as this is
  2104. # not a PPA)
  2105. self.assertEqual(exc['green']['policy_info']['autopkgtest']['lightgreen/1']['amd64'][0],
  2106. 'REGRESSION')
  2107. link = urllib.parse.urlparse(exc['green']['policy_info']['autopkgtest']['lightgreen/1']['amd64'][1])
  2108. self.assertEqual(link.path[-53:], '/autopkgtest/testing/amd64/l/lightgreen/101001/log.gz')
  2109. self.assertEqual(exc['green']['policy_info']['autopkgtest']['lightgreen/1']['amd64'][2:4],
  2110. ['https://autopkgtest.ubuntu.com/packages/l/lightgreen/testing/amd64',
  2111. None])
  2112. # should have retry link for the regressions (not a stable URL, test
  2113. # separately)
  2114. link = urllib.parse.urlparse(exc['green']['policy_info']['autopkgtest']['lightgreen/1']['amd64'][4])
  2115. self.assertEqual(link.netloc, 'autopkgtest.ubuntu.com')
  2116. self.assertEqual(link.path, '/request.cgi')
  2117. self.assertEqual(urllib.parse.parse_qs(link.query),
  2118. {'release': ['testing'], 'arch': ['amd64'],
  2119. 'package': ['lightgreen'], 'trigger': ['green/2']})
  2120. # we already had all results before the run, so this should not trigger
  2121. # any new requests
  2122. self.assertEqual(self.amqp_requests, set())
  2123. self.assertEqual(self.pending_requests, {})
  2124. # not expecting any failures to retrieve from swift
  2125. self.assertNotIn('Failure', out, out)
  2126. def test_multi_rdepends_with_tests_mixed_penalty(self):
  2127. '''Bounty/penalty system instead of blocking
  2128. based on "Multiple reverse dependencies with tests (mixed results)"'''
  2129. # Don't use policy verdics, but age packages appropriate
  2130. for line in fileinput.input(self.britney_conf, inplace=True):
  2131. if line.startswith('MINDAYS_MEDIUM'):
  2132. print('MINDAYS_MEDIUM = 13')
  2133. elif line.startswith('ADT_SUCCESS_BOUNTY'):
  2134. print('ADT_SUCCESS_BOUNTY = 6')
  2135. elif line.startswith('ADT_REGRESSION_PENALTY'):
  2136. print('ADT_REGRESSION_PENALTY = 27')
  2137. else:
  2138. sys.stdout.write(line)
  2139. self.data.add_default_packages(green=False)
  2140. # green has passed before on i386 only, therefore ALWAYSFAIL on amd64
  2141. self.swift.set_results({'autopkgtest-testing': {
  2142. 'testing/i386/g/green/20150101_100000@': (0, 'green 1', tr('passedbefore/1')),
  2143. }})
  2144. # first run requests tests and marks them as pending
  2145. exc = self.run_it(
  2146. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  2147. {'green': (False, {'green': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING'},
  2148. 'lightgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  2149. 'darkgreen': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'RUNNING-ALWAYSFAIL'},
  2150. })
  2151. },
  2152. {'green': [('old-version', '1'), ('new-version', '2')]})[1]
  2153. # while no autopkgtest results are known, penalty applies
  2154. self.assertEqual(exc['green']['policy_info']['age']['age-requirement'], 40)
  2155. # second run collects the results
  2156. self.swift.set_results({'autopkgtest-testing': {
  2157. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  2158. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  2159. 'testing/amd64/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  2160. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  2161. 'testing/amd64/g/green/20150101_100201@': (4, 'green 2', tr('green/2')),
  2162. # unrelated results (wrong trigger), ignore this!
  2163. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/1')),
  2164. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('blue/1')),
  2165. }})
  2166. res = self.run_it(
  2167. [],
  2168. {'green': (False, {'green/2': {'amd64': 'ALWAYSFAIL', 'i386': 'PASS'},
  2169. 'lightgreen/1': {'amd64': 'REGRESSION', 'i386': 'RUNNING'},
  2170. 'darkgreen/1': {'amd64': 'RUNNING', 'i386': 'PASS'},
  2171. })
  2172. })
  2173. out = res[0]
  2174. exc = res[1]
  2175. self.assertIn('Update Excuses generation completed', out)
  2176. # not expecting any failures to retrieve from swift
  2177. self.assertNotIn('Failure', out)
  2178. # there should be some pending ones
  2179. self.assertEqual(self.pending_requests,
  2180. {'green/2': {'darkgreen': ['amd64'], 'lightgreen': ['i386']}})
  2181. # autopkgtest should not cause the package to be blocked
  2182. self.assertEqual(exc['green']['policy_info']['autopkgtest']['verdict'], 'PASS')
  2183. # instead, it should cause the age to sky-rocket
  2184. self.assertEqual(exc['green']['policy_info']['age']['age-requirement'], 40)
  2185. def test_multi_rdepends_with_tests_no_penalty(self):
  2186. '''Check that penalties are not applied for "urgency >= high"'''
  2187. # Don't use policy verdics, but age packages appropriate
  2188. for line in fileinput.input(self.britney_conf, inplace=True):
  2189. if line.startswith('MINDAYS_MEDIUM'):
  2190. print('MINDAYS_MEDIUM = 13')
  2191. elif line.startswith('ADT_SUCCESS_BOUNTY'):
  2192. print('ADT_SUCCESS_BOUNTY = 6')
  2193. elif line.startswith('ADT_REGRESSION_PENALTY'):
  2194. print('ADT_REGRESSION_PENALTY = 27')
  2195. elif line.startswith('NO_PENALTIES'):
  2196. print('NO_PENALTIES = medium')
  2197. else:
  2198. sys.stdout.write(line)
  2199. self.data.add_default_packages(green=False)
  2200. self.swift.set_results({'autopkgtest-testing': {
  2201. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  2202. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/1')),
  2203. 'testing/amd64/l/lightgreen/20150101_100101@': (4, 'lightgreen 1', tr('green/2')),
  2204. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  2205. 'testing/amd64/g/green/20150101_100201@': (4, 'green 2', tr('green/2')),
  2206. }})
  2207. exc = self.run_it(
  2208. [('libgreen1', {'Version': '2', 'Source': 'green', 'Depends': 'libc6'}, 'autopkgtest')],
  2209. {'green': (False, {'green/2': {'amd64': 'ALWAYSFAIL', 'i386': 'PASS'},
  2210. 'lightgreen/1': {'amd64': 'REGRESSION', 'i386': 'RUNNING-ALWAYSFAIL'},
  2211. 'darkgreen/1': {'amd64': 'RUNNING-ALWAYSFAIL', 'i386': 'PASS'},
  2212. })
  2213. })[1]
  2214. # age-requirement should remain the same despite regression
  2215. self.assertEqual(exc['green']['policy_info']['age']['age-requirement'], 13)
  2216. def test_passing_package_receives_bounty(self):
  2217. '''Test bounty system (instead of policy verdict)'''
  2218. # Don't use policy verdics, but age packages appropriate
  2219. for line in fileinput.input(self.britney_conf, inplace=True):
  2220. if line.startswith('MINDAYS_MEDIUM'):
  2221. print('MINDAYS_MEDIUM = 13')
  2222. elif line.startswith('ADT_SUCCESS_BOUNTY'):
  2223. print('ADT_SUCCESS_BOUNTY = 6')
  2224. elif line.startswith('ADT_REGRESSION_PENALTY'):
  2225. print('ADT_REGRESSION_PENALTY = 27')
  2226. else:
  2227. sys.stdout.write(line)
  2228. self.data.add_default_packages(green=False)
  2229. self.swift.set_results({'autopkgtest-testing': {
  2230. 'testing/i386/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  2231. 'testing/amd64/d/darkgreen/20150101_100000@': (0, 'darkgreen 1', tr('green/2')),
  2232. 'testing/i386/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/2')),
  2233. 'testing/amd64/l/lightgreen/20150101_100100@': (0, 'lightgreen 1', tr('green/2')),
  2234. 'testing/i386/g/green/20150101_100200@': (0, 'green 2', tr('green/2')),
  2235. 'testing/amd64/g/green/20150101_100201@': (0, 'green 2', tr('green/2')),
  2236. }})
  2237. exc = self.run_it(
  2238. [('green', {'Version': '2'}, 'autopkgtest')],
  2239. {'green': (False, {})},
  2240. {})[1]
  2241. # it should cause the age to drop
  2242. self.assertEqual(exc['green']['policy_info']['age']['age-requirement'], 8)
  2243. self.assertEqual(exc['green']['excuses'][-1], 'Required age is not allowed to drop below 8 days')
  2244. if __name__ == '__main__':
  2245. unittest.main()