Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip testMergeWithMatrixBuild if gpgsign enabled #1564

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion src/test/java/hudson/plugins/git/GitSCMSlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import hudson.remoting.VirtualChannel;
import hudson.slaves.DumbSlave;
import hudson.slaves.EnvironmentVariablesNodeProperty;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -39,8 +40,12 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;

import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.storage.file.UserConfigFile;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.SystemReader;
import org.jenkinsci.plugins.gitclient.GitClient;
import org.junit.BeforeClass;
Expand All @@ -62,6 +67,7 @@ public class GitSCMSlowTest extends AbstractGitTestCase {

private final Random random = new Random();
private boolean useChangelogToBranch = random.nextBoolean();
private static boolean gpgsignEnabled = false; // set by gpgsignCheck()

@BeforeClass
public static void setGitDefaults() throws Exception {
Expand All @@ -70,6 +76,20 @@ public static void setGitDefaults() throws Exception {
gitCmd.setDefaults();
}

@BeforeClass
public static void gpgsignCheck() throws Exception {
File userGitConfig = new File(System.getProperty("user.home"), ".gitconfig");
File xdgGitConfig = userGitConfig;
String xdgDirName = System.getenv("XDG_CONFIG_HOME");
if (xdgDirName != null) {
xdgGitConfig = new File(xdgDirName, ".gitconfig");
}
UserConfigFile userConfig = new UserConfigFile(null, userGitConfig, xdgGitConfig, FS.DETECTED);
userConfig.load();
gpgsignEnabled = userConfig.getBoolean(ConfigConstants.CONFIG_COMMIT_SECTION, ConfigConstants.CONFIG_KEY_GPGSIGN, false) ||
userConfig.getBoolean(ConfigConstants.CONFIG_TAG_SECTION, ConfigConstants.CONFIG_KEY_GPGSIGN, false);
}

@ClassRule
public static Stopwatch stopwatch = new Stopwatch();
@Rule
Expand Down Expand Up @@ -340,6 +360,18 @@ public GitClient decorate(GitSCM scm, GitClient git) throws IOException, Interru
@Test
public void testMergeWithMatrixBuild() throws Exception {
assumeTrue("Test class max time " + MAX_SECONDS_FOR_THESE_TESTS + " exceeded", isTimeAvailable());
/* The testMergeWithMatrixBuild test fails randomly on several
* machines when commit.gpgsign and tag.gpgsign are not
* enabled if the TestPreBuildMerge implementation is used. It
* passes consistently when PreBuildMerge is used. Rather than
Copy link
Member

@olamy olamy Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting. what sort of error did you get? Did it happen on https://ci.jenkins.io/?
but this doesn't mean I really want to spend time on that :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran more tests to check failure rates on various machines in my home lab. Failure rate seemed to decrease as machine performance decreased.

  • RHEL 8 with Ryzen 5 - 16/16 failed
  • Ubuntu 22.04 with Xeon(R) X5660 - 14/16 failed
  • Ubuntu 22.04 with Xeon(R) X3450 - 13/16 failed
  • Ubuntu 22.04 with i5-6400 - 12/16 failed
  • Debian testing with i5-2400 - 7/16 failed

* spend the time trying to diagnose the intermittent
* failures, this configuration allows the test to be skipped
* if either of those configuration settings are enabled.
*
* Other tests in this class are able to use TestPreBuildMerge
* without issue.
*/
assumeFalse("gpgsign enabled", gpgsignEnabled);
//Create a matrix project and a couple of axes
MatrixProject project = r.jenkins.createProject(MatrixProject.class, "xyz");
project.setAxes(new AxisList(new Axis("VAR", "a", "b")));
Expand All @@ -349,7 +381,7 @@ public void testMergeWithMatrixBuild() throws Exception {
Collections.singletonList(new BranchSpec("*")),
null, null,
Collections.emptyList());
scm.getExtensions().add(new TestPreBuildMerge(new UserMergeOptions("origin", "integration", null, null)));
scm.getExtensions().add(new PreBuildMerge(new UserMergeOptions("origin", "integration", null, null)));
addChangelogToBranchExtension(scm);
project.setScm(scm);

Expand Down
Loading