From 18feeb51a88e221bbfaaaaf4d466d5b3330e429d Mon Sep 17 00:00:00 2001
From: Sam Doran <sdoran@redhat.com>
Date: Wed, 19 Jun 2019 12:38:05 -0400
Subject: [PATCH] Change integration tests in order to pass on Fedora 30
 (#58081)

* Use different package for DNF tests
    Ninja caused errors in Fedora 30. This works in both Fedora 29 and 30.

* Fix git integration tests
    Git >= 2.21.0 has either a bug or change in behavior where it errors when fetching a
    repository containing submodules that are behind the upstream submodule commits.
    It's weird and I don't fully understand it.

    Get around this my checking out specific commits from a repository rather than
    switch the origin URL.

* Fix PostgreSQL tests
    The error message is slightly different
---
 .../targets/dnf/tasks/modularity.yml          |  2 +-
 test/integration/targets/git/tasks/setup.yml  |  4 ++
 .../targets/git/tasks/submodules.yml          | 72 ++++++++++---------
 test/integration/targets/git/vars/main.yml    |  4 +-
 .../tasks/pg_authid_not_readable.yml          |  2 +-
 5 files changed, 47 insertions(+), 37 deletions(-)

diff --git a/test/integration/targets/dnf/tasks/modularity.yml b/test/integration/targets/dnf/tasks/modularity.yml
index 944e9bc8e91..2ba62e991ce 100644
--- a/test/integration/targets/dnf/tasks/modularity.yml
+++ b/test/integration/targets/dnf/tasks/modularity.yml
@@ -6,7 +6,7 @@
 
 - name: set package for Fedora
   set_fact:
-    astream_name: '@ninja:master/default'
+    astream_name: '@ripgrep:master/default'
   when: ansible_distribution == 'Fedora'
 
 - name: install "{{ astream_name }}" module
diff --git a/test/integration/targets/git/tasks/setup.yml b/test/integration/targets/git/tasks/setup.yml
index f5f416b4d8e..0e56e8b0175 100644
--- a/test/integration/targets/git/tasks/setup.yml
+++ b/test/integration/targets/git/tasks/setup.yml
@@ -37,3 +37,7 @@
   file:
     path: "{{ repo_dir }}"
     state: directory
+
+- name: SETUP | show git version
+  debug:
+    msg: "Running test with git {{ git_version.stdout }}"
diff --git a/test/integration/targets/git/tasks/submodules.yml b/test/integration/targets/git/tasks/submodules.yml
index e2e91da5de9..647d1e23b4e 100644
--- a/test/integration/targets/git/tasks/submodules.yml
+++ b/test/integration/targets/git/tasks/submodules.yml
@@ -22,13 +22,16 @@
 - name: SUBMODULES | Test that clone without recursive does not retrieve submodules
   git:
     repo: "{{ repo_submodules }}"
+    version: 45c6c07ef10fd9e453d90207e63da1ce5bd3ae1e
     dest: "{{ checkout_dir }}"
     recursive: no
 
-- command: 'ls -1a {{ checkout_dir }}/submodule1'
+- name: SUBMODULES | List submodule1
+  command: 'ls -1a {{ checkout_dir }}/submodule1'
   register: submodule1
 
-- assert:
+- name: SUBMODULES | Ensure submodu1 is at the appropriate commit
+  assert:
     that: '{{ submodule1.stdout_lines | length }} == 2'
 
 - name: SUBMODULES | clear checkout_dir
@@ -41,76 +44,81 @@
   git:
     repo: "{{ repo_submodules }}"
     dest: "{{ checkout_dir }}"
+    version: 45c6c07ef10fd9e453d90207e63da1ce5bd3ae1e
     recursive: yes
 
-- command: 'ls -1a {{ checkout_dir }}/submodule1'
+- name: SUBMODULES | List submodule1
+  command: 'ls -1a {{ checkout_dir }}/submodule1'
   register: submodule1
 
-- assert:
+- name: SUBMODULES | Ensure submodule1 is at the appropriate commit
+  assert:
     that: '{{ submodule1.stdout_lines | length }} == 4'
 
 - name: SUBMODULES | Copy the checkout so we can run several different tests on it
   command: 'cp -pr {{ checkout_dir }} {{ checkout_dir }}.bak'
 
 
-
 - name: SUBMODULES | Test that update without recursive does not change submodules
-  command: 'git config --replace-all remote.origin.url {{ repo_submodules_newer }}'
-  args:
-    chdir: '{{ checkout_dir }}'
-
-- git:
-    repo: "{{ repo_submodules_newer }}"
+  git:
+    repo: "{{ repo_submodules }}"
+    version: d2974e4bbccdb59368f1d5eff2205f0fa863297e
     dest: "{{ checkout_dir }}"
     recursive: no
     update: yes
     track_submodules: yes
 
-- command: 'ls -1a {{ checkout_dir }}/submodule1'
+- name: SUBMODULES | List submodule1
+  command: 'ls -1a {{ checkout_dir }}/submodule1'
   register: submodule1
 
-- stat:
+- name: SUBMODULES | Stat submodule2
+  stat:
     path: "{{ checkout_dir }}/submodule2"
   register: submodule2
 
-- command: ls -1a {{ checkout_dir }}/submodule2
+- name: SUBMODULES | List submodule2
+  command: ls -1a {{ checkout_dir }}/submodule2
   register: submodule2
 
-- assert:
-    that: '{{ submodule1.stdout_lines|length }} == 4'
-
-- assert:
-    that: '{{ submodule2.stdout_lines|length }} == 2'
+- name: SUBMODULES | Ensure both submodules are at the appropriate commit
+  assert:
+    that:
+      - '{{ submodule1.stdout_lines|length }} == 4'
+      - '{{ submodule2.stdout_lines|length }} == 2'
 
 
-- name: SUBMODULES | Restore checkout to prior state
+- name: SUBMODULES | Remove checkout dir
   file:
     state: absent
     path: "{{ checkout_dir }}"
-- command: 'cp -pr {{ checkout_dir }}.bak {{ checkout_dir }}'
+
+- name: SUBMODULES | Restore checkout to prior state
+  command: 'cp -pr {{ checkout_dir }}.bak {{ checkout_dir }}'
+
 
 - name: SUBMODULES | Test that update with recursive updated existing submodules
-  command: 'git config --replace-all remote.origin.url {{ repo_submodules_newer }}'
-  args:
-    chdir: "{{ checkout_dir }}"
-
-- git:
-    repo: "{{ repo_submodules_newer }}"
+  git:
+    repo: "{{ repo_submodules }}"
+    version: d2974e4bbccdb59368f1d5eff2205f0fa863297e
     dest: "{{ checkout_dir }}"
     update: yes
     recursive: yes
     track_submodules: yes
 
-- command: 'ls -1a {{ checkout_dir }}/submodule1'
+- name: SUBMODULES | List submodule 1
+  command: 'ls -1a {{ checkout_dir }}/submodule1'
   register: submodule1
 
-- assert:
-    that: '{{ submodule1.stdout_lines|length }} == 5'
+- name: SUBMODULES | Ensure submodule1 is at the appropriate commit
+  assert:
+    that: '{{ submodule1.stdout_lines | length }} == 5'
 
 
 - name: SUBMODULES | Test that update with recursive found new submodules
   command: 'ls -1a {{ checkout_dir }}/submodule2'
   register: submodule2
 
-- assert:
-    that: '{{ submodule2.stdout_lines|length }} == 4'
+- name: SUBMODULES | Enusre submodule2 is at the appropriate commit
+  assert:
+    that: '{{ submodule2.stdout_lines | length }} == 4'
diff --git a/test/integration/targets/git/vars/main.yml b/test/integration/targets/git/vars/main.yml
index af6e028085f..ea9dae268c4 100644
--- a/test/integration/targets/git/vars/main.yml
+++ b/test/integration/targets/git/vars/main.yml
@@ -15,10 +15,8 @@ separate_git_dir: '{{ output_dir }}/sep_git_dir'
 repo_format1: 'https://github.com/jimi-c/test_role'
 repo_format2: 'git@github.com:jimi-c/test_role.git'
 repo_format3: 'ssh://git@github.com/jimi-c/test_role.git'
-repo_submodules: 'https://github.com/abadger/test_submodules.git'
-repo_submodules_newer: 'https://github.com/abadger/test_submodules_newer.git'
+repo_submodules: 'https://github.com/abadger/test_submodules_newer.git'
 repo_submodule1: 'https://github.com/abadger/test_submodules_subm1.git'
-repo_submodule1_newer: 'https://github.com/abadger/test_submodules_subm1_newer.git'
 repo_submodule2: 'https://github.com/abadger/test_submodules_subm2.git'
 repo_update_url_1: 'https://github.com/ansible-test-robinro/git-test-old'
 repo_update_url_2: 'https://github.com/ansible-test-robinro/git-test-new'
diff --git a/test/integration/targets/postgresql/tasks/pg_authid_not_readable.yml b/test/integration/targets/postgresql/tasks/pg_authid_not_readable.yml
index eb2921501c5..6dd6b4056bb 100644
--- a/test/integration/targets/postgresql/tasks/pg_authid_not_readable.yml
+++ b/test/integration/targets/postgresql/tasks/pg_authid_not_readable.yml
@@ -27,7 +27,7 @@
 - assert:
     that:
       - 'pg_authid is failed'
-      - '"permission denied for relation pg_authid" in pg_authid.stderr'
+      - pg_authid.stderr is search('permission denied for (relation|table) pg_authid')
 
 - name: "Normal user isn't allowed to access pg_authid relation: password comparison will fail, password will be updated"
   become_user: "{{ pg_user }}"