def test_package_common_1(self): maintain_config = common.load_yaml_file("test-maintain.yaml") cluster_config = common.load_yaml_file("test-cluster-config.yaml") node_config = cluster_config['workermachinelist']['worker-01'] common.maintain_package_wrapper(cluster_config, maintain_config, node_config, "unittest-common-1") self.assertTrue( os.path.exists("parcel-center/1.2.3.2/unittest-common-1.tar")) package = tarfile.open("parcel-center/1.2.3.2/unittest-common-1.tar", "r:") package.extractall() self.assertTrue(os.path.exists("unittest-common-1/")) target_file_list = ["testfile1.sh", "testfile2.sh"] package_file_list = os.listdir("unittest-common-1/") self.assertListEqual(sorted(target_file_list), sorted(package_file_list)) shutil.rmtree("unittest-common-1/") common.maintain_package_cleaner(node_config) self.assertFalse(os.path.exists("parcel-center/1.2.3.2")) self.assertTrue(os.path.exists("parcel-center")) shutil.rmtree("parcel-center/")
def test_etcdfix_conf_validation_node_config_validation(self): node_list = common.load_yaml_file( "data/data_maintainlib_etcdfix/test_node_list_config.yaml") cluster_config = common.load_yaml_file( "data/data_maintainlib_etcdfix/test_cluster_config_ok.yaml") node_config = node_list['machinelist']['ok-machine-node'] validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertTrue(validation.node_conf_validation()) node_config = node_list['machinelist']['miss-node-name'] validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertFalse(validation.node_conf_validation()) node_config = node_list['machinelist']['miss-host-ip'] validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertFalse(validation.node_conf_validation()) node_config = node_list['machinelist']['wrong-host-ip'] validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertFalse(validation.node_conf_validation()) node_config = node_list['machinelist']['wrong-ssh-port'] validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertFalse(validation.node_conf_validation()) node_config = node_list['machinelist']['miss-user-name'] validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertFalse(validation.node_conf_validation()) node_config = node_list['machinelist']['miss-password'] validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertFalse(validation.node_conf_validation()) node_config = node_list['machinelist']['miss-etcd-id'] validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertFalse(validation.node_conf_validation())
def setup_logging(): """ Setup logging configuration. """ configuration_path = "sysconf/logging.yaml" logging_configuration = pai_common.load_yaml_file(configuration_path) logging.config.dictConfig(logging_configuration)
def test_etcdfix_conf_validation_cluster_config_validation(self): node_list = common.load_yaml_file( "data/data_maintainlib_etcdfix/test_node_list_config.yaml") node_config = node_list['machinelist']['ok-machine-node'] cluster_config = common.load_yaml_file( "data/data_maintainlib_etcdfix/test_cluster_config_ok.yaml") validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertTrue(validation.cluster_conf_validation()) cluster_config = common.load_yaml_file( "data/data_maintainlib_etcdfix/test_cluster_config_miss_master_list.yaml" ) validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertFalse(validation.cluster_conf_validation()) cluster_config = common.load_yaml_file( "data/data_maintainlib_etcdfix/test_cluster_config_miss_node_config.yaml" ) validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertFalse(validation.cluster_conf_validation()) cluster_config = common.load_yaml_file( "data/data_maintainlib_etcdfix/test_cluster_config_wrong_node_config.yaml" ) validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertFalse(validation.cluster_conf_validation()) cluster_config = common.load_yaml_file( "data/data_maintainlib_etcdfix/test_cluster_config_inconsistent_node_config.yaml" ) validation = etcdfix.etcdfix_conf_validation(cluster_config, node_config) self.assertFalse(validation.cluster_conf_validation())