| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The LUCI Authors. All rights reserved. | 2 # Copyright 2015 The LUCI Authors. All rights reserved. |
| 3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
| 4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import collections | 6 import collections |
| 7 import contextlib | 7 import contextlib |
| 8 import datetime | 8 import datetime |
| 9 import json | 9 import json |
| 10 import os | 10 import os |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 | 655 |
| 656 def testNestedStream(self): | 656 def testNestedStream(self): |
| 657 with self._new_stream_engine() as se: | 657 with self._new_stream_engine() as se: |
| 658 # parent | 658 # parent |
| 659 with self._step_stream(se, name='parent') as step: | 659 with self._step_stream(se, name='parent') as step: |
| 660 step.write_line('I am the parent.') | 660 step.write_line('I am the parent.') |
| 661 | 661 |
| 662 # parent."child 1" | 662 # parent."child 1" |
| 663 with self._step_stream(se, | 663 with self._step_stream(se, |
| 664 name='child 1', | 664 name='child 1', |
| 665 step_nest_level=1) as step: | 665 nest_level=1) as step: |
| 666 step.write_line('I am child #1.') | 666 step.write_line('I am child #1.') |
| 667 | 667 |
| 668 # parent."child 1"."grandchild" | 668 # parent."child 1"."grandchild" |
| 669 with self._step_stream(se, | 669 with self._step_stream(se, |
| 670 name='grandchild', | 670 name='grandchild', |
| 671 step_nest_level=2) as step: | 671 nest_level=2) as step: |
| 672 step.write_line("I am child #1's child.") | 672 step.write_line("I am child #1's child.") |
| 673 | 673 |
| 674 # parent."child 2". Mark this child as failed. This should not propagate | 674 # parent."child 2". Mark this child as failed. This should not propagate |
| 675 # to the parent, since it has an explicit status. | 675 # to the parent, since it has an explicit status. |
| 676 with self._step_stream(se, | 676 with self._step_stream(se, |
| 677 name='child 2', | 677 name='child 2', |
| 678 step_nest_level=1) as step: | 678 nest_level=1) as step: |
| 679 step.write_line('I am child #2.') | 679 step.write_line('I am child #2.') |
| 680 | 680 |
| 681 # parent."child 2". Mark this child as failed. This should not propagate | 681 # parent."child 2". Mark this child as failed. This should not propagate |
| 682 # to the parent, since it has an explicit status. | 682 # to the parent, since it has an explicit status. |
| 683 with self._step_stream(se, name='friend') as step: | 683 with self._step_stream(se, name='friend') as step: |
| 684 step.write_line("I am the parent's friend.") | 684 step.write_line("I am the parent's friend.") |
| 685 | 685 |
| 686 self.assertEqual(self.client.all_streams(), { | 686 self.assertEqual(self.client.all_streams(), { |
| 687 u'annotations': { | 687 u'annotations': { |
| 688 u'name': u'steps', | 688 u'name': u'steps', |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 # Root step. | 964 # Root step. |
| 965 base = self.astate.base | 965 base = self.astate.base |
| 966 self.astate.create_step(recipe_api.StepConfig.create(name='first')) | 966 self.astate.create_step(recipe_api.StepConfig.create(name='first')) |
| 967 self.assertEqual(len(base.substep), 1) | 967 self.assertEqual(len(base.substep), 1) |
| 968 self.assertEqual(base.substep[0].step.name, 'first') | 968 self.assertEqual(base.substep[0].step.name, 'first') |
| 969 self.assertIsNotNone(self.astate.check()) | 969 self.assertIsNotNone(self.astate.check()) |
| 970 | 970 |
| 971 # Child step. | 971 # Child step. |
| 972 self.astate.create_step(recipe_api.StepConfig.create( | 972 self.astate.create_step(recipe_api.StepConfig.create( |
| 973 name='first child', | 973 name='first child', |
| 974 step_nest_level=1)) | 974 nest_level=1)) |
| 975 self.assertEqual(len(base.substep), 1) | 975 self.assertEqual(len(base.substep), 1) |
| 976 self.assertEqual(len(base.substep[0].step.substep), 1) | 976 self.assertEqual(len(base.substep[0].step.substep), 1) |
| 977 self.assertEqual(base.substep[0].step.substep[0].step.name, 'first child') | 977 self.assertEqual(base.substep[0].step.substep[0].step.name, 'first child') |
| 978 self.assertIsNotNone(self.astate.check()) | 978 self.assertIsNotNone(self.astate.check()) |
| 979 | 979 |
| 980 # Sibling step to 'first'. | 980 # Sibling step to 'first'. |
| 981 self.astate.create_step(recipe_api.StepConfig.create(name='second')) | 981 self.astate.create_step(recipe_api.StepConfig.create(name='second')) |
| 982 self.assertEqual(len(base.substep), 2) | 982 self.assertEqual(len(base.substep), 2) |
| 983 self.assertEqual(base.substep[1].step.name, 'second') | 983 self.assertEqual(base.substep[1].step.name, 'second') |
| 984 self.assertIsNotNone(self.astate.check()) | 984 self.assertIsNotNone(self.astate.check()) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 sn = sn.append('#!!! stream name !!!') | 1021 sn = sn.append('#!!! stream name !!!') |
| 1022 self.assertEqual(str(sn), 'base/s______stream_name____') | 1022 self.assertEqual(str(sn), 'base/s______stream_name____') |
| 1023 | 1023 |
| 1024 def testAugmentInvalidStreamNameNormalizes(self): | 1024 def testAugmentInvalidStreamNameNormalizes(self): |
| 1025 sn = stream_logdog._StreamName('base') | 1025 sn = stream_logdog._StreamName('base') |
| 1026 self.assertEqual(str(sn.augment(' !!! other !!! ')), 'base_____other_____') | 1026 self.assertEqual(str(sn.augment(' !!! other !!! ')), 'base_____other_____') |
| 1027 | 1027 |
| 1028 | 1028 |
| 1029 if __name__ == '__main__': | 1029 if __name__ == '__main__': |
| 1030 unittest.main() | 1030 unittest.main() |
| OLD | NEW |