From b822b9b69f7c11550c985a4c3fcabb098e2f3824 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 23 Mar 2024 13:32:38 +0100 Subject: [PATCH] Delete `BigDiffTest` This test was originally added to make sure the `git` process does not hang in case it writes a lot of output to the output streams. To check this behavior, the test created 100.000 (!) files each a few KBs large and then invoked the plugin, hoping that `git` would produce enough output. However, this puts a lot of pressure on the file system and disk due to the large number of files. For GitHub CI whose runners are probably using SSDs, this test alone took more than 50% of the time of the complete Maven build. And when running the test with an HDD the test could easily take minutes. https://github.com/git-commit-id/git-commit-id-plugin-core/pull/101 has added a dedicated and more reliable test which makes sure that the process output is properly consumed, so there is probably no need for this `BigDiffTest` anymore, especially due to the downsides mentioned above. --- .../pl/project13/maven/git/BigDiffTest.java | 91 ------------------- 1 file changed, 91 deletions(-) delete mode 100644 src/test/java/pl/project13/maven/git/BigDiffTest.java diff --git a/src/test/java/pl/project13/maven/git/BigDiffTest.java b/src/test/java/pl/project13/maven/git/BigDiffTest.java deleted file mode 100644 index 066ffaad..00000000 --- a/src/test/java/pl/project13/maven/git/BigDiffTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This file is part of git-commit-id-maven-plugin - * Originally invented by Konrad 'ktoso' Malawski - * - * git-commit-id-maven-plugin is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * git-commit-id-maven-plugin is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with git-commit-id-maven-plugin. If not, see . - */ - -package pl.project13.maven.git; - -import java.io.FileOutputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import org.apache.maven.project.MavenProject; -import org.junit.jupiter.api.Test; -import pl.project13.core.git.GitDescribeConfig; - -/** - * Run this to simulate hanging native-git-process for repo-state with lots of changes. - * - *

The test case will still finish successfully because all git-related errors are cught in. - * - * @author eternach - */ -public class BigDiffTest extends GitIntegrationTest { - - @Test - // @Ignore("Run this to simulate hanging native-git-process for repo-state with lots of changes") - public void bigDiff() throws Exception { - // given - mavenSandbox - .withParentProject("my-pom-project", "pom") - .withChildProject("my-jar-module", "jar") - .withGitRepoInChild(AvailableGitTestRepo.MAVEN_GIT_COMMIT_ID_PLUGIN) - .create(); - final MavenProject targetProject = mavenSandbox.getChildProject(); - - setProjectToExecuteMojoIn(targetProject); - - final GitDescribeConfig gitDescribeConfig = createGitDescribeConfig(true, 7); - gitDescribeConfig.setAlways(true); - // set timeout to one hour - mojo.nativeGitTimeoutInMs = 60 * 60 * 1000; - mojo.useNativeGit = true; - mojo.gitDescribe = gitDescribeConfig; - - for (int i = 0; i < 100000; i++) { - final Path path = - Paths.get( - mavenSandbox.getChildProject().getBasedir().toString(), - "very-long-file-name-with-id-" + Integer.toString(i) + ".txt"); - final byte[] bytes = "for performance test\n".getBytes(); - Files.createFile(path); - try (FileOutputStream fos = new FileOutputStream(path.toFile())) { - for (int ii = 0; ii < 100; ii++) { - fos.write(bytes); - } - } - } - // when - final long startTime = System.currentTimeMillis(); - - mojo.execute(); - - final long estimatedTime = System.currentTimeMillis() - startTime; - System.out.println("[***] time: " + (double) estimatedTime + " ms"); - - // then - assertGitPropertiesPresentInProject(targetProject.getProperties()); - } - - private GitDescribeConfig createGitDescribeConfig( - final boolean forceLongFormat, final int abbrev) { - final GitDescribeConfig gitDescribeConfig = new GitDescribeConfig(); - gitDescribeConfig.setTags(true); - gitDescribeConfig.setForceLongFormat(forceLongFormat); - gitDescribeConfig.setAbbrev(abbrev); - return gitDescribeConfig; - } -}