summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStas Negara <snegara@google.com>2015-05-08 13:22:43 -0700
committerStas Negara <snegara@google.com>2015-05-08 13:27:58 -0700
commita32ddf669ab4b4e132170dee8b4975dd2fa5b558 (patch)
treeab7ef274a0e6b7922e803b9594ed6ebda7306934
parente58e92dade0f641c11f9afc8b522b524a579a57d (diff)
downloadtesting-a32ddf669ab4b4e132170dee8b4975dd2fa5b558.tar.gz
Stop sending history id.
Also, support new states for matrix and individual executions. Change-Id: Id213bcd2b86933c0d2610b45ce333cdce1d689e0
-rw-r--r--google-cloud-testing.iml4
-rw-r--r--lib/google-api-services-testing-v1-rev20150305-1.20.0.jarbin0 -> 84058 bytes
-rw-r--r--lib/google-api-services-testing-v1-rev20150323-1.20.0.jarbin75013 -> 0 bytes
-rw-r--r--src/com/google/gct/testing/CloudConfigurationProviderImpl.java23
-rw-r--r--src/com/google/gct/testing/CloudResultsAdapter.java9
-rw-r--r--src/com/google/gct/testing/CloudResultsLoader.java101
-rw-r--r--src/com/google/gct/testing/launcher/CloudTestsLauncher.java32
7 files changed, 89 insertions, 80 deletions
diff --git a/google-cloud-testing.iml b/google-cloud-testing.iml
index 03b96e1..74ce3f2 100644
--- a/google-cloud-testing.iml
+++ b/google-cloud-testing.iml
@@ -54,11 +54,11 @@
<orderEntry type="module-library">
<library>
<CLASSES>
- <root url="jar://$MODULE_DIR$/lib/google-api-services-testing-v1-rev20150323-1.20.0.jar!/" />
+ <root url="jar://$MODULE_DIR$/lib/google-api-services-testing-v1-rev20150305-1.20.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
-</module> \ No newline at end of file
+</module>
diff --git a/lib/google-api-services-testing-v1-rev20150305-1.20.0.jar b/lib/google-api-services-testing-v1-rev20150305-1.20.0.jar
new file mode 100644
index 0000000..f6f0770
--- /dev/null
+++ b/lib/google-api-services-testing-v1-rev20150305-1.20.0.jar
Binary files differ
diff --git a/lib/google-api-services-testing-v1-rev20150323-1.20.0.jar b/lib/google-api-services-testing-v1-rev20150323-1.20.0.jar
deleted file mode 100644
index 26f6c92..0000000
--- a/lib/google-api-services-testing-v1-rev20150323-1.20.0.jar
+++ /dev/null
Binary files differ
diff --git a/src/com/google/gct/testing/CloudConfigurationProviderImpl.java b/src/com/google/gct/testing/CloudConfigurationProviderImpl.java
index 4ca8a21..64a206f 100644
--- a/src/com/google/gct/testing/CloudConfigurationProviderImpl.java
+++ b/src/com/google/gct/testing/CloudConfigurationProviderImpl.java
@@ -28,7 +28,6 @@ import com.google.api.services.storage.model.Buckets;
import com.google.api.services.storage.model.StorageObject;
import com.google.api.services.testing.model.AndroidDevice;
import com.google.api.services.testing.model.Device;
-import com.google.api.services.testing.model.ResultStorage;
import com.google.api.services.testing.model.TestMatrix;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
@@ -69,7 +68,6 @@ import java.util.*;
import static com.android.tools.idea.run.CloudConfiguration.Kind.MATRIX;
import static com.android.tools.idea.run.CloudConfiguration.Kind.SINGLE_DEVICE;
-import static com.google.gct.testing.launcher.CloudAuthenticator.getStorage;
import static com.google.gct.testing.launcher.CloudAuthenticator.getTest;
public class CloudConfigurationProviderImpl extends CloudConfigurationProvider {
@@ -452,8 +450,8 @@ public class CloudConfigurationProviderImpl extends CloudConfigurationProvider {
else {
String testRunId = TEST_RUN_ID_PREFIX + googleCloudTestingDeveloperState.fakeBucketName + System.currentTimeMillis();
CloudResultsAdapter cloudResultsAdapter =
- new CloudResultsAdapter(cloudProjectId, googleCloudTestingDeveloperState.fakeBucketName, cloudResultParser,
- expectedConfigurationInstances, testRunId, null, null);
+ new CloudResultsAdapter(cloudProjectId, googleCloudTestingDeveloperState.fakeBucketName, runningState.getProcessHandler(),
+ cloudResultParser, expectedConfigurationInstances, testRunId, null, null);
addCloudConfiguration(testRunId, cloudConfiguration);
addCloudResultsAdapter(testRunId, cloudResultsAdapter);
cloudResultsAdapter.startPolling();
@@ -535,7 +533,7 @@ public class CloudConfigurationProviderImpl extends CloudConfigurationProvider {
if (matrixExecutionCancellator.isCancelled()) {
return;
}
- runningState.getProcessHandler().notifyTextAvailable(prepareProgressString("Invoking cloud test API...", "\n"),
+ runningState.getProcessHandler().notifyTextAvailable(prepareProgressString("Invoking cloud test API...", ""),
ProcessOutputTypes.STDOUT);
String testSpecification = CloudTestingUtils.prepareTestSpecification(testRunConfiguration);
@@ -545,15 +543,14 @@ public class CloudConfigurationProviderImpl extends CloudConfigurationProvider {
cloudTestingConfiguration, appPackage, testPackage);
if (testMatrix != null) {
- runningState.getProcessHandler().notifyTextAvailable(
- "You can also view test results, along with other runs against this app, on the web:\n"
- + getTuxLink(cloudProjectId, testMatrix.getResultStorage()) + " \n\n\n", ProcessOutputTypes.STDOUT);
+ runningState.getProcessHandler().notifyTextAvailable(prepareProgressString("Validating APKs...", "\n\n"),
+ ProcessOutputTypes.STDOUT);
matrixExecutionCancellator.setCloudProjectId(cloudProjectId);
matrixExecutionCancellator.setTestMatrixId(testMatrix.getTestMatrixId());
String testRunId = TEST_RUN_ID_PREFIX + bucketName;
CloudResultsAdapter cloudResultsAdapter =
- new CloudResultsAdapter(cloudProjectId, bucketName, cloudResultParser, expectedConfigurationInstances, testRunId, testMatrix,
- matrixExecutionCancellator);
+ new CloudResultsAdapter(cloudProjectId, bucketName, runningState.getProcessHandler(), cloudResultParser,
+ expectedConfigurationInstances, testRunId, testMatrix, matrixExecutionCancellator);
addCloudConfiguration(testRunId, cloudTestingConfiguration);
addCloudResultsAdapter(testRunId, cloudResultsAdapter);
cloudResultsAdapter.startPolling();
@@ -569,12 +566,6 @@ public class CloudConfigurationProviderImpl extends CloudConfigurationProvider {
}
}
- private static String getTuxLink(String cloudProjectId, ResultStorage resultStorage) {
- return "https://console.developers.google.com/project/" + cloudProjectId
- + "/clouddev/toolresults/histories/" + resultStorage.getToolResultsHistoryId()
- + "/executions/" + resultStorage.getToolResultsExecutionId();
- }
-
private String listAllApks(List<String> apkPaths) {
List<String> allApks = new ArrayList<String>();
for (String apkPath : apkPaths) {
diff --git a/src/com/google/gct/testing/CloudResultsAdapter.java b/src/com/google/gct/testing/CloudResultsAdapter.java
index 99b27c3..e28cb49 100644
--- a/src/com/google/gct/testing/CloudResultsAdapter.java
+++ b/src/com/google/gct/testing/CloudResultsAdapter.java
@@ -20,6 +20,7 @@ import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.gct.testing.results.GoogleCloudTestingResultParser;
+import com.intellij.execution.process.ProcessHandler;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -43,11 +44,11 @@ public class CloudResultsAdapter {
private final PollingTicker pollingTicker;
- public CloudResultsAdapter(String cloudProjectId, String bucketName, GoogleCloudTestingResultParser resultParser,
- List<String> expectedConfigurationInstances, String testRunId, @Nullable TestMatrix testMatrix,
- @Nullable CloudMatrixExecutionCancellator matrixExecutionCancellator) {
+ public CloudResultsAdapter(String cloudProjectId, String bucketName, ProcessHandler processHandler,
+ GoogleCloudTestingResultParser resultParser, List<String> expectedConfigurationInstances, String testRunId,
+ @Nullable TestMatrix testMatrix, @Nullable CloudMatrixExecutionCancellator matrixExecutionCancellator) {
this.cloudProjectId = cloudProjectId;
- loader = new CloudResultsLoader(cloudProjectId, resultParser.getTestRunListener(), bucketName, testMatrix);
+ loader = new CloudResultsLoader(cloudProjectId, resultParser.getTestRunListener(), processHandler, bucketName, testMatrix);
this.resultParser = resultParser;
this.expectedConfigurationInstances = expectedConfigurationInstances;
pollingTicker = new PollingTicker(matrixExecutionCancellator);
diff --git a/src/com/google/gct/testing/CloudResultsLoader.java b/src/com/google/gct/testing/CloudResultsLoader.java
index b20b2ec..95669cd 100644
--- a/src/com/google/gct/testing/CloudResultsLoader.java
+++ b/src/com/google/gct/testing/CloudResultsLoader.java
@@ -19,6 +19,7 @@ import com.google.api.client.http.HttpHeaders;
import com.google.api.services.storage.Storage;
import com.google.api.services.storage.model.StorageObject;
import com.google.api.services.testing.model.AndroidDevice;
+import com.google.api.services.testing.model.ResultStorage;
import com.google.api.services.testing.model.TestExecution;
import com.google.api.services.testing.model.TestMatrix;
import com.google.common.base.Function;
@@ -28,6 +29,8 @@ import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.gct.testing.results.IGoogleCloudTestRunListener;
+import com.intellij.execution.process.ProcessHandler;
+import com.intellij.execution.process.ProcessOutputTypes;
import org.jetbrains.annotations.NotNull;
import java.io.ByteArrayOutputStream;
@@ -89,20 +92,24 @@ public class CloudResultsLoader {
private final String cloudProjectId;
private final IGoogleCloudTestRunListener testRunListener;
+ private final ProcessHandler processHandler;
private final String bucketName;
private final String testMatrixId;
private final Set<String> allConfigurationInstances = new HashSet<String>();
private final Set<String> finishedConfigurationInstances = new HashSet<String>();
private long loadedScreenshotSize = 0;
private int consecutivePollFailuresCount = 0;
+ private boolean webLinkReported = false;
// Encoded configuration instance -> progress accumulated so far.
private final Map<String, String> configurationProgress = new HashMap<String, String>();
- public CloudResultsLoader(String cloudProjectId, IGoogleCloudTestRunListener testRunListener, String bucketName, TestMatrix testMatrix) {
+ public CloudResultsLoader(String cloudProjectId, IGoogleCloudTestRunListener testRunListener, ProcessHandler processHandler,
+ String bucketName, TestMatrix testMatrix) {
this.cloudProjectId = cloudProjectId;
this.testRunListener = testRunListener;
+ this.processHandler = processHandler;
this.bucketName = bucketName;
// testMatrix is null for runs with a fake bucket.
if (testMatrix != null) {
@@ -211,44 +218,76 @@ public class CloudResultsLoader {
}
private void updateResultsFromTestMatrix(Map<String, ConfigurationResult> results, @NotNull TestMatrix testMatrix) {
- for (TestExecution testExecution : testMatrix.getTestExecutions()) {
- String encodedConfigurationInstance = getEncodedConfigurationNameForTestExecution(testExecution);
- if (finishedConfigurationInstances.contains(encodedConfigurationInstance)) {
- continue;
+ String testMatrixState = testMatrix.getState();
+ if (testMatrixState.equals("VALIDATING")) {
+ return;
+ }
+ if (!webLinkReported) {
+ webLinkReported = true;
+ if (!testMatrixState.equals("INVALID")) {
+ processHandler.notifyTextAvailable("You can also view test results, along with other runs against this app, on the web:\n" +
+ getTuxLink(cloudProjectId, testMatrix.getResultStorage()) + " \n\n\n",
+ ProcessOutputTypes.STDOUT);
}
- String testExecutionState = testExecution.getState();
- if (testExecutionState.equals("UNSUPPORTED_ENVIRONMENT")) {
- String diffProgress = "Skipped triggering the test execution: Incompatible API level for requested model\n";
- // Probably, no previous progress could be expected in this scenario, but it would not hurt considering it anyway.
+ }
+ for (TestExecution testExecution : testMatrix.getTestExecutions()) {
+ updateResultsFromTestExecution(results, testExecution);
+ }
+ }
+
+ private void updateResultsFromTestExecution(Map<String, ConfigurationResult> results, TestExecution testExecution) {
+ String encodedConfigurationInstance = getEncodedConfigurationNameForTestExecution(testExecution);
+ if (finishedConfigurationInstances.contains(encodedConfigurationInstance)) {
+ return;
+ }
+ String testExecutionState = testExecution.getState();
+ if (testExecutionState.equals("UNSUPPORTED_ENVIRONMENT")) {
+ handleTriggeringError(results, encodedConfigurationInstance,
+ "Skipped triggering the test execution: Incompatible API level for requested model\n");
+ } else if (testExecutionState.equals("INCOMPATIBLE_ENVIRONMENT")) {
+ // It is not expected to happen for Android Studio client.
+ handleTriggeringError(results, encodedConfigurationInstance, "The given APK is not compatible with this configuration\n");
+ } else if (testExecutionState.equals("INVALID")) {
+ // It is not expected to happen for Android Studio client.
+ handleTriggeringError(results, encodedConfigurationInstance, "The provided APK is invalid\n");
+ } else if (!testExecutionState.equals("QUEUED")) {
+ if (testExecutionState.equals("ERROR")) {
+ String diffProgress = INFRASTRUCTURE_FAILURE_PREFIX + " " + testExecution.getTestDetails().getErrorDetails() + "\n";
String previousProgress = getPreviousProgress(encodedConfigurationInstance);
- reportNewProgress(encodedConfigurationInstance, previousProgress, previousProgress + diffProgress);
- ConfigurationResult result = getOrCreateConfigurationResult(encodedConfigurationInstance, results);
- result.setTriggeringError(true);
- finishedConfigurationInstances.add(encodedConfigurationInstance);
- } else if (!testExecutionState.equals("QUEUED")) {
- if (testExecutionState.equals("ERROR")) {
- String diffProgress = INFRASTRUCTURE_FAILURE_PREFIX + " " + testExecution.getTestDetails().getErrorDetails() + "\n";
- String previousProgress = getPreviousProgress(encodedConfigurationInstance);
- if (!previousProgress.endsWith(diffProgress)) {
- reportNewProgress(encodedConfigurationInstance, previousProgress, previousProgress + diffProgress);
- }
- } else if (testExecutionState.equals("IN_PROGRESS")) {
- String newProgress = testExecution.getTestDetails().getProgressDetails();
- String previousProgress = getPreviousProgress(encodedConfigurationInstance);
- if (newProgress != null && !newProgress.equals(previousProgress)) {
- reportNewProgress(encodedConfigurationInstance, previousProgress, newProgress);
- }
+ if (!previousProgress.endsWith(diffProgress)) {
+ reportNewProgress(encodedConfigurationInstance, previousProgress, previousProgress + diffProgress);
}
- ConfigurationResult result = getOrCreateConfigurationResult(encodedConfigurationInstance, results);
- result.setComplete(testExecutionState.equals("FINISHED"));
- result.setInfrastructureFailure(isInfrastructureFailure(getPreviousProgress(encodedConfigurationInstance)));
- if (result.isNoProgressExpected()) {
- finishedConfigurationInstances.add(encodedConfigurationInstance);
+ } else if (testExecutionState.equals("IN_PROGRESS")) {
+ String newProgress = testExecution.getTestDetails().getProgressDetails();
+ String previousProgress = getPreviousProgress(encodedConfigurationInstance);
+ if (newProgress != null && !newProgress.equals(previousProgress)) {
+ reportNewProgress(encodedConfigurationInstance, previousProgress, newProgress);
}
}
+ ConfigurationResult result = getOrCreateConfigurationResult(encodedConfigurationInstance, results);
+ result.setComplete(testExecutionState.equals("FINISHED"));
+ result.setInfrastructureFailure(isInfrastructureFailure(getPreviousProgress(encodedConfigurationInstance)));
+ if (result.isNoProgressExpected()) {
+ finishedConfigurationInstances.add(encodedConfigurationInstance);
+ }
}
}
+ private void handleTriggeringError(Map<String, ConfigurationResult> results, String encodedConfigurationInstance, String diffProgress) {
+ // Probably, no previous progress could be expected in this scenario, but it would not hurt considering it anyway.
+ String previousProgress = getPreviousProgress(encodedConfigurationInstance);
+ reportNewProgress(encodedConfigurationInstance, previousProgress, previousProgress + diffProgress);
+ ConfigurationResult result = getOrCreateConfigurationResult(encodedConfigurationInstance, results);
+ result.setTriggeringError(true);
+ finishedConfigurationInstances.add(encodedConfigurationInstance);
+ }
+
+ private static String getTuxLink(String cloudProjectId, ResultStorage resultStorage) {
+ return "https://console.developers.google.com/project/" + cloudProjectId
+ + "/clouddev/toolresults/histories/" + resultStorage.getToolResultsHistoryId()
+ + "/executions/" + resultStorage.getToolResultsExecutionId();
+ }
+
private String getEncodedConfigurationNameForTestExecution(TestExecution testExecution) {
AndroidDevice androidDevice = testExecution.getEnvironment().getAndroidDevice();
return androidDevice.getAndroidModelId() + ConfigurationInstance.ENCODED_NAME_DELIMITER
diff --git a/src/com/google/gct/testing/launcher/CloudTestsLauncher.java b/src/com/google/gct/testing/launcher/CloudTestsLauncher.java
index cdfc7ad..1b4c091 100644
--- a/src/com/google/gct/testing/launcher/CloudTestsLauncher.java
+++ b/src/com/google/gct/testing/launcher/CloudTestsLauncher.java
@@ -20,7 +20,6 @@ import com.google.api.services.storage.Storage;
import com.google.api.services.storage.model.Bucket;
import com.google.api.services.storage.model.StorageObject;
import com.google.api.services.testing.model.*;
-import com.google.api.services.toolresults.model.History;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.gct.testing.CloudConfigurationImpl;
@@ -41,7 +40,8 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import static com.google.gct.testing.launcher.CloudAuthenticator.*;
+import static com.google.gct.testing.launcher.CloudAuthenticator.getStorage;
+import static com.google.gct.testing.launcher.CloudAuthenticator.getTest;
public class CloudTestsLauncher {
@@ -118,13 +118,14 @@ public class CloudTestsLauncher {
TestMatrix testMatrix = new TestMatrix();
+ testMatrix.setClientInfo(new ClientInfo().setName("Android Studio"));
+
testMatrix.setTestSpecification(new TestSpecification().setAndroidInstrumentationTest(
new AndroidInstrumentationTest().setAppApk(new FileReference().setGcsPath(appApkGcsPath))
.setTestApk(new FileReference().setGcsPath(testApkGcsPath)).setAppPackageId(appPackage).setTestPackageId(testPackage)
.setTestRunnerClass(instrumentationTestRunner).setTestTargets(Lists.newArrayList(testSpecification))));
- testMatrix.setResultStorage(new ResultStorage().setGoogleCloudStorage(new GoogleCloudStorage().setGcsPath(bucketGcsPath))
- .setToolResultsHistoryId(getHistoryId(cloudProjectId, appPackage)));
+ testMatrix.setResultStorage(new ResultStorage().setGoogleCloudStorage(new GoogleCloudStorage().setGcsPath(bucketGcsPath)));
AndroidMatrix androidMatrix = new AndroidMatrix();
@@ -153,29 +154,6 @@ public class CloudTestsLauncher {
return triggeredTestMatrix;
}
- private static String getHistoryId(String cloudProjectId, String applicationName) {
- String historyName = applicationName + " (Android Studio)";
- try {
- List<History> histories =
- getToolresults().projects().histories().list(cloudProjectId).setFilterByDisplayName(historyName).execute().getHistories();
- if (histories != null && !histories.isEmpty()) {
- return histories.get(0).getHistoryId();
- }
- } catch (Exception e) {
- // Ignore, just create a new history.
- }
- try {
- return getToolresults().projects().histories().create(cloudProjectId,
- new History().setDisplayName(historyName)).execute().getHistoryId();
- }
- catch (Exception e) {
- CloudTestingUtils.showErrorMessage(null, "Error creating history id", "Failed to create history id for test execution!\n" +
- "Exception while creating a test execution history id\n\n" +
- e.getMessage());
- return "";
- }
- }
-
/**
* Not used, left as an example.
*/