Beispiel #1
0
 def test_negate_condition(self):
     self.assertEqual(
         negate_condition('a == b'),
         'not (a == b)'
     )
     self.assertEqual(
         negate_condition('a != b'),
         'not (a != b)'
     )
     self.assertEqual(
         negate_condition('a in b'),
         'not (a in b)'
     )
 def test_negate_condition(self):
     self.assertEqual(
         negate_condition('a == b'),
         'not (a == b)'
     )
     self.assertEqual(
         negate_condition('a != b'),
         'not (a != b)'
     )
     self.assertEqual(
         negate_condition('a in b'),
         'not (a in b)'
     )
Beispiel #3
0
    def test_release_roles_metadata_upgrade_51_to_60(self):
        operational_restriction = {
            'condition': "cluster:status != 'operational'",
            'warning': "MongoDB node can not be added to an "
                       "operational environment."
        }
        ceilometer_restriction = {
            'condition': 'settings:additional_components.ceilometer.value? == '
                         'true',
            'warning': "Ceilometer should be enabled."
        }
        new_operational_restriction = {
            'condition': remove_question_operator(negate_condition(
                operational_restriction['condition'])),
            'message': operational_restriction['warning'],
        }
        new_ceilometer_restriction = {
            'condition': remove_question_operator(negate_condition(
                ceilometer_restriction['condition'])),
            'message': ceilometer_restriction['warning']
        }
        false_restriction = {
            'condition': "1 == 2",
            'message': "This is always false"
        }
        roles_metadata_51 = {
            'mongo': {
                'name': "Telemetry - MongoDB",
                'description': "A feature-complete and recommended "
                               "database for storage of metering data "
                               "from OpenStack Telemetry (Ceilometer)",
                'conflicts': ['compute',
                              'ceph-osd',
                              'zabbix-server'],
                'depends': [
                    operational_restriction,
                    ceilometer_restriction
                ],
            },
            'test': {
                'name': "Test restrictions extend",
                'description': "Testing restrictions list extend",
                'conflicts': [],
                'depends': [
                    operational_restriction,
                    ceilometer_restriction
                ],
                'restrictions': [
                    false_restriction
                ]
            }
        }

        roles_metadata_60 = upgrade_release_roles_51_to_60(
            roles_metadata_51
        )

        self.assertTrue('depends' not in roles_metadata_60["mongo"])
        self.assertTrue('depends' not in roles_metadata_60["test"])
        self.assertEqual(roles_metadata_60['mongo']['restrictions'],
                         [
                             new_operational_restriction,
                             new_ceilometer_restriction
                         ])
        self.assertEqual(roles_metadata_60['test']['restrictions'],
                         [
                             false_restriction,
                             new_operational_restriction,
                             new_ceilometer_restriction
                         ])
Beispiel #4
0
    def test_release_roles_metadata_upgrade_51_to_60(self):
        operational_restriction = {
            'condition':
            "cluster:status != 'operational'",
            'warning':
            "MongoDB node can not be added to an "
            "operational environment."
        }
        ceilometer_restriction = {
            'condition': 'settings:additional_components.ceilometer.value? == '
            'true',
            'warning': "Ceilometer should be enabled."
        }
        new_operational_restriction = {
            'condition':
            remove_question_operator(
                negate_condition(operational_restriction['condition'])),
            'message':
            operational_restriction['warning'],
        }
        new_ceilometer_restriction = {
            'condition':
            remove_question_operator(
                negate_condition(ceilometer_restriction['condition'])),
            'message':
            ceilometer_restriction['warning']
        }
        false_restriction = {
            'condition': "1 == 2",
            'message': "This is always false"
        }
        roles_metadata_51 = {
            'mongo': {
                'name':
                "Telemetry - MongoDB",
                'description':
                "A feature-complete and recommended "
                "database for storage of metering data "
                "from OpenStack Telemetry (Ceilometer)",
                'conflicts': ['compute', 'ceph-osd', 'zabbix-server'],
                'depends': [operational_restriction, ceilometer_restriction],
            },
            'test': {
                'name': "Test restrictions extend",
                'description': "Testing restrictions list extend",
                'conflicts': [],
                'depends': [operational_restriction, ceilometer_restriction],
                'restrictions': [false_restriction]
            }
        }

        roles_metadata_60 = upgrade_release_roles_51_to_60(roles_metadata_51)

        self.assertTrue('depends' not in roles_metadata_60["mongo"])
        self.assertTrue('depends' not in roles_metadata_60["test"])
        self.assertEqual(
            roles_metadata_60['mongo']['restrictions'],
            [new_operational_restriction, new_ceilometer_restriction])
        self.assertEqual(roles_metadata_60['test']['restrictions'], [
            false_restriction, new_operational_restriction,
            new_ceilometer_restriction
        ])