From 580f8b30a821ff35b1335c4f7a3e75f874a99d72 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 29 Nov 2023 07:30:10 +0100 Subject: [PATCH] [PR #7625/3b779eca backport][stable-8] Fix bad expressions in tests (#7629) Fix bad expressions in tests (#7625) * Fix bad expressions in tests. ci_complete * Disable cmd_runner integration tests. ci_complete * Another bad expression. ci_complete (cherry picked from commit 3b779ecade5abe8fedc3f00839cbdfc400e8bbbd) Co-authored-by: Felix Fontein --- .../alternatives/tasks/tests_set_priority.yml | 2 +- .../targets/archive/tests/core.yml | 10 +++---- .../targets/archive/tests/remove.yml | 30 ++++++++++++++----- tests/integration/targets/cmd_runner/aliases | 1 + .../targets/deploy_helper/tasks/main.yml | 18 +++++------ .../targets/ini_file/tasks/tests/00-basic.yml | 2 +- .../targets/lvg/tasks/test_active_change.yml | 8 ++--- 7 files changed, 43 insertions(+), 28 deletions(-) diff --git a/tests/integration/targets/alternatives/tasks/tests_set_priority.yml b/tests/integration/targets/alternatives/tasks/tests_set_priority.yml index 46cf48e59b..9bc523b0dc 100644 --- a/tests/integration/targets/alternatives/tasks/tests_set_priority.yml +++ b/tests/integration/targets/alternatives/tasks/tests_set_priority.yml @@ -22,7 +22,7 @@ assert: that: - 'alternative is changed' - - 'cmd.stdout == "dummy{{ item }}"' + - 'cmd.stdout == "dummy" ~ item' - name: check that alternative has been updated command: "grep -Pzq '/bin/dummy{{ item }}\\n{{ 60 + item|int }}' '{{ alternatives_dir }}/dummy'" diff --git a/tests/integration/targets/archive/tests/core.yml b/tests/integration/targets/archive/tests/core.yml index 1c4f4d1aaf..21b07038f0 100644 --- a/tests/integration/targets/archive/tests/core.yml +++ b/tests/integration/targets/archive/tests/core.yml @@ -29,7 +29,7 @@ that: - archive_no_options is changed - "archive_no_options.dest_state == 'archive'" - - "{{ archive_no_options.archived | length }} == 3" + - "archive_no_options.archived | length == 3" - name: Remove the archive - no options ({{ format }}) file: @@ -54,7 +54,7 @@ that: - archive_file_options_stat is not changed - "archive_file_options.mode == '0600'" - - "{{ archive_file_options.archived | length }} == 3" + - "archive_file_options.archived | length == 3" - name: Remove the archive - file options ({{ format }}) file: @@ -146,7 +146,7 @@ assert: that: - archive_path_list is changed - - "{{ archive_path_list.archived | length }} == 3" + - "archive_path_list.archived | length == 3" - name: Remove archive - path list ({{ format }}) file: @@ -168,8 +168,8 @@ that: - archive_missing_paths is changed - "archive_missing_paths.dest_state == 'incomplete'" - - "'{{ remote_tmp_dir }}/dne.txt' in archive_missing_paths.missing" - - "'{{ remote_tmp_dir }}/foo.txt' not in archive_missing_paths.missing" + - "(remote_tmp_dir ~ '/dne.txt') in archive_missing_paths.missing" + - "(remote_tmp_dir ~ '/foo.txt') not in archive_missing_paths.missing" - name: Remove archive - missing paths ({{ format }}) file: diff --git a/tests/integration/targets/archive/tests/remove.yml b/tests/integration/targets/archive/tests/remove.yml index 8f0b8cff86..a7e151d25b 100644 --- a/tests/integration/targets/archive/tests/remove.yml +++ b/tests/integration/targets/archive/tests/remove.yml @@ -20,21 +20,28 @@ assert: that: - archive_remove_source_files is changed - - "{{ archive_remove_source_files.archived | length }} == 3" + - "archive_remove_source_files.archived | length == 3" - name: Remove Archive - remove source files ({{ format }}) file: path: "{{ remote_tmp_dir }}/archive_remove_source_files.{{ format }}" state: absent -- name: Assert that source files were removed - remove source files ({{ format }}) - assert: - that: - - "'{{ remote_tmp_dir }}/{{ item }}' is not exists" +- name: Remove source files in check mode ({{ format }}) + file: + path: "{{ remote_tmp_dir }}/{{ item }}" + state: absent + check_mode: true with_items: - foo.txt - bar.txt - empty.txt + register: remove_files + +- name: Assert that source files were removed - remove source files ({{ format }}) + assert: + that: + - remove_files is not changed - name: Copy source files - remove source directory ({{ format }}) copy: @@ -76,17 +83,24 @@ assert: that: - archive_remove_source_directory is changed - - "{{ archive_remove_source_directory.archived | length }} == 3" + - "archive_remove_source_directory.archived | length == 3" - name: Remove archive - remove source directory ({{ format }}) file: path: "{{ remote_tmp_dir }}/archive_remove_source_directory.{{ format }}" state: absent +- name: Remove source source directory in check mode ({{ format }}) + file: + path: "{{ remote_tmp_dir }}/tmpdir" + state: absent + check_mode: true + register: remove_dir + - name: Verify source directory was removed - remove source directory ({{ format }}) assert: that: - - "'{{ remote_tmp_dir }}/tmpdir' is not exists" + - remove_dir is not changed - name: Create temporary directory - remove source excluding path ({{ format }}) file: @@ -120,7 +134,7 @@ assert: that: - archive_remove_source_excluding_path is changed - - "{{ archive_remove_source_excluding_path.archived | length }} == 2" + - "archive_remove_source_excluding_path.archived | length == 2" - name: Remove archive - remove source excluding path ({{ format }}) file: diff --git a/tests/integration/targets/cmd_runner/aliases b/tests/integration/targets/cmd_runner/aliases index 12d1d6617e..0c3b04c1d4 100644 --- a/tests/integration/targets/cmd_runner/aliases +++ b/tests/integration/targets/cmd_runner/aliases @@ -3,3 +3,4 @@ # SPDX-License-Identifier: GPL-3.0-or-later azp/posix/2 +disabled # TODO diff --git a/tests/integration/targets/deploy_helper/tasks/main.yml b/tests/integration/targets/deploy_helper/tasks/main.yml index fdd8bd87b2..9bd5f41506 100644 --- a/tests/integration/targets/deploy_helper/tasks/main.yml +++ b/tests/integration/targets/deploy_helper/tasks/main.yml @@ -17,25 +17,25 @@ assert: that: - "'project_path' in deploy_helper" - - "deploy_helper.current_path == '{{ deploy_helper.project_path }}/current'" - - "deploy_helper.releases_path == '{{ deploy_helper.project_path }}/releases'" - - "deploy_helper.shared_path == '{{ deploy_helper.project_path }}/shared'" + - "deploy_helper.current_path == deploy_helper.project_path ~ '/current'" + - "deploy_helper.releases_path == deploy_helper.project_path ~ '/releases'" + - "deploy_helper.shared_path == deploy_helper.project_path ~ '/shared'" - "deploy_helper.unfinished_filename == 'DEPLOY_UNFINISHED'" - "'previous_release' in deploy_helper" - "'previous_release_path' in deploy_helper" - "'new_release' in deploy_helper" - "'new_release_path' in deploy_helper" - - "deploy_helper.new_release_path == '{{ deploy_helper.releases_path }}/{{ deploy_helper.new_release }}'" + - "deploy_helper.new_release_path == deploy_helper.releases_path ~ '/' ~ deploy_helper.new_release" - name: State=query with relative overridden paths deploy_helper: path={{ deploy_helper_test_root }} current_path=CURRENT_PATH releases_path=RELEASES_PATH shared_path=SHARED_PATH state=query - name: Assert State=query with relative overridden paths assert: that: - - "deploy_helper.current_path == '{{ deploy_helper.project_path }}/CURRENT_PATH'" - - "deploy_helper.releases_path == '{{ deploy_helper.project_path }}/RELEASES_PATH'" - - "deploy_helper.shared_path == '{{ deploy_helper.project_path }}/SHARED_PATH'" - - "deploy_helper.new_release_path == '{{ deploy_helper.releases_path }}/{{ deploy_helper.new_release}}'" + - "deploy_helper.current_path == deploy_helper.project_path ~ '/CURRENT_PATH'" + - "deploy_helper.releases_path == deploy_helper.project_path ~ '/RELEASES_PATH'" + - "deploy_helper.shared_path == deploy_helper.project_path ~ '/SHARED_PATH'" + - "deploy_helper.new_release_path == deploy_helper.releases_path ~ '/' ~ deploy_helper.new_release" - name: State=query with absolute overridden paths deploy_helper: path={{ deploy_helper_test_root }} current_path=/CURRENT_PATH releases_path=/RELEASES_PATH shared_path=/SHARED_PATH state=query @@ -45,7 +45,7 @@ - "deploy_helper.current_path == '/CURRENT_PATH'" - "deploy_helper.releases_path == '/RELEASES_PATH'" - "deploy_helper.shared_path == '/SHARED_PATH'" - - "deploy_helper.new_release_path == '{{ deploy_helper.releases_path }}/{{ deploy_helper.new_release}}'" + - "deploy_helper.new_release_path == deploy_helper.releases_path ~ '/' ~ deploy_helper.new_release" - name: State=query with overridden unfinished_filename deploy_helper: path={{ deploy_helper_test_root }} unfinished_filename=UNFINISHED_DEPLOY state=query diff --git a/tests/integration/targets/ini_file/tasks/tests/00-basic.yml b/tests/integration/targets/ini_file/tasks/tests/00-basic.yml index 2d0ab3ac4c..f36fd54c54 100644 --- a/tests/integration/targets/ini_file/tasks/tests/00-basic.yml +++ b/tests/integration/targets/ini_file/tasks/tests/00-basic.yml @@ -39,4 +39,4 @@ that: - result_basic_2 is not changed - result_basic_2 is failed - - result_basic_2.msg == "Destination {{ non_existing_file }} does not exist!" + - result_basic_2.msg == "Destination " ~ non_existing_file ~ " does not exist!" diff --git a/tests/integration/targets/lvg/tasks/test_active_change.yml b/tests/integration/targets/lvg/tasks/test_active_change.yml index 8ff88e6fbb..7df52683f6 100644 --- a/tests/integration/targets/lvg/tasks/test_active_change.yml +++ b/tests/integration/targets/lvg/tasks/test_active_change.yml @@ -35,7 +35,7 @@ loop: "{{ initial_lv_status_result.stdout_lines }}" assert: that: - - "'active' == '{{ item }}'" + - "'active' == item" - name: Deactivate volume group lvg: @@ -100,7 +100,7 @@ loop: "{{ activate_lv_status_result.stdout_lines }}" assert: that: - - "'active' == '{{ item }}'" + - "'active' == item" - name: Activate volume group again to verify idempontency lvg: @@ -138,7 +138,7 @@ loop: "{{ activate_partial_lv_status_result.stdout_lines }}" assert: that: - - "'active' == '{{ item }}'" + - "'active' == item" - name: Deactivate volume group in check mode lvg: @@ -160,4 +160,4 @@ loop: "{{ check_mode_deactivate_lv_status_result.stdout_lines }}" assert: that: - - "'active' == '{{ item }}'" + - "'active' == item"