use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.
the class PowerShellRunTypeTest method testGenerateAnyBitnessRequirement_WithMinVersion.
@Test(dataProvider = "versionProvider")
@TestFor(issues = "TW-44808")
public void testGenerateAnyBitnessRequirement_WithMinVersion(@Nullable final String version) {
final Map<String, String> input = createDummyParameters(null);
if (version != null) {
input.put(PowerShellConstants.RUNNER_MIN_VERSION, version);
}
final Collection<Requirement> requirements = runType.getRunnerSpecificRequirements(input);
assertEquals(1, requirements.size());
final Requirement r = requirements.iterator().next();
assertEquals("Exists=>(powershell_Core_x86|powershell_Core_x64|powershell_Desktop_x86|powershell_Desktop_x64)", r.getPropertyName());
assertEquals(version, r.getPropertyValue());
if (version != null) {
assertEquals(RequirementType.VER_NO_LESS_THAN, r.getType());
}
}
use of jetbrains.buildServer.util.TestFor in project teamcity-rest by JetBrains.
the class BuildTest method testBuildEstimates.
@Test
@TestFor(issues = "TW-50824")
public void testBuildEstimates() throws Exception {
BuildTypeImpl bt1 = registerBuildType("buildType1", "projectName");
// ~setting build estimate to 10 minutes
Date tenMinutesAgo = Date.from(Instant.now().minus(10, ChronoUnit.MINUTES));
createBuildWithBuildDurationStatistic(bt1, Status.NORMAL, tenMinutesAgo, tenMinutesAgo, myBuildAgent);
build().in(bt1).addToQueue();
build().in(bt1).parameter("a", "prevent merging").addToQueue();
BuildTypeImpl bt2 = registerBuildType("buildType2", "projectName");
bt2.addRequirement(myFixture.getSingletonService(RequirementFactory.class).createRequirement("missing", "some", RequirementType.EQUALS));
build().in(bt2).addToQueue();
myFixture.getSingletonService(CachingBuildEstimator.class).invalidate(true);
TimeInterval timeInterval = myServer.getQueue().getItems().get(1).getBuildEstimates().getTimeInterval();
long diff = timeInterval.getStartPoint().getAbsoluteTime().getTime() - Date.from(Instant.now().plus(10, ChronoUnit.MINUTES)).getTime();
assertTrue(timeInterval.getStartPoint().getAbsoluteTime().toString() + " -- " + Dates.now().toString() + ", diff: " + diff, diff < 60000);
Build build1 = new Build(myServer.getQueue().getItems().get(1).getBuildPromotion(), Fields.LONG, getBeanContext(myFixture));
assertEquals(Util.formatTime(myServer.getQueue().getItems().get(1).getBuildEstimates().getTimeInterval().getStartPoint().getAbsoluteTime()), build1.getStartEstimate());
assertEquals(Util.formatTime(myServer.getQueue().getItems().get(1).getBuildEstimates().getTimeInterval().getEndPoint().getAbsoluteTime()), build1.getFinishEstimate());
build1 = new Build(myServer.getQueue().getItems().get(2).getBuildPromotion(), Fields.LONG, getBeanContext(myFixture));
assertNull(build1.getStartEstimate());
}
use of jetbrains.buildServer.util.TestFor in project teamcity-rest by JetBrains.
the class BuildTest method testBuildArtifactsHrefWithSpecialSymbols.
@SuppressWarnings("ResultOfMethodCallIgnored")
@Test
@TestFor(issues = "TW-27205")
public void testBuildArtifactsHrefWithSpecialSymbols() throws IOException {
SFinishedBuild finishedBuild = build().in(myBuildType).finish();
final File artifactsDir = finishedBuild.getArtifactsDirectory();
artifactsDir.mkdirs();
String specialCharacters = "~!@#$%^&()_+=-`][{}'; .,\u044B%61";
File dir = new File(artifactsDir, specialCharacters);
dir.mkdirs();
File file = new File(dir, specialCharacters);
file.createNewFile();
final ApiUrlBuilder apiUrlBuilder = new ApiUrlBuilder(new PathTransformer() {
public String transform(final String path) {
return StringUtil.replace(path, "/app/rest/", "/app/rest/version/");
}
});
final Build build = new Build(finishedBuild, new Fields("href,artifacts($locator(recursive:true),href,file(name,fullName,href,children($long,$locator(pattern(+:**,+:%))),content))"), new BeanContext(new BeanFactory(null), myFixture, apiUrlBuilder));
assertEquals("/app/rest/version/builds/id:1", build.getHref());
// noinspection ConstantConditions
jetbrains.buildServer.server.rest.model.files.File artifact1 = build.getArtifacts().files.get(0);
jetbrains.buildServer.server.rest.model.files.File artifact2 = build.getArtifacts().files.get(1);
String specialCharacters_escaped;
if (!specialCharacters.equals(artifact1.name)) {
System.out.println("File system does not seem to support some characters. Was creating file \"" + specialCharacters + "\" but got \"" + artifact1.name + "\"");
specialCharacters_escaped = WebUtil.encode(artifact1.name);
} else {
specialCharacters_escaped = WebUtil.encode(specialCharacters);
assertEquals(specialCharacters, artifact2.name);
assertEquals(specialCharacters + "/" + specialCharacters, artifact2.fullName);
}
assertEquals("/app/rest/version/builds/id:1/artifacts/metadata/" + specialCharacters_escaped, artifact1.href);
// noinspection ConstantConditions
assertEquals("/app/rest/version/builds/id:1/artifacts/children/" + specialCharacters_escaped + "?locator=pattern(%2B:**,%2B:%25)", artifact1.getChildren().href);
assertEquals("/app/rest/version/builds/id:1/artifacts/metadata/" + specialCharacters_escaped + "/" + specialCharacters_escaped, artifact2.href);
// noinspection ConstantConditions
assertEquals("/app/rest/version/builds/id:1/artifacts/content/" + specialCharacters_escaped + "/" + specialCharacters_escaped, artifact2.getContent().href);
}
use of jetbrains.buildServer.util.TestFor in project teamcity-rest by JetBrains.
the class BuildTest method testDownloadedArtifacts.
@Test
@TestFor(issues = "TW-21036")
public void testDownloadedArtifacts() {
DownloadedArtifactsLoggerImpl artifactsLogger = myFixture.getSingletonService(DownloadedArtifactsLoggerImpl.class);
SBuildType bt1 = registerBuildType("bt1", "project1", "Ant");
SBuild build1 = createBuild(bt1, Status.NORMAL);
SBuildType bt2 = registerBuildType("bt2", "project2", "Ant");
SBuild build2 = createBuild(bt2, Status.NORMAL);
artifactsLogger.logArtifactDownload(build2.getBuildId(), build1.getBuildId(), "path1");
artifactsLogger.waitForQueuePersisting();
Build build2model = new Build(build2, Fields.ALL_NESTED, getBeanContext(myFixture));
jetbrains.buildServer.server.rest.model.build.downloadedArtifacts.DownloadedArtifacts build2Artifacts = build2model.getDownloadedArtifacts();
assertEquals("There is 1 build as a source of artifacts", 1, (int) build2Artifacts.getUnfilteredCount());
assertEquals("There is 1 build as a source of artifacts", 1, (int) build2Artifacts.getCount());
assertEquals("There is 1 build as a source of artifacts", 1, build2Artifacts.getDownloadInfo().size());
BuildArtifactsDownloadInfo build2downloadInfo = build2Artifacts.getDownloadInfo().get(0);
assertEquals("There is 1 downloaded artifact", 1, (int) build2downloadInfo.getCount());
assertEquals("Build(" + build2.getBuildId() + ") downloaded artifact from build(" + build1.getBuildId() + ")", build1.getBuildId(), (long) build2downloadInfo.getBuild().getId());
DownloadedArtifacts realDownloaded = build2.getDownloadedArtifacts();
ArtifactDownloadInfo artifactInfo = build2downloadInfo.getArtifactInfo().get(0);
assertEquals("path1", artifactInfo.getArtifactPath());
assertEquals(Util.formatTime(realDownloaded.getArtifacts().get(build1).get(0).getDownloadTimestamp()), artifactInfo.getDownloadTimestamp());
}
use of jetbrains.buildServer.util.TestFor in project teamcity-rest by JetBrains.
the class BuildTest method testBuildArtifactsHrefForVersionedUrls.
@Test
@TestFor(issues = "TW-51092")
public void testBuildArtifactsHrefForVersionedUrls() throws IOException {
SFinishedBuild finishedBuild = build().in(myBuildType).finish();
final File artifactsDir = finishedBuild.getArtifactsDirectory();
// noinspection ResultOfMethodCallIgnored
artifactsDir.mkdirs();
File dir = new File(artifactsDir, "dir");
// noinspection ResultOfMethodCallIgnored
dir.mkdirs();
File file = new File(artifactsDir, "file.txt");
// noinspection ResultOfMethodCallIgnored
file.createNewFile();
final ApiUrlBuilder apiUrlBuilder = new ApiUrlBuilder(new PathTransformer() {
public String transform(final String path) {
return StringUtil.replace(path, "/app/rest/", "/app/rest/version/");
}
});
final Build build = new Build(finishedBuild, new Fields("href,artifacts(href,file(children,content))"), new BeanContext(new BeanFactory(null), myFixture, apiUrlBuilder));
assertEquals("/app/rest/version/builds/id:1", build.getHref());
assertEquals("/app/rest/version/builds/id:1/artifacts/children/", build.getArtifacts().href);
// noinspection ConstantConditions
assertEquals("/app/rest/version/builds/id:1/artifacts/children/dir", build.getArtifacts().files.get(0).getChildren().href);
// noinspection ConstantConditions
assertEquals("/app/rest/version/builds/id:1/artifacts/content/file.txt", build.getArtifacts().files.get(1).getContent().href);
}
Aggregations