use of com.facebook.buck.util.versioncontrol.NoOpCmdLineInterface in project buck by facebook.
the class InteractiveReportIntegrationTest method createDefectReport.
private static DefectSubmitResult createDefectReport(ProjectWorkspace workspace, ByteArrayInputStream inputStream) throws IOException, InterruptedException {
ProjectFilesystem filesystem = workspace.asCell().getFilesystem();
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
RageConfig rageConfig = RageConfig.of(workspace.asCell().getBuckConfig());
Clock clock = new DefaultClock();
ExtraInfoCollector extraInfoCollector = Optional::empty;
TestConsole console = new TestConsole();
DefectReporter defectReporter = new DefaultDefectReporter(filesystem, objectMapper, rageConfig, BuckEventBusFactory.newInstance(clock), clock);
WatchmanDiagReportCollector watchmanDiagReportCollector = new WatchmanDiagReportCollector(filesystem, WATCHMAN_DIAG_COMMAND, createFakeWatchmanDiagProcessExecutor(console));
InteractiveReport interactiveReport = new InteractiveReport(defectReporter, filesystem, objectMapper, console, inputStream, TestBuildEnvironmentDescription.INSTANCE, VcsInfoCollector.create(new NoOpCmdLineInterface()), rageConfig, extraInfoCollector, Optional.of(watchmanDiagReportCollector));
return interactiveReport.collectAndSubmitResult().get();
}
use of com.facebook.buck.util.versioncontrol.NoOpCmdLineInterface in project buck by facebook.
the class RageCommandIntegrationTest method testExtraInfo.
@Test
public void testExtraInfo() throws Exception {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "interactive_report", temporaryFolder);
workspace.setUp();
RageConfig rageConfig = createRageConfig(0, "python, extra.py", RageProtocolVersion.SIMPLE);
ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
Console console = new TestConsole();
CapturingDefectReporter defectReporter = new CapturingDefectReporter();
AutomatedReport automatedReport = new AutomatedReport(defectReporter, filesystem, ObjectMappers.newDefaultInstance(), new TestConsole(), TestBuildEnvironmentDescription.INSTANCE, VcsInfoCollector.create(new NoOpCmdLineInterface()), rageConfig, new DefaultExtraInfoCollector(rageConfig, filesystem, new DefaultProcessExecutor(console)));
automatedReport.collectAndSubmitResult();
DefectReport defectReport = defectReporter.getDefectReport();
assertThat(defectReport.getExtraInfo(), Matchers.equalTo(Optional.of("Extra\n")));
assertThat(FluentIterable.from(defectReport.getIncludedPaths()).transform(Object::toString), Matchers.hasItem(Matchers.endsWith("extra.txt")));
}
use of com.facebook.buck.util.versioncontrol.NoOpCmdLineInterface in project buck by facebook.
the class RageCommandIntegrationTest method testUploadFailure.
@Test
public void testUploadFailure() throws Exception {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "interactive_report", temporaryFolder);
workspace.setUp();
try (HttpdForTests httpd = new HttpdForTests()) {
httpd.addHandler(new AbstractHandler() {
@Override
public void handle(String s, Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {
httpServletResponse.setStatus(500);
request.setHandled(true);
}
});
httpd.start();
RageConfig rageConfig = createRageConfig(httpd.getRootUri().getPort(), "", RageProtocolVersion.SIMPLE);
ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
Clock clock = new DefaultClock();
DefectReporter reporter = new DefaultDefectReporter(filesystem, objectMapper, rageConfig, BuckEventBusFactory.newInstance(clock), clock);
AutomatedReport automatedReport = new AutomatedReport(reporter, filesystem, objectMapper, new TestConsole(), TestBuildEnvironmentDescription.INSTANCE, VcsInfoCollector.create(new NoOpCmdLineInterface()), rageConfig, Optional::empty);
DefectSubmitResult submitReport = automatedReport.collectAndSubmitResult().get();
// If upload fails it should store the zip locally and inform the user.
assertFalse(submitReport.getReportSubmitErrorMessage().get().isEmpty());
ZipInspector zipInspector = new ZipInspector(filesystem.resolve(submitReport.getReportSubmitLocation().get()));
assertEquals(zipInspector.getZipFileEntries().size(), 7);
}
}
use of com.facebook.buck.util.versioncontrol.NoOpCmdLineInterface in project buck by facebook.
the class RageCommandIntegrationTest method testUpload.
@Test
public void testUpload() throws Exception {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "interactive_report", temporaryFolder);
workspace.setUp();
final AtomicReference<String> requestMethod = new AtomicReference<>();
final AtomicReference<String> requestPath = new AtomicReference<>();
final AtomicReference<byte[]> requestBody = new AtomicReference<>();
final String successMessage = "Upload successful";
try (HttpdForTests httpd = new HttpdForTests()) {
httpd.addHandler(new AbstractHandler() {
@Override
public void handle(String s, Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {
httpServletResponse.setStatus(200);
request.setHandled(true);
if (request.getUri().getPath().equals("/status.php")) {
return;
}
requestPath.set(request.getUri().getPath());
requestMethod.set(request.getMethod());
requestBody.set(ByteStreams.toByteArray(httpServletRequest.getInputStream()));
try (DataOutputStream out = new DataOutputStream(httpServletResponse.getOutputStream())) {
out.writeBytes(successMessage);
}
}
});
httpd.start();
RageConfig rageConfig = createRageConfig(httpd.getRootUri().getPort(), "", RageProtocolVersion.SIMPLE);
ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
Clock clock = new DefaultClock();
DefectReporter reporter = new DefaultDefectReporter(filesystem, objectMapper, rageConfig, BuckEventBusFactory.newInstance(clock), clock);
AutomatedReport automatedReport = new AutomatedReport(reporter, filesystem, objectMapper, new TestConsole(), TestBuildEnvironmentDescription.INSTANCE, VcsInfoCollector.create(new NoOpCmdLineInterface()), rageConfig, Optional::empty);
DefectSubmitResult defectSubmitResult = automatedReport.collectAndSubmitResult().get();
assertThat(defectSubmitResult.getReportSubmitMessage(), Matchers.equalTo(Optional.of(successMessage)));
assertThat(requestPath.get(), Matchers.equalTo(UPLOAD_PATH));
assertThat(requestMethod.get(), Matchers.equalTo("POST"));
filesystem.mkdirs(filesystem.getBuckPaths().getBuckOut());
Path report = filesystem.createTempFile(filesystem.getBuckPaths().getBuckOut(), "report", "zip");
filesystem.writeBytesToPath(requestBody.get(), report);
ZipInspector zipInspector = new ZipInspector(filesystem.resolve(report));
zipInspector.assertFileExists("report.json");
zipInspector.assertFileExists("buckconfig.local");
zipInspector.assertFileExists("bucklogging.local.properties");
zipInspector.assertFileExists(BUILD_COMMAND_DIR_PATH + "buck.log");
zipInspector.assertFileExists(AUTODEPS_COMMAND_DIR_PATH + "buck.log");
zipInspector.assertFileExists(BUILD_COMMAND_DIR_PATH + "buck-machine-log");
zipInspector.assertFileExists(AUTODEPS_COMMAND_DIR_PATH + "buck-machine-log");
}
}
use of com.facebook.buck.util.versioncontrol.NoOpCmdLineInterface in project buck by facebook.
the class RageCommandIntegrationTest method testJsonUpload.
@Test
public void testJsonUpload() throws Exception {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "interactive_report", temporaryFolder);
workspace.setUp();
try (HttpdForTests httpd = new HttpdForTests()) {
httpd.addHandler(new AbstractHandler() {
@Override
public void handle(String s, Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpResponse) throws IOException, ServletException {
httpResponse.setStatus(200);
request.setHandled(true);
if (request.getUri().getPath().equals("/status.php")) {
return;
}
RageJsonResponse json = RageJsonResponse.of(/* isRequestSuccessful */
true, /* errorMessage */
Optional.empty(), /* rageUrl */
Optional.of("http://remoteUrlToVisit"), /* message */
Optional.of("This is supposed to be JSON."));
try (DataOutputStream out = new DataOutputStream(httpResponse.getOutputStream())) {
objectMapper.writeValue(out, json);
}
}
});
httpd.start();
RageConfig rageConfig = createRageConfig(httpd.getRootUri().getPort(), "", RageProtocolVersion.JSON);
ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
Clock clock = new DefaultClock();
DefectReporter reporter = new DefaultDefectReporter(filesystem, objectMapper, rageConfig, BuckEventBusFactory.newInstance(clock), clock);
AutomatedReport automatedReport = new AutomatedReport(reporter, filesystem, objectMapper, new TestConsole(), TestBuildEnvironmentDescription.INSTANCE, VcsInfoCollector.create(new NoOpCmdLineInterface()), rageConfig, Optional::empty);
DefectSubmitResult submitReport = automatedReport.collectAndSubmitResult().get();
assertEquals("http://remoteUrlToVisit", submitReport.getReportSubmitLocation().get());
assertEquals("This is supposed to be JSON.", submitReport.getReportSubmitMessage().get());
}
}
Aggregations