Search in sources :

Example 61 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-git by JetBrains.

the class RevisionsCacheTest method should_not_save_revision_if_there_was_reset.

@TestFor(issues = { "TW-23460" })
@Test(dataProvider = "reset")
public void should_not_save_revision_if_there_was_reset(@NotNull BiConsumer<RevisionsCache, File> reset) throws Exception {
    File repo = repository("1");
    Semaphore s1 = new Semaphore(1);
    s1.acquire();
    Semaphore s2 = new Semaphore(1);
    s2.acquire();
    Thread mapFullPath = new Thread(() -> {
        try {
            RepositoryRevisionCache repoCache = myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE);
            long resetCounter = repoCache.getResetCounter();
            if (repoCache.hasRevision("v1") == null) {
                s1.release();
                // long commit lookup (we didn't find it)
                s2.acquire();
                repoCache.saveRevision("v1", false, resetCounter);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    });
    mapFullPath.start();
    // collect changes which resets cache:
    s1.acquire();
    reset.accept(myCache, repo);
    s2.release();
    mapFullPath.join();
    then(myCache.getRepositoryCache(repo, RevisionCacheType.COMMIT_CACHE).hasRevision("v1")).isNull();
}
Also used : Semaphore(java.util.concurrent.Semaphore) RepositoryRevisionCache(jetbrains.buildServer.buildTriggers.vcs.git.RepositoryRevisionCache) File(java.io.File) IOException(java.io.IOException) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 62 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.

the class PowerShellIntegrationTests method should_run_simple_command_file_ps1.

@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = "TW-29803")
public void should_run_simple_command_file_ps1(@NotNull final PowerShellBitness bits) throws Throwable {
    final File dir = createTempDir();
    final File code = new File(dir, "code.ps1");
    FileUtil.writeFileAndReportErrors(code, "echo works");
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.FILE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_FILE, code.getPath());
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isSuccessful());
    Assert.assertTrue(getBuildLog(build).contains("works"));
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 63 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.

the class PowerShellIntegrationTests method should_run_simple_command_file_stdin.

@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = "TW-29803")
public void should_run_simple_command_file_stdin(@NotNull final PowerShellBitness bits) throws Throwable {
    final File code = createTempFile("echo works");
    setRunnerParameter(PowerShellConstants.RUNNER_MIN_VERSION, "2.0");
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.STDIN.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.FILE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_FILE, code.getPath());
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isSuccessful());
    Assert.assertTrue(getBuildLog(build).contains("works"));
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 64 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.

the class PowerShellIntegrationTests method testMultilineArguments.

@SuppressWarnings("TestMethodWithIncorrectSignature")
@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = "TW-65627")
public void testMultilineArguments(@NotNull final PowerShellBitness bits) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "param(\n" + "\t[string] $param1 = \"\"\n" + ")\n" + "\n" + "Write-Output \"praram1: $param1.\"");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_ARGUMENTS, "-param1 \"line1a = line1b\nline2a = line2b\"");
    setBuildConfigurationParameter(PowerShellConstants.PARAM_ARGS_MULTILINE, "true");
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isSuccessful());
    Assert.assertTrue(getBuildLog(build).contains("\"line1a = line1b line2a = line2b\""));
    Assert.assertTrue(getBuildLog(build).contains("praram1: line1a = line1b line2a = line2b."));
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 65 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.

the class PowerShellIntegrationTests method testShouldKeepGeneratedFiles_Global.

@SuppressWarnings("TestMethodWithIncorrectSignature")
@Test(dataProvider = "supportedBitnessProvider")
@TestFor(issues = { "TW-39841", "TW-49772" })
public void testShouldKeepGeneratedFiles_Global(@NotNull final PowerShellBitness bits) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "echo works\r\n");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bits.getValue());
    setBuildConfigurationParameter("teamcity.dont.delete.temp.files", "true");
    final SFinishedBuild build = doTest(null);
    assertEquals(1, getTempFiles().length);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isSuccessful());
    Assert.assertTrue(getBuildLog(build).contains("works"));
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

TestFor (jetbrains.buildServer.util.TestFor)129 Test (org.testng.annotations.Test)81 File (java.io.File)65 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)56 VcsRootImpl (jetbrains.buildServer.vcs.impl.VcsRootImpl)26 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)21 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)17 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)12 VcsException (jetbrains.buildServer.vcs.VcsException)11 URIish (org.eclipse.jgit.transport.URIish)11 Repository (org.eclipse.jgit.lib.Repository)9 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)7 AfterMethod (org.testng.annotations.AfterMethod)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 Method (java.lang.reflect.Method)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 GitTestUtil.copyRepository (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.copyRepository)6 Build (jetbrains.buildServer.server.rest.model.build.Build)6 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)6 FileUtil.writeFile (jetbrains.buildServer.util.FileUtil.writeFile)6