From 35efa65b8c9fa7aa5f95991472e2d0f16720e8db Mon Sep 17 00:00:00 2001
From: Patrick Uiterwijk <patrick@puiterwijk.org>
Date: Feb 04 2019 11:17:18 +0000
Subject: [PATCH 1/3] Make sure repoSpanner tests run in CentOS CI


Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>

---

diff --git a/run_ci_tests.sh b/run_ci_tests.sh
index a699245..a8e1fba 100755
--- a/run_ci_tests.sh
+++ b/run_ci_tests.sh
@@ -1,12 +1,24 @@
 set -x
 
+echo "Installing Fedora Infra Tags repo"
+cat >/etc/yum.repos.d/infra-tags.repo << 'EOF'
+[infrastructure-tags]
+name=Fedora Infrastructure tag $releasever - $basearch
+baseurl=https://kojipkgs.fedoraproject.org/repos-dist/epel$releasever-infra/latest/$basearch/
+enabled=1
+gpgcheck=1
+gpgkey=https://infrastructure.fedoraproject.org/repo/infra/RPM-GPG-KEY-INFRA-TAGS
+EOF
+
+
 yum install -y python-virtualenv python34 python34-devel \
                gcc python-cryptography python34-cryptography \
                libgit2 libgit2-devel python-pygit2 \
                redis swig openssl-devel m2crypto \
                python2-fedmsg python34-fedmsg-core fedmsg \
                python-tox python-pip python34-pip \
-               parallel zeromq-devel python-Cython
+               parallel zeromq-devel python-Cython \
+               repoSpanner repoSpanner-bridge
 
 sysctl -w fs.file-max=2048
 

From c589012c36494dcf5df54fda7e3d45962610e5a6 Mon Sep 17 00:00:00 2001
From: Patrick Uiterwijk <patrick@puiterwijk.org>
Date: Feb 04 2019 11:17:18 +0000
Subject: [PATCH 2/3] Add self._origrepo for repoSpanner case


Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>

---

diff --git a/pagure/lib/git.py b/pagure/lib/git.py
index 01f252e..55f11fb 100644
--- a/pagure/lib/git.py
+++ b/pagure/lib/git.py
@@ -963,6 +963,7 @@ class TemporaryClone(object):
                     env=environ,
                 )
             self.repo = pygit2.Repository(self.repopath)
+            self._origrepo = self.repo
 
         # Make sure that all remote refs are mapped to local ones.
         headname = None

From 3bda5f3c7f7842a1909200771ddcad4731080dd0 Mon Sep 17 00:00:00 2001
From: Patrick Uiterwijk <patrick@puiterwijk.org>
Date: Feb 04 2019 11:17:18 +0000
Subject: [PATCH 3/3] Give repoSpanner up to 5 seconds to become available


Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>

---

diff --git a/tests/test_pagure_repospanner.py b/tests/test_pagure_repospanner.py
index d8f12aa..4afd8b1 100644
--- a/tests/test_pagure_repospanner.py
+++ b/tests/test_pagure_repospanner.py
@@ -204,25 +204,37 @@ class PagureRepoSpannerTests(tests.Modeltests):
                 stdout=self.repospanner_runlog,
                 stderr=subprocess.STDOUT,
             )
-
-            # Wait for the instance to become available
-            resp = requests.get(
-                'https://nodea.regiona.repospanner.local:%d/'
-                % configvals['gitport'],
-                verify=os.path.join(self.path, 'repospanner', 'pki', 'ca.crt'),
-                cert=(
-                    os.path.join(self.path, 'repospanner', 'pki', 'pagure.crt'),
-                    os.path.join(self.path, 'repospanner', 'pki', 'pagure.key'),
-                )
-            )
-            resp.raise_for_status()
-
-            print('repoSpanner identification: %s' % resp.text)
         except:
             # Make sure to clean up repoSpanner, since we did start it
             self.tearDown()
             raise
 
+        attempts = 0
+        while True:
+            try:
+                # Wait for the instance to become available
+                resp = requests.get(
+                    'https://nodea.regiona.repospanner.local:%d/'
+                    % configvals['gitport'],
+                    verify=os.path.join(self.path, 'repospanner', 'pki', 'ca.crt'),
+                    cert=(
+                        os.path.join(self.path, 'repospanner', 'pki', 'pagure.crt'),
+                        os.path.join(self.path, 'repospanner', 'pki', 'pagure.key'),
+                    )
+                )
+                resp.raise_for_status()
+
+                print('repoSpanner identification: %s' % resp.text)
+                break
+            except:
+                if attempts < 5:
+                    attempts += 1
+                    time.sleep(1)
+                    continue
+                # Make sure to clean up repoSpanner, since we did start it
+                self.tearDown()
+                raise
+
     def tearDown(self):
         """ Tear down the repoSpanner instance. """
         if self.repospanner_proc:

