|
3 | 3 | from time import sleep
|
4 | 4 |
|
5 | 5 | from conan.api.model import RecipeReference
|
6 |
| -from conan.test.utils.tools import TestClient, GenConanfile |
| 6 | +from conan.test.utils.tools import TestClient, GenConanfile, TestServer |
7 | 7 | from conans.util.files import load
|
8 | 8 |
|
9 | 9 |
|
@@ -165,3 +165,71 @@ def test_install_update_repeated_tool_requires():
|
165 | 165 | c.run("create libc")
|
166 | 166 | c.run("install libc --update -pr=profile")
|
167 | 167 | assert 1 == str(c.out).count("tool/0.1: Checking remote")
|
| 168 | + |
| 169 | + |
| 170 | +class TestUpdateOldPolicy: |
| 171 | + def test_multi_remote_update_resolution(self): |
| 172 | + c = TestClient(servers={"r1": TestServer(), "r2": TestServer(), "r3": TestServer()}, |
| 173 | + inputs=["admin", "password"] * 3, light=True) |
| 174 | + c.save({"conanfile.py": GenConanfile("pkg", "0.1")}) |
| 175 | + c.run("export .") |
| 176 | + rev1 = c.exported_recipe_revision() |
| 177 | + c.run("upload * -r=r1 -c") |
| 178 | + # second revision |
| 179 | + c.save({"conanfile.py": GenConanfile("pkg", "0.1").with_class_attribute("auther = 'me'")}) |
| 180 | + c.run("export .") |
| 181 | + rev2 = c.exported_recipe_revision() |
| 182 | + assert rev1 != rev2 |
| 183 | + c.run("upload * -r=r2 -c") # By default uploads latest revisions only |
| 184 | + assert rev1 not in c.out |
| 185 | + assert rev2 in c.out |
| 186 | + # going back to the previous revision |
| 187 | + c.save({"conanfile.py": GenConanfile("pkg", "0.1")}) |
| 188 | + c.run("export .") # Makes it the latest |
| 189 | + rev3 = c.exported_recipe_revision() |
| 190 | + assert rev1 == rev3 |
| 191 | + c.run("upload * -r=r3 -c") # By default uploads latest revisions only |
| 192 | + assert rev3 in c.out |
| 193 | + assert rev2 not in c.out |
| 194 | + |
| 195 | + # now test the --update, it will pick up the latest revision, which is r3 |
| 196 | + c.run("remove * -c") |
| 197 | + c.run("graph info --requires=pkg/0.1 --update") |
| 198 | + assert f"pkg/0.1#{rev3} - Downloaded (r3)" in c.out |
| 199 | + |
| 200 | + # But if we enable order-based first found timestamp, it will pick up r2 |
| 201 | + c.run("remove * -c") |
| 202 | + c.run("graph info --requires=pkg/0.1 --update -cc core:update_policy=legacy") |
| 203 | + assert "The 'core:update_policy' conf is deprecated and will be removed" in c.out |
| 204 | + assert f"pkg/0.1#{rev2} - Downloaded (r2)" in c.out |
| 205 | + |
| 206 | + def test_multi_remote_update_resolution_2_remotes(self): |
| 207 | + c = TestClient(servers={"r1": TestServer(), "r2": TestServer()}, |
| 208 | + inputs=["admin", "password"] * 2, light=True) |
| 209 | + c.save({"conanfile.py": GenConanfile("pkg", "0.1")}) |
| 210 | + c.run("export .") |
| 211 | + rev1 = c.exported_recipe_revision() |
| 212 | + c.run("upload * -r=r1 -c") |
| 213 | + # second revision |
| 214 | + c.save({"conanfile.py": GenConanfile("pkg", "0.1").with_class_attribute("auther = 'me'")}) |
| 215 | + c.run("export .") |
| 216 | + rev2 = c.exported_recipe_revision() |
| 217 | + assert rev1 != rev2 |
| 218 | + c.run("upload * -r=r1 -c") |
| 219 | + c.run("list *#* -r=r1") |
| 220 | + |
| 221 | + # Upload the first, old revision to the other remote |
| 222 | + c.run(f"upload pkg/0.1#{rev1} -r=r2 -c") |
| 223 | + assert rev1 in c.out |
| 224 | + assert rev2 not in c.out |
| 225 | + c.run("list *#* -r=r2") |
| 226 | + |
| 227 | + # now test the --update, it will pick up the latest revision, which is r3 |
| 228 | + c.run("remove * -c") |
| 229 | + c.run("graph info --requires=pkg/0.1 --update") |
| 230 | + assert f"pkg/0.1#{rev1} - Downloaded (r2)" in c.out |
| 231 | + |
| 232 | + # But if we enable order-based first found timestamp, it will pick up r2 |
| 233 | + c.run("remove * -c") |
| 234 | + c.run("graph info --requires=pkg/0.1 --update -cc core:update_policy=legacy") |
| 235 | + assert f"pkg/0.1#{rev2} - Downloaded (r1)" in c.out |
0 commit comments