def test_create_logs_dump(backup_func, skale_container, removed_containers_folder): archive_path = create_logs_dump(G_CONF_HOME) safe_mkdir(TEST_ARCHIVE_FOLDER_PATH) cmd = shlex.split(f'tar xf {archive_path} -C {TEST_ARCHIVE_FOLDER_PATH}') run_cmd(cmd) test_container_log_path = os.path.join(TEST_ARCHIVE_FOLDER_PATH, 'containers', f'{TEST_SKALE_NAME}.log') with open(test_container_log_path) as data_file: content = data_file.readlines() assert content == [ 'Hello, SKALE!\n', '================================================================================\n', # noqa 'Hello, SKALE!\n' ] assert os.path.exists( os.path.join(TEST_ARCHIVE_FOLDER_PATH, 'removed_containers')) assert os.path.exists(os.path.join(TEST_ARCHIVE_FOLDER_PATH, 'cli')) assert os.path.exists(os.path.join(TEST_ARCHIVE_FOLDER_PATH, 'containers')) assert os.path.isfile( os.path.join(TEST_ARCHIVE_FOLDER_PATH, 'cli', 'debug-node-cli.log')) assert os.path.isfile( os.path.join(TEST_ARCHIVE_FOLDER_PATH, 'cli', 'node-cli.log'))
def download_skale_node(stream: Optional[str], src: Optional[str]) -> None: rm_dir(CONTAINER_CONFIG_TMP_PATH) safe_mkdir(CONTAINER_CONFIG_TMP_PATH) dest = CONTAINER_CONFIG_TMP_PATH if src: rsync_dirs(src, dest) else: clone_repo(SKALE_NODE_REPO_URL, CONTAINER_CONFIG_TMP_PATH, stream)
def create_dump_dir(): time = datetime.datetime.utcnow().strftime("%Y-%m-%d--%H-%M-%S") folder_name = f'skale-logs-dump-{time}' folder_path = os.path.join(SKALE_TMP_DIR, folder_name) containers_path = os.path.join(folder_path, 'containers') logger.debug(f'Creating tmp dir for logs dump: {folder_path}') safe_mkdir(containers_path) return folder_path, folder_name
def test_generate(): safe_mkdir(NODE_DATA_PATH) resp_mock = response_mock(requests.codes.created) with mock.patch('node_cli.core.resources.get_disk_size', return_value=BIG_DISK_SIZE): result = run_command_mock('node_cli.utils.helper.post_request', resp_mock, generate, ['./tests/test-env', '--yes']) assert result.output == (f'Resource allocation file generated: ' f'{RESOURCE_ALLOCATION_FILEPATH}\n') assert result.exit_code == 0
def save_report(new_report: List[Dict], report_path: str = CHECK_REPORT_PATH) -> None: safe_mkdir(REPORTS_PATH) with open(report_path, 'w') as report_file: json.dump(new_report, report_file, indent=4)