Skip to content
Permalink
Browse files

Add additional SCM trigger tests to show JENKINS-28506

Reduce special cases in trigger tests to 1 isChangeExpected() method.
Several of the tests show known existing remote polling issues.  Those
known issues cannot be resolved without significant risk to backward
compatibility, so they are intentionally not being fixed.
  • Loading branch information
MarkEWaite authored and ndeloof committed May 22, 2015
1 parent 97fdec5 commit 5b5a00458f98055fa294713e2cf0a8fd67d8c88c
@@ -18,4 +18,9 @@ protected boolean isDisableRemotePoll()
return true;
}

@Override
protected boolean isChangeExpected()
{
return false;
}
}
@@ -3,16 +3,14 @@
import hudson.plugins.git.extensions.GitClientType;
import hudson.plugins.git.extensions.impl.EnforceGitClient;

public class CliGitSCMTriggerRemotePollTest extends SCMTriggerTest
{
/**
* Remote polling and local polling behave differently due to bugs in productive
* code which probably cannot be fixed without serious compatibility problems.
* The isChangeExpected() method adjusts the tests to the difference between
* local and remote polling.
*/
public class CliGitSCMTriggerRemotePollTest extends SCMTriggerTest {

/**
* Currently some tests still fail due to bugs in productive code.
* TODO: Fix bugs and enable tests.
*/
private boolean SKIP_FAILING_TESTS = true;


@Override
protected EnforceGitClient getGitClient()
{
@@ -24,52 +22,10 @@ protected boolean isDisableRemotePoll()
{
return false;
}

@Override
public void testNamespaces_with_master() throws Exception {
if(SKIP_FAILING_TESTS) return; //TODO Fix productive code
super.testNamespaces_with_master();
}

@Override
public void testNamespaces_with_namespace1Master() throws Exception {
//This one works by accident! ls-remote lists this as first entry
super.testNamespaces_with_namespace1Master();
}

@Override
public void testNamespaces_with_namespace2Master() throws Exception {
if(SKIP_FAILING_TESTS) return; //TODO Fix productive code
super.testNamespaces_with_namespace2Master();
}

@Override
public void testCommitAsBranchSpec() throws Exception {
if(SKIP_FAILING_TESTS) return; //TODO Fix productive code
super.testCommitAsBranchSpec();
}

@Override
public void testTags_with_TagA() throws Exception {
if(SKIP_FAILING_TESTS) return; //TODO Fix productive code
super.testTags_with_TagA();
}

@Override
public void testTags_with_TagBAnnotated() throws Exception {
if(SKIP_FAILING_TESTS) return; //TODO Fix productive code
super.testTags_with_TagBAnnotated();
}

/* Skip this test because git client 1.10.2 and later include a fix for
* JENKINS-23299. The fix resolves refs/tags/tag_name as the commit to
* which tag_name points. Prior to that change, the ref pointed to the
* SHA-1 of the tag, instead of the SHA-1 of the commit to which the tag
* points. Because of that bug fix, the git plugin correctly detects
* refs/tags/TagA as needing to build.
*/
@Override
public void testTags_with_refsTagsTagA() throws Exception {
return;
protected boolean isChangeExpected()
{
return true;
}
}
@@ -18,4 +18,9 @@ protected boolean isDisableRemotePoll()
return true;
}

@Override
protected boolean isChangeExpected()
{
return false;
}
}
@@ -3,16 +3,14 @@
import hudson.plugins.git.extensions.GitClientType;
import hudson.plugins.git.extensions.impl.EnforceGitClient;

/**
* Remote polling and local polling behave differently due to bugs in productive
* code which probably cannot be fixed without serious compatibility problems.
* The isChangeExpected() method adjusts the tests to the difference between
* local and remote polling.
*/
public class JGitSCMTriggerRemotePollTest extends SCMTriggerTest
{

/**
* Currently some tests still fail due to bugs in productive code.
* TODO: Fix bugs and enable tests.
*/
private boolean SKIP_FAILING_TESTS = true;


@Override
protected EnforceGitClient getGitClient()
{
@@ -26,21 +24,8 @@ protected boolean isDisableRemotePoll()
}

@Override
public void testNamespaces_with_master() throws Exception {
if(SKIP_FAILING_TESTS) return; //TODO Fix productive code
super.testNamespaces_with_master();
}

@Override
public void testNamespaces_with_namespace2Master() throws Exception {
if(SKIP_FAILING_TESTS) return; //TODO Fix productive code
super.testNamespaces_with_namespace2Master();
}

@Override
public void testCommitAsBranchSpec() throws Exception {
if(SKIP_FAILING_TESTS) return; //TODO Fix productive code
super.testCommitAsBranchSpec();
protected boolean isChangeExpected()
{
return true;
}

}
}
@@ -22,8 +22,6 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
@@ -39,6 +37,7 @@
private ZipFile namespaceRepoZip;
private Properties namespaceRepoCommits;
private ExecutorService singleThreadExecutor;
protected boolean expectChanges = false;

@Override
protected void tearDown() throws Exception
@@ -59,6 +58,7 @@ protected void tearDown() throws Exception
@Override
public void setUp() throws Exception {
super.setUp();
expectChanges = false;
namespaceRepoZip = new ZipFile("src/test/resources/namespaceBranchRepo.zip");
namespaceRepoCommits = parseLsRemote(new File("src/test/resources/namespaceBranchRepo.ls-remote"));
tempAllocator = new TemporaryDirectoryAllocator();
@@ -68,7 +68,9 @@ public void setUp() throws Exception {
protected abstract EnforceGitClient getGitClient();

protected abstract boolean isDisableRemotePoll();


protected abstract boolean isChangeExpected();

public void testNamespaces_with_refsHeadsMaster() throws Exception {
check(namespaceRepoZip, namespaceRepoCommits,
"refs/heads/master",
@@ -124,7 +126,35 @@ public void testNamespaces_with_refsHeadsNamespace2Master() throws Exception {
namespaceRepoCommits.getProperty("refs/heads/a_tests/b_namespace2/master"),
"origin/a_tests/b_namespace2/master");
}


public void testNamespaces_with_namespace3_feature3_sha1() throws Exception {
check(namespaceRepoZip, namespaceRepoCommits,
namespaceRepoCommits.getProperty("refs/heads/a_tests/b_namespace3/feature3"),
namespaceRepoCommits.getProperty("refs/heads/a_tests/b_namespace3/feature3"),
"detached");
}

public void testNamespaces_with_namespace3_feature3_branchName() throws Exception {
check(namespaceRepoZip, namespaceRepoCommits,
"a_tests/b_namespace3/feature3",
namespaceRepoCommits.getProperty("refs/heads/a_tests/b_namespace3/feature3"),
"origin/a_tests/b_namespace3/feature3");
}

public void testNamespaces_with_refsHeadsNamespace3_feature3_sha1() throws Exception {
check(namespaceRepoZip, namespaceRepoCommits,
namespaceRepoCommits.getProperty("refs/heads/a_tests/b_namespace3/feature3"),
namespaceRepoCommits.getProperty("refs/heads/a_tests/b_namespace3/feature3"),
"detached");
}

public void testNamespaces_with_refsHeadsNamespace3_feature3_branchName() throws Exception {
check(namespaceRepoZip, namespaceRepoCommits,
"refs/heads/a_tests/b_namespace3/feature3",
namespaceRepoCommits.getProperty("refs/heads/a_tests/b_namespace3/feature3"),
"origin/a_tests/b_namespace3/feature3");
}

public void testTags_with_TagA() throws Exception {
check(namespaceRepoZip, namespaceRepoCommits,
"TagA",
@@ -153,6 +183,20 @@ public void testTags_with_refsTagsTagBAnnotated() throws Exception {
"refs/tags/TagBAnnotated");
}

public void testCommitAsBranchSpec_feature4_sha1() throws Exception {
check(namespaceRepoZip, namespaceRepoCommits,
namespaceRepoCommits.getProperty("refs/heads/b_namespace3/feature4"),
namespaceRepoCommits.getProperty("refs/heads/b_namespace3/feature4"),
"detached");
}

public void testCommitAsBranchSpec_feature4_branchName() throws Exception {
check(namespaceRepoZip, namespaceRepoCommits,
"refs/heads/b_namespace3/feature4",
namespaceRepoCommits.getProperty("refs/heads/b_namespace3/feature4"),
"origin/b_namespace3/feature4");
}

public void testCommitAsBranchSpec() throws Exception {
check(namespaceRepoZip, namespaceRepoCommits,
namespaceRepoCommits.getProperty("refs/heads/b_namespace3/master"),
@@ -179,7 +223,7 @@ public void check(ZipFile repoZip, Properties commits, String branchSpec,
assertNotNull("Job has not been triggered", build1);

PollingResult poll = project.poll(listener);
assertFalse("Polling found new changes although nothing new", poll.hasChanges());
assertEquals("Expected and actual polling results disagree", isChangeExpected(), poll.hasChanges());

//Speedup test - avoid waiting 1 minute
triggerSCMTrigger(project.getTrigger(SCMTrigger.class)).get(20, SECONDS);

0 comments on commit 5b5a004

Please sign in to comment.
You can’t perform that action at this time.