From c398fb2b6b5be13251a74ba36b5fd5a9ef360a1a Mon Sep 17 00:00:00 2001 From: Minh Thai Date: Fri, 31 Aug 2018 15:54:39 -0700 Subject: Replace useminimalnegotation flag with maxhaves flag Client will stop sending haves when the number of haves sent reaches maxhaves. Change-Id: I1e5b1525be4c67f20a81ca24a2770c20eb5c1271 Signed-off-by: Minh Thai --- .../eclipse/jgit/transport/TestProtocolTest.java | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'org.eclipse.jgit.test/tst/org') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java index 86c92bb528..953c9fc30a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java @@ -77,6 +77,7 @@ public class TestProtocolTest { "+refs/heads/master:refs/heads/master"); private static final int HAVES_PER_ROUND = 32; + private static final int MAX_HAVES = 256; private static class User { private final String name; @@ -187,7 +188,7 @@ public class TestProtocolTest { } @Test - public void testMinimalNegotiation() throws Exception { + public void testMaxHaves() throws Exception { TestProtocol proto = registerDefault(); URIish uri = proto.register(new User("user"), remote.getRepository()); @@ -200,28 +201,13 @@ public class TestProtocolTest { RevCommit master = remote.branch("master").commit() .add("readme.txt", "unique commit").create(); - TestProtocol.setFetchConfig(new FetchConfig(true, true)); + TestProtocol.setFetchConfig(new FetchConfig(true, MAX_HAVES)); try (Git git = new Git(local.getRepository())) { assertNull(local.getRepository().exactRef("refs/heads/master")); git.fetch().setRemote(uri.toString()).setRefSpecs(MASTER).call(); assertEquals(master, local.getRepository() .exactRef("refs/heads/master").getObjectId()); - assertTrue(havesCount <= 2 * HAVES_PER_ROUND); - - // Update the remote master and add local branches for 5 more rounds - // of negotiation, where the local branch commits have newer - // timestamps. Negotiation should send 5 rounds for those newer - // branches before getting to the round that sends its stale version - // of master. - master = remote.branch("master").commit().parent(master).create(); - local.tick(2 * HAVES_PER_ROUND); - for (int i = 0; i < 5 * HAVES_PER_ROUND; i++) { - local.branch("local-" + i).commit().create(); - } - git.fetch().setRemote(uri.toString()).setRefSpecs(MASTER).call(); - assertEquals(master, local.getRepository() - .exactRef("refs/heads/master").getObjectId()); - assertEquals(6 * HAVES_PER_ROUND, havesCount); + assertTrue(havesCount <= MAX_HAVES); } } -- cgit v1.2.3