def test_invalid_cluster_config(self):
        """ Test config_apply for invalid cluster.yaml """

        cluster_conf_file_path = "/tmp/invalid_cluster.yaml"
        # cluster_id, node_types, nodes are missing in below data.
        # config_apply should fail.
        data = {
            "cluster": {
                "name": "cortx-cluster",
                "storage_sets": [
                    {"name": "storage-set-1"}
                ]
            }
        }
        f = open(cluster_conf_file_path, 'w+')
        f.write(yaml.dump(data))
        f.close()
        cluster_conf_url = f"yaml://{cluster_conf_file_path}"
        rc = 0
        try:
            CortxProvisioner.config_apply(cluster_conf_url, cortx_conf_url)

        except Exception as e:
            print(e)
            rc = 1

        self.assertEqual(rc, 1)
        os.remove(cluster_conf_file_path)
    def test_for_multiple_storage_sets(self):
        """ Test for multiple storage sets """

        cluster_conf_file_path = "/tmp/cluster.yaml"
        data = {
            "cluster": {
                "name":
                "cortx-cluster",
                "id":
                "C01",
                "node_types": [{
                    "name": "control_node",
                    "components": [{
                        "name": "csm"
                    }]
                }],
                "storage_sets": [{
                    "name":
                    "storage-set-1",
                    "durability": {
                        "sns": "8+7+0",
                        "dix": "1+7+0"
                    },
                    "nodes": [{
                        "name": "pod-1",
                        "id": '1',
                        "hostname": "pod-1.colo.seagate.com",
                        "type": "control_node"
                    }]
                }, {
                    "name":
                    "storage-set-2",
                    "durability": {
                        "sns": "8+7+0",
                        "dix": "1+7+0"
                    },
                    "nodes": [{
                        "name": "pod-2",
                        "id": '2',
                        "hostname": "pod-2.colo.seagate.com",
                        "type": "control_node"
                    }]
                }]
            }
        }
        f = open(cluster_conf_file_path, 'w+')
        f.write(yaml.dump(data))
        f.close()
        cluster_conf_url = f"yaml://{cluster_conf_file_path}"
        rc = 0
        try:
            CortxProvisioner.config_apply(cluster_conf_url, cortx_conf_url)

        except Exception as e:
            print(e)
            rc = 1

        self.assertEqual(rc, 0)
        os.remove(cluster_conf_file_path)
Beispiel #3
0
 def process(self, *args, **kwargs):
     """ Bootsrap Cluster """
     self._validate()
     force_override = True if self._args.override else False
     if self._args.action == 'bootstrap':
         CortxProvisioner.cluster_bootstrap(self._args.cortx_conf,
                                            force_override)
     if self._args.action == 'upgrade':
         CortxProvisioner.cluster_upgrade(self._args.cortx_conf,
                                          force_override)
     return 0
 def test_update_conf(self):
     """Test if new keys from changeset are getting updated in conf"""
     rc = 0
     try:
         CortxProvisioner._update_conf('index2', 'index1')
     except Exception as e:
         print('Exception: ', e)
         sys.stderr.write("%s\n" % traceback.format_exc())
         rc = 1
     self.assertEqual(rc, 0)
     self.assertEqual(Conf.get('index2', 'cortx>common>name'), 'CORTX')
Beispiel #5
0
 def process(self, *args, **kwargs):
     """Bootsrap Cluster."""
     self._validate()
     force_override = True if self._args.override else False
     if self._args.action == 'bootstrap':
         CortxProvisioner.cluster_bootstrap(self._args.cortx_conf,
                                            force_override)
     # TODO: upgrade CLI code needs to be removed as boostrap CLi will be
     # Internally calling deploy/upgrade based on version compatibility
     if self._args.action == 'upgrade':
         CortxProvisioner.cluster_upgrade(self._args.cortx_conf,
                                          force_override)
     return 0
Beispiel #6
0
    def test_config_apply_bootstrap(self):
        """ Test Config Apply """

        rc = 0
        try:
            CortxProvisioner.config_apply(solution_cluster_url, cortx_conf_url)
            CortxProvisioner.config_apply(solution_conf_url,
                                          cortx_conf_url,
                                          force_override=True)
        except Exception as e:
            print('Exception: ', e)
            sys.stderr.write("%s\n" % traceback.format_exc())
            rc = 1

        self.assertEqual(rc, 0)

        rc = 0
        try:
            CortxProvisioner.cluster_bootstrap(cortx_conf_url)
            CortxProvisioner.cluster_upgrade(cortx_conf_url)
        except Exception as e:
            print('Exception: ', e)
            sys.stderr.write("%s\n" % traceback.format_exc())
            rc = 1

        self.assertEqual(rc, 0)
Beispiel #7
0
    def process(self):
        """ Apply Config """
        self._validate()
        if self._args.action == 'apply':
            force_override = True if self._args.override else False
            CortxProvisioner.config_apply(self._args.solution_conf,
                                          self._args.cortx_conf,
                                          force_override)
        if self._args.action == 'validate':
            validations = ['all']
            if self._args.validations is not None:
                validations = self._args.validations.split(',')
            Validator.validate(validations, self._args.solution_conf,
                               self._args.cortx_conf)

        return 0
Beispiel #8
0
    def test_invalid_cortx_config(self):
        """ Test config_apply for invalid config.yaml """

        config_conf_file_path = "/tmp/invalid_config.yaml"
        # 'common' are missing in below data.
        # config_apply should fail.
        data = {"cortx": {"external": ""}}
        f = open(config_conf_file_path, 'w+')
        f.write(yaml.dump(data))
        f.close()
        config_conf_url = f"yaml://{config_conf_file_path}"
        rc = 0
        try:
            CortxProvisioner.config_apply(config_conf_url, cortx_conf_url)

        except Exception as e:
            print(e)
            rc = 1

        self.assertEqual(rc, 1)
        os.remove(config_conf_file_path)
 def test_prepare_diff(self):
     """Test if changeset file is getting generated with new/changes/deleted keys"""
     Conf.load('index1', tmp_conf_url)
     Conf.load('index2', cortx_conf_url)
     # add 1 new key in tmp conf
     Conf.set('index1', 'cortx>common>name', 'CORTX')
     # Change previous key from tmp conf
     Conf.set('index1', 'cortx>common>security>device_certificate',
              '/etc/cortx/solution/security.pem')
     # Delete one key from tmp conf
     Conf.delete('index1', 'cortx>common>security>domain_certificate')
     Conf.save('index1')
     rc = 0
     try:
         CortxProvisioner._prepare_diff('index2', 'index1', 'index3')
     except Exception as e:
         print('Exception: ', e)
         sys.stderr.write("%s\n" % traceback.format_exc())
         rc = 1
     self.assertEqual(rc, 0)
     self.assertEqual(Conf.get('index3', 'new>cortx>common>name'), 'CORTX')
 def test_num_xxx_in_gconf(self):
     """Test if num_xxx key is saved in gconf for list items(CORTX-30863)."""
     rc = 0
     try:
         CortxProvisioner.config_apply(solution_cluster_url, cortx_conf_url)
         CortxProvisioner.config_apply(solution_conf_url,
                                       cortx_conf_url,
                                       force_override=True)
     except Exception as e:
         print('Exception: ', e)
         sys.stderr.write("%s\n" % traceback.format_exc())
         rc = 1
     self.assertEqual(rc, 0)
     conf_path = cortx_conf_url.split('//')[1]
     rc = 0
     with open(conf_path, 'r') as stream:
         try:
             gconf = yaml.safe_load(stream)
         except yaml.YAMLError as exc:
             print(exc)
             rc = 1
     self.assertEqual(rc, 0)
     is_key_present, message = check_num_xx_keys(gconf)
     self.assertTrue(is_key_present, message)