-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability storing of webdriver console and network logs after failing tests #8926
Changes from 22 commits
0fa6a51
f8cba6f
b5f4e52
f34a6a7
a362d20
8c668f0
b2167c8
360b707
ac41500
5e1ab4f
0d00d06
b3fe3f4
85f4efc
9861ae2
b1eab7c
97d9bca
3db9bf2
ce0cf6b
cec456d
423417f
44b7466
a2a2be2
ae5ede8
be9f972
d33badc
c8930f2
66c3ef5
925fbf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.plugin.java.server.rest; | ||
|
||
import javax.inject.Singleton; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.ExceptionMapper; | ||
import javax.ws.rs.ext.Provider; | ||
import org.eclipse.che.api.core.rest.shared.dto.ServiceError; | ||
import org.eclipse.che.dto.server.DtoFactory; | ||
import org.eclipse.jdt.core.JavaModelException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Exception mapper for all JDT exceptions | ||
* | ||
* @author Evgen Vidolob | ||
*/ | ||
@Provider | ||
@Singleton | ||
public class JavaModelExceptionMapper implements ExceptionMapper<JavaModelException> { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(JavaModelExceptionMapper.class); | ||
|
||
@Override | ||
public Response toResponse(JavaModelException exception) { | ||
LOG.error(exception.getMessage()); | ||
ServiceError serviceError = | ||
DtoFactory.getInstance().createDto(ServiceError.class).withMessage(exception.getMessage()); | ||
return Response.status(Response.Status.BAD_REQUEST) | ||
.entity(DtoFactory.getInstance().toJson(serviceError)) | ||
.type(MediaType.APPLICATION_JSON) | ||
.build(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.plugin.java.server.rest; | ||
|
||
import javax.inject.Singleton; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.ExceptionMapper; | ||
import javax.ws.rs.ext.Provider; | ||
import org.eclipse.che.dto.server.DtoFactory; | ||
import org.eclipse.che.plugin.java.server.refactoring.RefactoringException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Exception mapper for all JDT exceptions | ||
* | ||
* @author Evgen Vidolob | ||
*/ | ||
@Provider | ||
@Singleton | ||
public class RefactoringExceptionMapper implements ExceptionMapper<RefactoringException> { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(RefactoringExceptionMapper.class); | ||
|
||
@Override | ||
public Response toResponse(RefactoringException exception) { | ||
LOG.error(exception.getMessage()); | ||
return Response.status(Response.Status.BAD_REQUEST) | ||
.entity(DtoFactory.getInstance().toJson(exception.getServiceError())) | ||
.type(MediaType.APPLICATION_JSON) | ||
.build(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,8 @@ | |
import org.eclipse.jdt.internal.core.JavaModel; | ||
import org.eclipse.jdt.internal.core.JavaModelManager; | ||
import org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Service for all Java refactorings | ||
|
@@ -58,6 +60,7 @@ | |
public class RefactoringService { | ||
private static final JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel(); | ||
private RefactoringManager manager; | ||
private static final Logger LOG = LoggerFactory.getLogger(RefactoringService.class); | ||
|
||
@Inject | ||
public RefactoringService(RefactoringManager manager) { | ||
|
@@ -78,6 +81,11 @@ public RefactoringService(RefactoringManager manager) { | |
@Produces("text/plain") | ||
public String createMoveRefactoring(CreateMoveRefactoring cmr) | ||
throws JavaModelException, RefactoringException { | ||
LOG.info( | ||
"createMoveRefactoring started in " | ||
+ System.currentTimeMillis() | ||
+ " ms with " | ||
+ cmr.toString()); | ||
IJavaProject javaProject = model.getJavaProject(cmr.getProjectPath()); | ||
IJavaElement[] javaElements; | ||
try { | ||
|
@@ -104,16 +112,30 @@ public String createMoveRefactoring(CreateMoveRefactoring cmr) | |
javaElements = cmr.getElements().stream().map(map).toArray(IJavaElement[]::new); | ||
|
||
} catch (IllegalArgumentException e) { | ||
LOG.error( | ||
"createMoveRefactoring fail in " | ||
+ System.currentTimeMillis() | ||
+ " ms with exception " | ||
+ e.getMessage()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if (e.getCause() instanceof JavaModelException) { | ||
throw (JavaModelException) e.getCause(); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
if (RefactoringAvailabilityTester.isMoveAvailable(new IResource[0], javaElements)) { | ||
return manager.createMoveRefactoringSession(javaElements); | ||
String moveRefactoringSession = manager.createMoveRefactoringSession(javaElements); | ||
LOG.info( | ||
"createMoveRefactoring finished in " | ||
+ System.currentTimeMillis() | ||
+ " ms with session id " | ||
+ moveRefactoringSession); | ||
return moveRefactoringSession; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
LOG.error( | ||
"createMoveRefactoring finished in " | ||
+ System.currentTimeMillis() | ||
+ " ms with with RefactoringException"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
throw new RefactoringException("Can't create move refactoring."); | ||
} | ||
|
||
|
@@ -238,6 +260,11 @@ public RefactoringResult applyRefactoring(RefactoringSession session) | |
@Consumes("application/json") | ||
public RenameRefactoringSession createRenameRefactoring(CreateRenameRefactoring settings) | ||
throws CoreException, RefactoringException { | ||
LOG.info( | ||
"createRenameRefactoring started in " | ||
+ System.currentTimeMillis() | ||
+ " ms with " | ||
+ settings.toString()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
IJavaProject javaProject = model.getJavaProject(settings.getProjectPath()); | ||
IJavaElement elementToRename; | ||
ICompilationUnit cu = null; | ||
|
@@ -257,11 +284,22 @@ public RenameRefactoringSession createRenameRefactoring(CreateRenameRefactoring | |
elementToRename = null; | ||
} | ||
if (elementToRename == null) { | ||
LOG.error( | ||
"createRenameRefactoring fail in " | ||
+ System.currentTimeMillis() | ||
+ " ms with RefactoringException: Can't find java element to rename. "); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
throw new RefactoringException("Can't find java element to rename."); | ||
} | ||
|
||
return manager.createRenameRefactoring( | ||
elementToRename, cu, settings.getOffset(), settings.isRefactorLightweight()); | ||
RenameRefactoringSession renameRefactoring = | ||
manager.createRenameRefactoring( | ||
elementToRename, cu, settings.getOffset(), settings.isRefactorLightweight()); | ||
LOG.info( | ||
"createRenameRefactoring finished in " | ||
+ System.currentTimeMillis() | ||
+ " ms with " | ||
+ renameRefactoring.toString()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return renameRefactoring; | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -255,7 +255,8 @@ private RemoteWebDriver doCreateDriver(URL webDriverUrl) { | |
switch (browser) { | ||
case GOOGLE_CHROME: | ||
LoggingPreferences loggingPreferences = new LoggingPreferences(); | ||
loggingPreferences.enable(LogType.BROWSER, Level.SEVERE); | ||
loggingPreferences.enable(LogType.PERFORMANCE, Level.ALL); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was used because only browser errors have useful information for us. But it only in case for browser's console output. In other cases (for example "Networking"), logs of other levels may be useful. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ALL levels log also can have important info |
||
loggingPreferences.enable(LogType.BROWSER, Level.ALL); | ||
|
||
ChromeOptions options = new ChromeOptions(); | ||
options.addArguments("--no-sandbox"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use please LOG.info("createMoveRefactoring started in {} " ms with " {}", System.currentTimeMillis(), cmr.toString())