summaryrefslogtreecommitdiffstats
path: root/tests/test_git_superproject.py
diff options
context:
space:
mode:
authorRaman Tenneti <rtenneti@google.com>2021-02-22 16:54:56 -0800
committerRaman Tenneti <rtenneti@google.com>2021-02-25 20:45:26 +0000
commitceba2ddc1333dbd53b559bde2b79d09d2082f3dc (patch)
tree91c9b2513f0b2984237b1eba47dd59adb780bedf /tests/test_git_superproject.py
parent45ad1541c5cd20e2947edae76264b40413b3fd8d (diff)
downloadgit-repo-ceba2ddc1333dbd53b559bde2b79d09d2082f3dc.tar.gz
sync: superproject - support for switching hosts and switching branches.
+ superproject will be fetched into a directory with the name “<remote name>-superproject.git” instead of the current “superproject.git” folder. + Deleted _Clone method and added _Init method. + _Init method will do “git init --bare <remote>-superproject.git”. It will create the folder and set up a bare repository in <remote>-superproject.git folder. + _Fetch method, will pass <remote url>, <branch> arguments. Moved the --filter argument from “git clone” to “git fetch”. _Fetch method will execute the following command to fetch superproject. Added --no-tags argument. master: git fetch <remote url> --force --no-tags --filter blob:none branch: git fetch <remote url> --force --no-tags --filter blob:none \ <branch>:<branch> + Performance improvements for aosp-master ++ repo init performance improved from 35 seconds to 17 seconds. ++ repo init --use-superproject is around 5 to 7 secsonds slower. ++ repo sync --use-superproject is around 3 to 4 minutes faster. Tested the code with the following commands. $ ./run_tests -v Tested the sync code by using repo_dev alias and pointing to this CL. $ time repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M --repo-rev=main --use-superproject ... real 0m20.648s user 0m8.046s sys 0m3.271s + Without superproject $ time repo init -u sso://android.git.corp.google.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M --repo-rev=main real 0m13.078s user 0m9.783s sys 0m2.528s $ time repo_dev sync -c -j32 --use-superproject ... real 15m7.072s user 110m7.216s sys 20m17.559s + Without superproject $ time repo sync -c -j32 ... real 19m25.644s user 91m56.331s sys 20m59.170s Bug: [google internal] b/180492484 Bug: [google internal] b/179470886 Bug: [google internal] b/180124069 Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Change-Id: Ib04bd7f1e25ceb75532643e58ad0129300ba3299 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297702 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
Diffstat (limited to 'tests/test_git_superproject.py')
-rw-r--r--tests/test_git_superproject.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py
index d2ee9f4f..07b9a7db 100644
--- a/tests/test_git_superproject.py
+++ b/tests/test_git_superproject.py
@@ -97,17 +97,17 @@ class SuperprojectTestCase(unittest.TestCase):
97 with mock.patch.object(self._superproject, '_GetBranch', return_value='junk'): 97 with mock.patch.object(self._superproject, '_GetBranch', return_value='junk'):
98 self.assertFalse(superproject.Sync()) 98 self.assertFalse(superproject.Sync())
99 99
100 def test_superproject_get_superproject_mock_clone(self): 100 def test_superproject_get_superproject_mock_init(self):
101 """Test with _Clone failing.""" 101 """Test with _Init failing."""
102 with mock.patch.object(self._superproject, '_Clone', return_value=False): 102 with mock.patch.object(self._superproject, '_Init', return_value=False):
103 self.assertFalse(self._superproject.Sync()) 103 self.assertFalse(self._superproject.Sync())
104 104
105 def test_superproject_get_superproject_mock_fetch(self): 105 def test_superproject_get_superproject_mock_fetch(self):
106 """Test with _Fetch failing and _clone being called.""" 106 """Test with _Fetch failing."""
107 with mock.patch.object(self._superproject, '_Clone', return_value=True): 107 with mock.patch.object(self._superproject, '_Init', return_value=True):
108 os.mkdir(self._superproject._superproject_path) 108 os.mkdir(self._superproject._superproject_path)
109 with mock.patch.object(self._superproject, '_Fetch', return_value=False): 109 with mock.patch.object(self._superproject, '_Fetch', return_value=False):
110 self.assertTrue(self._superproject.Sync()) 110 self.assertFalse(self._superproject.Sync())
111 111
112 def test_superproject_get_all_project_commit_ids_mock_ls_tree(self): 112 def test_superproject_get_all_project_commit_ids_mock_ls_tree(self):
113 """Test with LsTree being a mock.""" 113 """Test with LsTree being a mock."""
@@ -116,14 +116,15 @@ class SuperprojectTestCase(unittest.TestCase):
116 '160000 commit e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06\tbootable/recovery\x00' 116 '160000 commit e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06\tbootable/recovery\x00'
117 '120000 blob acc2cbdf438f9d2141f0ae424cec1d8fc4b5d97f\tbootstrap.bash\x00' 117 '120000 blob acc2cbdf438f9d2141f0ae424cec1d8fc4b5d97f\tbootstrap.bash\x00'
118 '160000 commit ade9b7a0d874e25fff4bf2552488825c6f111928\tbuild/bazel\x00') 118 '160000 commit ade9b7a0d874e25fff4bf2552488825c6f111928\tbuild/bazel\x00')
119 with mock.patch.object(self._superproject, '_Clone', return_value=True): 119 with mock.patch.object(self._superproject, '_Init', return_value=True):
120 with mock.patch.object(self._superproject, '_LsTree', return_value=data): 120 with mock.patch.object(self._superproject, '_Fetch', return_value=True):
121 commit_ids = self._superproject._GetAllProjectsCommitIds() 121 with mock.patch.object(self._superproject, '_LsTree', return_value=data):
122 self.assertEqual(commit_ids, { 122 commit_ids = self._superproject._GetAllProjectsCommitIds()
123 'art': '2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea', 123 self.assertEqual(commit_ids, {
124 'bootable/recovery': 'e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06', 124 'art': '2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea',
125 'build/bazel': 'ade9b7a0d874e25fff4bf2552488825c6f111928' 125 'bootable/recovery': 'e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06',
126 }) 126 'build/bazel': 'ade9b7a0d874e25fff4bf2552488825c6f111928'
127 })
127 128
128 def test_superproject_write_manifest_file(self): 129 def test_superproject_write_manifest_file(self):
129 """Test with writing manifest to a file after setting revisionId.""" 130 """Test with writing manifest to a file after setting revisionId."""
@@ -151,7 +152,7 @@ class SuperprojectTestCase(unittest.TestCase):
151 projects = self._superproject._manifest.projects 152 projects = self._superproject._manifest.projects
152 data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00' 153 data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00'
153 '160000 commit e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06\tbootable/recovery\x00') 154 '160000 commit e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06\tbootable/recovery\x00')
154 with mock.patch.object(self._superproject, '_Clone', return_value=True): 155 with mock.patch.object(self._superproject, '_Init', return_value=True):
155 with mock.patch.object(self._superproject, '_Fetch', return_value=True): 156 with mock.patch.object(self._superproject, '_Fetch', return_value=True):
156 with mock.patch.object(self._superproject, 157 with mock.patch.object(self._superproject,
157 '_LsTree', 158 '_LsTree',