Permalink
Please sign in to comment.
Browse files
Merge pull request #105 from juju-solutions/feature/ha-flag
Feature/ha flag
- Loading branch information...
Showing
with
146 additions
and 11 deletions.
- +1 −1 .gitignore
- +44 −2 matrix/main.py
- +2 −2 matrix/matrix.yaml
- +1 −1 matrix/model.py
- +1 −1 matrix/rules.py
- +3 −3 matrix/tasks/chaos/main.py
- +2 −1 matrix/tasks/health.py
- +13 −0 matrix/utils.py
- +2 −0 tests/basic_bundle/tests/test.yaml
- +13 −0 tests/functional/gating_test.py
- +31 −0 tests/test_config.py
- +9 −0 tests/test_ha_gating.matrix
- +24 −0 tests/test_utils.py
| @@ -0,0 +1,2 @@ | ||
| +matrix: | ||
| + model_prefix: matrixtest |
| @@ -0,0 +1,31 @@ | ||
| +import mock | ||
| +import unittest | ||
| + | ||
| +from matrix import main | ||
| + | ||
| + | ||
| +class TestConfig(unittest.TestCase): | ||
| + | ||
| + def test_add_bundle_opts(self): | ||
| + """ | ||
| + _test_add_bundle_opts_ | ||
| + | ||
| + This test requires that we have a test.yaml in | ||
| + tests/basic_bundle/test.yaml, with a model_prefix equal to | ||
| + matrixtest. | ||
| + | ||
| + """ | ||
| + options = mock.Mock() | ||
| + parser = mock.Mock() | ||
| + options.path = 'tests/basic_bundle' | ||
| + options.model_prefix = 'matrix' # default | ||
| + parser.get_default.return_value = 'matrix' | ||
| + | ||
| + # Verify that we can override a default value | ||
| + options = main.add_bundle_opts(options, parser) | ||
| + self.assertEqual(options.model_prefix, 'matrixtest') | ||
| + | ||
| + # Verify that we can't override a non default value | ||
| + options.model_prefix = 'bar' | ||
| + options = main.add_bundle_opts(options, parser) | ||
| + self.assertEqual(options.model_prefix, 'bar') |
| @@ -0,0 +1,9 @@ | ||
| +#!/usr/bin/env matrix | ||
| +"tests": | ||
| +- "name": Verify that we can turn gating off. | ||
| + "description": > | ||
| + This test succeeds if matrix exits with a zero exit code. | ||
| + "rules": | ||
| + - "do": | ||
| + "task": matrix.tasks.fail | ||
| + "gating": ha_only |
| @@ -0,0 +1,24 @@ | ||
| +import unittest | ||
| +import mock | ||
| + | ||
| +from matrix import utils | ||
| + | ||
| + | ||
| +class TestUtils(unittest.TestCase): | ||
| + def test_should_gate(self): | ||
| + context = mock.Mock() | ||
| + task = mock.Mock() | ||
| + | ||
| + task.gating = True | ||
| + self.assertTrue(utils.should_gate(context, task)) | ||
| + | ||
| + task.gating = 'ha_only' | ||
| + context.ha = False | ||
| + self.assertFalse(utils.should_gate(context, task)) | ||
| + | ||
| + task.gating = 'ha_only' | ||
| + context.ha = True | ||
| + self.assertTrue(utils.should_gate(context, task)) | ||
| + | ||
| + task.gating = False | ||
| + self.assertFalse(utils.should_gate(context, task)) |
0 comments on commit
7329196