changeset 76:2f96f552f1bd 8.0.x

merged 8.1.x
author Evgeniy.Koshkin
date Tue, 04 Mar 2014 16:37:24 +0400
parents 29c6049b8e06 (current diff) 737ef280a587 (diff)
children
files .idea/ant.xml .idea/libraries/TeamCity_server_runtime.xml server-tests/src/DownloadSymbolsControllerTest.java server-tests/src/MetadataStorageMock.java server/src/jetbrains/buildServer/symbols/AuthHelper.java
diffstat 15 files changed, 255 insertions(+), 175 deletions(-) [+]
line wrap: on
line diff
--- a/.idea/ant.xml	Thu Feb 27 12:10:05 2014 +0400
+++ b/.idea/ant.xml	Tue Mar 04 16:37:24 2014 +0400
@@ -1,15 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="AntConfiguration">
-    <defaultAnt bundledAnt="true" />
-    <buildFile url="file://$PROJECT_DIR$/build/ant.build.xml">
-      <additionalClassPath />
-      <antReference projectDefault="true" />
-      <customJdkName value="" />
-      <maximumHeapSize value="128" />
-      <maximumStackSize value="2" />
-      <properties />
-    </buildFile>
+    <buildFile url="file://$PROJECT_DIR$/build/ant.build.xml" />
   </component>
 </project>
 
--- a/.idea/libraries/Common_Api.xml	Thu Feb 27 12:10:05 2014 +0400
+++ b/.idea/libraries/Common_Api.xml	Tue Mar 04 16:37:24 2014 +0400
@@ -2,7 +2,6 @@
   <library name="Common-Api">
     <CLASSES>
       <root url="jar://$teamcitydistribution$/devPackage/common-api.jar!/" />
-      <root url="jar://$teamcitydistribution$/webapps/ROOT/WEB-INF/lib/annotations.jar!/" />
     </CLASSES>
     <JAVADOC />
     <SOURCES>
--- a/.idea/libraries/TeamCity_server_runtime.xml	Thu Feb 27 12:10:05 2014 +0400
+++ b/.idea/libraries/TeamCity_server_runtime.xml	Tue Mar 04 16:37:24 2014 +0400
@@ -4,7 +4,13 @@
       <root url="file://$teamcitydistribution$/webapps/ROOT/WEB-INF/lib" />
     </CLASSES>
     <JAVADOC />
-    <SOURCES />
+    <SOURCES>
+      <root url="file://$teamcitydistribution$/webapps/ROOT/WEB-INF/lib" />
+    </SOURCES>
     <jarDirectory url="file://$teamcitydistribution$/webapps/ROOT/WEB-INF/lib" recursive="false" />
+    <jarDirectory url="file://$teamcitydistribution$/webapps/ROOT/WEB-INF/lib" recursive="false" />
+    <jarDirectory url="file://$teamcitydistribution$/webapps/ROOT/WEB-INF/lib" recursive="false" />
+    <jarDirectory url="file://$teamcitydistribution$/webapps/ROOT/WEB-INF/lib" recursive="false" type="SOURCES" />
+    <jarDirectory url="file://$teamcitydistribution$/webapps/ROOT/WEB-INF/lib" recursive="false" type="SOURCES" />
   </library>
 </component>
\ No newline at end of file
--- a/.idea/modules.xml	Thu Feb 27 12:10:05 2014 +0400
+++ b/.idea/modules.xml	Tue Mar 04 16:37:24 2014 +0400
@@ -3,6 +3,7 @@
   <component name="ProjectModuleManager">
     <modules>
       <module fileurl="file://$PROJECT_DIR$/agent/agent.iml" filepath="$PROJECT_DIR$/agent/agent.iml" />
+      <module fileurl="file://$PROJECT_DIR$/agent-tests/agent-tests.iml" filepath="$PROJECT_DIR$/agent-tests/agent-tests.iml" />
       <module fileurl="file://$PROJECT_DIR$/common/common.iml" filepath="$PROJECT_DIR$/common/common.iml" />
       <module fileurl="file://$PROJECT_DIR$/idea-resolve-helper.iml" filepath="$PROJECT_DIR$/idea-resolve-helper.iml" />
       <module fileurl="file://$PROJECT_DIR$/server/server.iml" filepath="$PROJECT_DIR$/server/server.iml" />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/agent-tests/agent-tests.iml	Tue Mar 04 16:37:24 2014 +0400
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="true" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="agent" />
+    <orderEntry type="library" name="Test-Api" level="project" />
+    <orderEntry type="library" name="testng" level="project" />
+    <orderEntry type="library" name="jmock" level="project" />
+    <orderEntry type="library" name="Common-Api" level="project" />
+    <orderEntry type="library" name="Idea-OpenApi" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="TeamCity agent runtime" level="project" />
+  </component>
+</module>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/agent-tests/src/jetbrains/buildServer/symbols/JetSymbolsExeTest.java	Tue Mar 04 16:37:24 2014 +0400
@@ -0,0 +1,190 @@
+package jetbrains.buildServer.symbols;
+
+import jetbrains.buildServer.BaseTestCase;
+import jetbrains.buildServer.BuildProblemData;
+import jetbrains.buildServer.agent.BuildProgressLogger;
+import jetbrains.buildServer.agent.FlowLogger;
+import jetbrains.buildServer.agent.NullBuildProgressLogger;
+import jetbrains.buildServer.messages.BuildMessage1;
+import jetbrains.buildServer.symbols.tools.JetSymbolsExe;
+import jetbrains.buildServer.util.FileUtil;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+
+/**
+ * @author Evgeniy.Koshkin
+ */
+public class JetSymbolsExeTest extends BaseTestCase implements BuildProgressLogger {
+
+  private JetSymbolsExe myExe;
+
+  @Override
+  @BeforeMethod
+  public void setUp() throws Exception {
+    super.setUp();
+    File homeDir = new File("tools\\JetSymbols").getAbsoluteFile();
+    assertTrue("Failed to find JetSymbolsExe home dir on path " + homeDir.getAbsolutePath(), homeDir.isDirectory());
+    myExe = new JetSymbolsExe(homeDir);
+  }
+
+  @Test
+  public void testCmdParametersLengthLimit() throws Exception {
+    myExe.dumpGuidsToFile(getFilesCollection(500), FileUtil.createTempFile("testCmdParametersLengthLimit", ".out"), this);
+  }
+
+  private Collection<File> getFilesCollection(int count) throws IOException {
+    Collection<File> result = new HashSet<File>();
+    for (int i = 0; i < count; i++){
+      result.add(FileUtil.createTempFile("foo", "boo"));
+    }
+    return result;
+  }
+
+  public void activityStarted(String activityName, String activityType) {
+
+  }
+
+  public void activityStarted(String activityName, String activityDescription, String activityType) {
+
+  }
+
+  public void activityFinished(String activityName, String activityType) {
+
+  }
+
+  public void targetStarted(String targetName) {
+
+  }
+
+  public void targetFinished(String targetName) {
+
+  }
+
+  public void buildFailureDescription(String message) {
+
+  }
+
+  public void internalError(String type, String message, Throwable throwable) {
+
+  }
+
+  public void progressStarted(String message) {
+
+  }
+
+  public void progressFinished() {
+
+  }
+
+  public void logMessage(BuildMessage1 message) {
+
+  }
+
+  public void logTestStarted(String name) {
+
+  }
+
+  public void logTestStarted(String name, Date timestamp) {
+
+  }
+
+  public void logTestFinished(String name) {
+
+  }
+
+  public void logTestFinished(String name, Date timestamp) {
+
+  }
+
+  public void logTestIgnored(String name, String reason) {
+
+  }
+
+  public void logSuiteStarted(String name) {
+
+  }
+
+  public void logSuiteStarted(String name, Date timestamp) {
+
+  }
+
+  public void logSuiteFinished(String name) {
+
+  }
+
+  public void logSuiteFinished(String name, Date timestamp) {
+
+  }
+
+  public void logTestStdOut(String testName, String out) {
+
+  }
+
+  public void logTestStdErr(String testName, String out) {
+
+  }
+
+  public void logTestFailed(String testName, Throwable e) {
+
+  }
+
+  public void logComparisonFailure(String testName, Throwable e, String expected, String actual) {
+
+  }
+
+  public void logTestFailed(String testName, String message, String stackTrace) {
+
+  }
+
+  public void flush() {
+
+  }
+
+  public void ignoreServiceMessages(Runnable runnable) {
+
+  }
+
+  public FlowLogger getFlowLogger(String flowId) {
+    return null;
+  }
+
+  public FlowLogger getThreadLogger() {
+    return null;
+  }
+
+  public String getFlowId() {
+    return null;
+  }
+
+  public void logBuildProblem(BuildProblemData buildProblem) {
+
+  }
+
+  public void message(String message) {
+
+  }
+
+  public void error(String message) {
+    fail(message);
+  }
+
+  public void warning(String message) {
+
+  }
+
+  public void exception(Throwable th) {
+    if(th != null) {
+      fail(th.toString());
+    }
+  }
+
+  public void progressMessage(String message) {
+
+  }
+}
--- a/agent/agent.iml	Thu Feb 27 12:10:05 2014 +0400
+++ b/agent/agent.iml	Tue Mar 04 16:37:24 2014 +0400
@@ -20,6 +20,7 @@
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" name="Agent-Api" level="project" />
+    <orderEntry type="library" name="idea annotations.jar" level="project" />
     <orderEntry type="library" name="Common-Api" level="project" />
     <orderEntry type="library" name="log4j" level="project" />
     <orderEntry type="library" name="Idea-OpenApi" level="project" />
--- a/agent/src/jetbrains/buildServer/symbols/tools/JetSymbolsExe.java	Thu Feb 27 12:10:05 2014 +0400
+++ b/agent/src/jetbrains/buildServer/symbols/tools/JetSymbolsExe.java	Tue Mar 04 16:37:24 2014 +0400
@@ -4,8 +4,10 @@
 import jetbrains.buildServer.ExecResult;
 import jetbrains.buildServer.SimpleCommandLineProcessRunner;
 import jetbrains.buildServer.agent.BuildProgressLogger;
+import jetbrains.buildServer.util.FileUtil;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.Collection;
 
 /**
@@ -21,14 +23,12 @@
     myExePath = new File(homeDir, SYMBOLS_EXE);
   }
 
-  public void dumpGuidsToFile(Collection<File> files, File output, BuildProgressLogger buildLogger){
+  public void dumpGuidsToFile(Collection<File> files, File output, BuildProgressLogger buildLogger) throws IOException {
     final GeneralCommandLine commandLine = new GeneralCommandLine();
     commandLine.setExePath(myExePath.getPath());
     commandLine.addParameter(DUMP_SYMBOL_SIGN_CMD);
     commandLine.addParameter(String.format("/o=\"%s\"", output.getPath()));
-    for(File file : files){
-      commandLine.addParameter(file.getPath());
-    }
+    commandLine.addParameter(String.format("/i=\"%s\"", dumpPathsToFile(files).getPath()));
     buildLogger.message(String.format("Running command %s", commandLine.getCommandLineString()));
     final ExecResult execResult = SimpleCommandLineProcessRunner.runCommand(commandLine, null);
     final String stdout = execResult.getStdout();
@@ -41,4 +41,14 @@
     buildLogger.warning("Stderr: " + execResult.getStderr());
     buildLogger.exception(execResult.getException());
   }
+
+  private File dumpPathsToFile(Collection<File> files) throws IOException {
+    final File result = FileUtil.createTempFile(DUMP_SYMBOL_SIGN_CMD, ".input");
+    StringBuilder contentBuilder = new StringBuilder();
+    for(File file : files){
+      contentBuilder.append(file.getPath()).append("\n");
+    }
+    FileUtil.writeToFile(result, contentBuilder.toString().getBytes());
+    return result;
+  }
 }
--- a/server-tests/src/DownloadSymbolsControllerTest.java	Thu Feb 27 12:10:05 2014 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import jetbrains.buildServer.controllers.AuthorizationInterceptor;
-import jetbrains.buildServer.controllers.BaseController;
-import jetbrains.buildServer.controllers.BaseControllerTestCase;
-import jetbrains.buildServer.controllers.interceptors.auth.HttpAuthenticationManager;
-import jetbrains.buildServer.serverSide.RunningBuildEx;
-import jetbrains.buildServer.serverSide.auth.Permission;
-import jetbrains.buildServer.serverSide.auth.RoleScope;
-import jetbrains.buildServer.symbols.AuthHelper;
-import jetbrains.buildServer.symbols.DownloadSymbolsController;
-import jetbrains.buildServer.users.SUser;
-import org.apache.commons.httpclient.HttpStatus;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * @author Evgeniy.Koshkin
- */
-public class DownloadSymbolsControllerTest extends BaseControllerTestCase {
-
-  private MetadataStorageMock myBuildMetadataStorage;
-
-  @Override
-  @BeforeMethod
-  public void setUp() throws Exception {
-    myBuildMetadataStorage = new MetadataStorageMock();
-    super.setUp();
-    myFixture.getServerSettings().setGuestLoginAllowed(true);
-  }
-
-  @Override
-  protected BaseController createController() throws IOException {
-    AuthorizationInterceptor authInterceptor = myFixture.getSingletonService(AuthorizationInterceptor.class);
-    AuthHelper authHelper = new AuthHelper(myFixture.getServerSettings(), myFixture.getUserModel(), myFixture.getSingletonService(HttpAuthenticationManager.class));
-    return new DownloadSymbolsController(myServer, myWebManager, authInterceptor,  myFixture.getSecurityContext(), myBuildMetadataStorage, authHelper);
-  }
-
-  @Test
-  public void request_pdb_simple() throws Throwable {
-    myFixture.getServerSettings().setPerProjectPermissionsEnabled(true);
-    SUser user = myFixture.getUserModel().getGuestUser();
-    user.addRole(RoleScope.projectScope(myProject.getProjectId()), getProjectDevRole());
-    assertTrue(user.isPermissionGrantedForProject(myProject.getProjectId(), Permission.VIEW_BUILD_RUNTIME_DATA));
-
-    myRequest.setRequestURI("mock", getRegisterPdbUrl("secur32.pdb", "8EF4E863187C45E78F4632152CC82FEB"));
-    doGet();
-    assertEquals(HttpStatus.SC_OK, myResponse.getStatus());
-  }
-
-  @Test
-  public void request_pdb_two_slashes_in_url() throws Exception {
-    myRequest.setRequestURI("mock", "/app/symbols//index2.txt'");
-    doGet();
-    assertEquals(HttpStatus.SC_NOT_FOUND, myResponse.getStatus());
-  }
-
-  @Test
-  public void request_pdb_invalid_url() throws Exception {
-    myRequest.setRequestURI("mock", "/app/symbols/foo");
-    doGet();
-    assertEquals(HttpStatus.SC_NOT_FOUND, myResponse.getStatus());
-  }
-
-  @Test
-  public void request_not_existent_pdb() throws Exception {
-    myRequest.setRequestURI("mock", "/app/symbols/fileName/FileId2/fileName");
-    doGet();
-    assertEquals(HttpStatus.SC_NOT_FOUND, myResponse.getStatus());
-  }
-
-  @Test
-  public void request_pdb_unauthorized() throws Exception {
-    myFixture.getServerSettings().setGuestLoginAllowed(false);
-    myRequest.setRequestURI("mock", getRegisterPdbUrl("secur32.pdb", "8EF4E863187C45E78F4632152CC82FEB"));
-    doGet();
-    assertEquals(HttpStatus.SC_UNAUTHORIZED, myResponse.getStatus());
-  }
-
-  @Test
-  public void request_pdb_no_permissions_granted() throws Exception {
-    myRequest.setRequestURI("mock", getRegisterPdbUrl("secur32.pdb", "8EF4E863187C45E78F4632152CC82FEB"));
-    doGet();
-    assertEquals(HttpStatus.SC_UNAUTHORIZED, myResponse.getStatus());
-  }
-
-  private String getRegisterPdbUrl(String fileName, String fileSignature) throws IOException {
-    final File artDirectory = createTempDir();
-    new File(artDirectory, "foo").createNewFile();
-    myBuildType.setArtifactPaths(artDirectory.getAbsolutePath());
-    RunningBuildEx build = startBuild();
-    myBuildMetadataStorage.addEntry(build.getBuildId(), fileName, fileSignature);
-    return String.format("/app/symbols/%s/%s/%s", fileName, fileSignature, fileName);
-  }
-}
--- a/server-tests/src/MetadataStorageMock.java	Thu Feb 27 12:10:05 2014 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-import jetbrains.buildServer.serverSide.metadata.BuildMetadataEntry;
-import jetbrains.buildServer.serverSide.metadata.MetadataStorage;
-import jetbrains.buildServer.symbols.BuildSymbolsIndexProvider;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.*;
-
-class MetadataStorageMock implements MetadataStorage {
-
-  private List<BuildMetadataEntry> myEntries = new ArrayList<BuildMetadataEntry>();
-
-  public void addEntry(final long buildId, final String fileName, final String fileSignature) {
-    myEntries.add(new BuildMetadataEntry() {
-      public long getBuildId() {
-        return buildId;
-      }
-
-      @NotNull
-      public String getKey() {
-        return fileSignature;
-      }
-
-      @NotNull
-      public Map<String, String> getMetadata() {
-        HashMap<String, String> map = new HashMap<String, String>();
-        map.put(BuildSymbolsIndexProvider.ARTIFACT_PATH_KEY, "foo");
-        map.put(BuildSymbolsIndexProvider.FILE_NAME_KEY, fileName);
-        return map;
-      }
-    });
-  }
-
-  @NotNull
-  public Iterator<BuildMetadataEntry> getAllEntries(@NotNull String s) {
-    return myEntries.iterator();
-  }
-
-  @NotNull
-  public Iterator<BuildMetadataEntry> getEntriesByKey(@NotNull String s, @NotNull String s2) {
-    return myEntries.iterator();
-  }
-
-  @NotNull
-  public Iterator<BuildMetadataEntry> getBuildEntry(long l, @NotNull String s) {
-    return myEntries.iterator();
-  }
-}
\ No newline at end of file
--- a/server-tests/src/jetbrains/buildServer/symbols/DownloadSymbolsControllerTest.java	Thu Feb 27 12:10:05 2014 +0400
+++ b/server-tests/src/jetbrains/buildServer/symbols/DownloadSymbolsControllerTest.java	Tue Mar 04 16:37:24 2014 +0400
@@ -1,4 +1,18 @@
-package jetbrains.buildServer.symbols;
+package jetbrains.buildServer.symbols;/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 import jetbrains.buildServer.controllers.AuthorizationInterceptor;
 import jetbrains.buildServer.controllers.BaseController;
@@ -50,6 +64,13 @@
   }
 
   @Test
+  public void request_pdb_two_slashes_in_url() throws Exception {
+    myRequest.setRequestURI("mock", "/app/symbols//index2.txt'");
+    doGet();
+    assertEquals(HttpStatus.SC_NOT_FOUND, myResponse.getStatus());
+  }
+
+  @Test
   public void request_pdb_invalid_url() throws Exception {
     myRequest.setRequestURI("mock", "/app/symbols/foo");
     doGet();
Binary file tools/JetSymbols/JetBrains.CommandLine.Symbols.exe has changed
Binary file tools/JetSymbols/JetBrains.Platform.Symbols.Interop.WinApi.dll has changed
Binary file tools/JetSymbols/JetBrains.Platform.Symbols.Metadata.dll has changed
Binary file tools/JetSymbols/JetBrains.Platform.Symbols.Util.dll has changed