Search in sources :

Example 6 with BuildProgressLogger

use of jetbrains.buildServer.agent.BuildProgressLogger in project teamcity-powershell by JetBrains.

the class PowerShellServiceWindows method getFileCommandLine.

@Override
protected SimpleProgramCommandLine getFileCommandLine(@NotNull final PowerShellInfo info, @NotNull final Map<String, String> env, @NotNull final String workDir, @NotNull final List<String> args) throws RunBuildException {
    final BuildProgressLogger buildLogger = getBuild().getBuildLogger();
    final String command = myCommands.getNativeCommand(info);
    buildLogger.message("Command: " + command);
    buildLogger.message("PowerShell arguments: " + StringUtil.join(args, ", "));
    return new SimpleProgramCommandLine(env, workDir, command, args);
}
Also used : BuildProgressLogger(jetbrains.buildServer.agent.BuildProgressLogger) SimpleProgramCommandLine(jetbrains.buildServer.agent.runner.SimpleProgramCommandLine)

Example 7 with BuildProgressLogger

use of jetbrains.buildServer.agent.BuildProgressLogger in project teamcity-torrent-plugin by JetBrains.

the class TorrentTransportTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    super.setUp();
    myServer = new Server(12345);
    WebAppContext handler = new WebAppContext();
    handler.setResourceBase("/");
    handler.setContextPath(CONTEXT_PATH);
    myDownloadMap = new HashMap<String, File>();
    myDownloadAttempts = new ArrayList<String>();
    myDownloadHonestly = true;
    myConfiguration = new FakeTorrentConfiguration();
    myDownloadHacks = new HashMap<String, byte[]>();
    myDownloadHackAttempts = new ArrayList<String>();
    handler.addServlet(new ServletHolder(new HttpServlet() {

        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            myDownloadAttempts.add(req.getPathInfo());
            final ServletOutputStream os = resp.getOutputStream();
            final File file = myDownloadMap.get(req.getPathInfo());
            if (file == null) {
                resp.getOutputStream().close();
            } else {
                final byte[] bytes = FileUtils.readFileToByteArray(file);
                os.write(bytes);
                os.close();
            }
        }
    }), "/*");
    myServer.setHandler(handler);
    myServer.start();
    myAgentParametersMap = new HashMap<String, String>();
    Mockery m = new Mockery();
    myBuild = m.mock(AgentRunningBuild.class);
    myLeechSettings = m.mock(LeechSettings.class);
    final BuildProgressLogger myLogger = new FakeBuildProgressLogger();
    final TorrentFilesFactory torrentFilesFactory = m.mock(TorrentFilesFactory.class);
    m.checking(new Expectations() {

        {
            allowing(myBuild).getSharedConfigParameters();
            will(returnValue(myAgentParametersMap));
            allowing(myBuild).getBuildTypeId();
            will(returnValue("TC_Gaya80x_BuildDist"));
            allowing(myBuild).getBuildLogger();
            will(returnValue(myLogger));
            allowing(myLeechSettings).isDownloadEnabled();
            will(returnValue(true));
            allowing(myLeechSettings).getMaxPieceDownloadTime();
            will(returnValue(15));
            allowing(myLeechSettings).getMinSeedersForDownload();
            will(returnValue(1));
            allowing(torrentFilesFactory).getTorrentFile();
            will(returnValue(createTempFile()));
        }
    });
    BuildAgentConfiguration agentConfiguration = myAgentConfigurationFixture.setUp();
    mySeeder = new AgentTorrentsSeeder(agentConfiguration, myConfiguration);
    myTorrentTransport = new TorrentTransportFactory.TorrentTransport(mySeeder.getTorrentsSeeder(), new HttpClient(), myBuild.getBuildLogger(), "http://localhost:12345", new TorrentsDownloadStatistic(), myLeechSettings, torrentFilesFactory) {

        @Override
        protected byte[] download(@NotNull String urlString) throws IOException {
            if (myDownloadHonestly) {
                return super.download(urlString);
            } else {
                myDownloadHackAttempts.add(urlString);
                return myDownloadHacks.get(urlString);
            }
        }
    };
    myTempDir = createTempDir();
}
Also used : Server(org.eclipse.jetty.server.Server) ServletOutputStream(javax.servlet.ServletOutputStream) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) Mockery(org.jmock.Mockery) HttpServletRequest(javax.servlet.http.HttpServletRequest) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) LeechSettings(jetbrains.buildServer.torrent.settings.LeechSettings) TorrentsDownloadStatistic(jetbrains.buildServer.torrent.util.TorrentsDownloadStatistic) BuildAgentConfiguration(jetbrains.buildServer.agent.BuildAgentConfiguration) Expectations(org.jmock.Expectations) AgentRunningBuild(jetbrains.buildServer.agent.AgentRunningBuild) HttpServlet(javax.servlet.http.HttpServlet) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) BuildProgressLogger(jetbrains.buildServer.agent.BuildProgressLogger) HttpClient(org.apache.commons.httpclient.HttpClient) File(java.io.File) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

BuildProgressLogger (jetbrains.buildServer.agent.BuildProgressLogger)7 SimpleProgramCommandLine (jetbrains.buildServer.agent.runner.SimpleProgramCommandLine)3 File (java.io.File)2 RunBuildException (jetbrains.buildServer.RunBuildException)2 PowerShellInfo (jetbrains.buildServer.powershell.agent.detect.PowerShellInfo)2 NotNull (org.jetbrains.annotations.NotNull)2 IOException (java.io.IOException)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 HttpServlet (javax.servlet.http.HttpServlet)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 AgentRunningBuild (jetbrains.buildServer.agent.AgentRunningBuild)1 BuildAgentConfiguration (jetbrains.buildServer.agent.BuildAgentConfiguration)1 PowerShellBitness (jetbrains.buildServer.powershell.common.PowerShellBitness)1 PowerShellEdition (jetbrains.buildServer.powershell.common.PowerShellEdition)1 PowerShellExecutionMode (jetbrains.buildServer.powershell.common.PowerShellExecutionMode)1 LeechSettings (jetbrains.buildServer.torrent.settings.LeechSettings)1 TorrentsDownloadStatistic (jetbrains.buildServer.torrent.util.TorrentsDownloadStatistic)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 Server (org.eclipse.jetty.server.Server)1