com.amazonaws.services.devicefarm.model.Upload Java Examples
The following examples show how to use
com.amazonaws.services.devicefarm.model.Upload.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeviceFarmUploader.java From aws-device-farm-gradle-plugin with Apache License 2.0 | 6 votes |
private void waitForUpload(final File file, final Upload upload) { while (true) { GetUploadRequest describeUploadRequest = new GetUploadRequest() .withArn(upload.getArn()); GetUploadResult describeUploadResult = api.getUpload(describeUploadRequest); String status = describeUploadResult.getUpload().getStatus(); if ("SUCCEEDED".equalsIgnoreCase(status)) { break; } else if ("FAILED".equalsIgnoreCase(status)) { throw new DeviceFarmException(String.format("Upload %s failed!", upload.getName())); } else { try { writeToLog(String.format("Waiting for upload %s to be ready (current status: %s)", file.getName(), status)); Thread.sleep(5000); } catch (InterruptedException e) { break; } } } }
Example #2
Source File: DeviceFarmServer.java From aws-device-farm-gradle-plugin with Apache License 2.0 | 6 votes |
private Collection<Upload> uploadAuxApps(final Project project) { final Collection<Upload> auxApps = uploader.batchUpload(extension.getDeviceState().getAuxiliaryApps(), project, UploadType.ANDROID_APP); if (auxApps == null || auxApps.size() == 0) { return null; } for (Upload auxApp : auxApps) { logger.lifecycle(String.format("Will install additional app %s, %s", auxApp.getName(), auxApp.getArn())); } return auxApps; }
Example #3
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 6 votes |
/** * Get Device Farm uploads for a given Device Farm project. * * @param project * Device Farm Project. * @return A List of the Device Farm uploads. * @throws AWSDeviceFarmException */ public List<Upload> getUploads(Project project) { List<Upload> uploads = new ArrayList<Upload>(); ListUploadsResult result = api.listUploads(new ListUploadsRequest().withArn(project.getArn())); uploads.addAll(result.getUploads()); while (result.getNextToken() != null) { ListUploadsRequest request = new ListUploadsRequest(); request.setArn(project.getArn()); request.setNextToken(result.getNextToken()); result = api.listUploads(request); uploads.addAll(result.getUploads()); } return uploads; }
Example #4
Source File: AWSDeviceFarmRecorder.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 6 votes |
/** * Get all TestSpecs for the selected project and store them * in a local cache. * * @param projectName The name of the currently selected project. * @return The List of device pool names associated with that project. */ private synchronized List<String> getAWSDeviceFarmTestSpec(String projectName) { testSpecCache.clear(); List<String> testSpecNames = testSpecCache.get(projectName); if (testSpecNames == null || testSpecNames.isEmpty()) { AWSDeviceFarm adf = getAWSDeviceFarm(); try { List<Upload> testSpecFiles = adf.getTestSpecs(projectName); testSpecNames = new ArrayList<String>(); for (Upload testSpec : testSpecFiles) { testSpecNames.add(testSpec.getName()); } Collections.sort(testSpecNames, String.CASE_INSENSITIVE_ORDER); } catch (AWSDeviceFarmException e) { } testSpecCache.put(projectName, testSpecNames); } return testSpecNames; }
Example #5
Source File: DeviceFarmUtils.java From aws-device-farm-gradle-plugin with Apache License 2.0 | 5 votes |
/** * Get Device Farm TestSpecs for a given Device Farm project. * * @param project Device Farm Project. * @return A List of the Device Farm TestSpecs. */ public List<Upload> getTestSpecs(Project project) { List<Upload> allUploads = getUploads(project); List<Upload> testSpecUploads = new ArrayList<Upload>(); for (Upload upload : allUploads) { if (upload.getType().contains("TEST_SPEC") && UploadStatus.SUCCEEDED.toString().equals(upload.getStatus())) { testSpecUploads.add(upload); } } return testSpecUploads; }
Example #6
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 5 votes |
/** * Private method to handle uploading apps and tests to Device Farm. * * @param project The Device Farm project to upload to. * @param artifact Possibly glob-y path to the file to be uploaded. * @param uploadType The type of upload (app/test/etc.). * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ private Upload upload(Project project, String artifact, AWSDeviceFarmUploadType uploadType) throws InterruptedException, IOException, AWSDeviceFarmException { if (artifact == null || artifact.isEmpty()) { throw new AWSDeviceFarmException("Must have an artifact path."); } File file = getArtifactFile(env.expand(artifact)); if (file == null || !file.exists()) { throw new AWSDeviceFarmException(String.format("File artifact %s not found.", artifact)); } return upload(file, project, uploadType); }
Example #7
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 5 votes |
/** * Upload an extra data file to Device Farm. * * @param project The Device Farm project to upload to. * @param extraDataArtifact String path to the extra data to be uploaded to Device Farm. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadExtraData(Project project, String extraDataArtifact) throws InterruptedException, IOException, AWSDeviceFarmException { AWSDeviceFarmUploadType type; if (extraDataArtifact.toLowerCase().endsWith("zip")) { type = AWSDeviceFarmUploadType.EXTERNAL_DATA; } else { throw new AWSDeviceFarmException(String.format("Unknown extra data file artifact to upload: %s", extraDataArtifact)); } return upload(project, extraDataArtifact, type); }
Example #8
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 5 votes |
/** * Upload an app to Device Farm to be tested. * * @param project The Device Farm project to upload to. * @param appArtifact String path to the app to be uploaded to Device Farm. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadApp(Project project, String appArtifact) throws InterruptedException, IOException, AWSDeviceFarmException { AWSDeviceFarmUploadType type; if (appArtifact.toLowerCase().endsWith("apk")) { type = AWSDeviceFarmUploadType.ANDROID_APP; } else if (appArtifact.toLowerCase().endsWith("ipa") || appArtifact.toLowerCase().endsWith("zip")) { type = AWSDeviceFarmUploadType.IOS_APP; } else { throw new AWSDeviceFarmException(String.format("Unknown app artifact to upload: %s", appArtifact)); } return upload(project, appArtifact, type); }
Example #9
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 5 votes |
/** * Get Device Farm TestSpec by Device Farm project and TestSpec name. * * @param project The Device Farm project. * @param testSpecName String name of the Device Farm testSpec. * @return The TestSpec. * @throws AWSDeviceFarmException */ public Upload getTestSpec(Project project, String testSpecName) throws AWSDeviceFarmException { List<Upload> testSpecUploads = getTestSpecs(project); for (Upload upload : testSpecUploads) { if (upload.getName().equals(testSpecName)) { return upload; } } throw new AWSDeviceFarmException(String.format("TestSpec '%s' not found.", testSpecName)); }
Example #10
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 5 votes |
/** * Helper function to detect a default testspec file for frameworks that cannot use it. * * @param testSpec the testspec file to check * * @return true if it is a default spec file. * @throws AWSDeviceFarmException */ public Boolean isRestrictedDefaultSpec(Upload testSpec) { if (testSpec != null) { if ((APPIUM_RUBY_TEST_SPEC.equals(testSpec.getType()) || APPIUM_NODE_TEST_SPEC.equals(testSpec.getType()) || APPIUM_WEB_RUBY_TEST_SPEC.equals(testSpec.getType()) || APPIUM_WEB_NODE_TEST_SPEC.equals(testSpec.getType())) && (CURATED.equals(testSpec.getCategory()))) { return true; } } return false; }
Example #11
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 5 votes |
/** * Get Device Farm TestSpecs for a given Device Farm project. * * @param project Device Farm Project. * @return A List of the Device Farm TestSpecs. * @throws AWSDeviceFarmException */ public List<Upload> getTestSpecs(Project project) throws AWSDeviceFarmException { List<Upload> allUploads = getUploads(project); List<Upload> testSpecUploads = new ArrayList<Upload>(); for (Upload upload : allUploads) { if (upload.getType().contains("TEST_SPEC") && UploadStatus.SUCCEEDED.toString().equals(upload.getStatus()) && !isRestrictedDefaultSpec(upload)) { testSpecUploads.add(upload); } } return testSpecUploads; }
Example #12
Source File: DeviceFarmUtils.java From aws-device-farm-gradle-plugin with Apache License 2.0 | 5 votes |
/** * Get Device Farm uploads for a given Device Farm project. * * @param project * Device Farm Project. * @return A List of the Device Farm uploads. */ public List<Upload> getUploads(Project project) { List<Upload> uploads = new ArrayList<Upload>(); ListUploadsResult result = api.listUploads(new ListUploadsRequest().withArn(project.getArn())); uploads.addAll(result.getUploads()); while (result.getNextToken() != null) { ListUploadsRequest request = new ListUploadsRequest(); request.setNextToken(result.getNextToken()); result = api.listUploads(request); uploads.addAll(result.getUploads()); } return uploads; }
Example #13
Source File: DeviceFarmServer.java From aws-device-farm-gradle-plugin with Apache License 2.0 | 5 votes |
private List<String> getAuxAppArns(Collection<Upload> auxUploads) { List<String> auxAppArns = Lists.newArrayList(); if (auxUploads == null || auxUploads.size() == 0) { return auxAppArns; } for (Upload auxApp : auxUploads) { auxAppArns.add(auxApp.getArn()); } return auxAppArns; }
Example #14
Source File: DeviceFarmUploader.java From aws-device-farm-gradle-plugin with Apache License 2.0 | 5 votes |
public Collection<Upload> batchUpload(final List<File> artifacts, final Project project, final UploadType uploadType) { List<Future<Upload>> futures = Lists.newArrayList(); // Upload each artifact and create a future for it. for (final File file : artifacts) { futures.add(uploadExecutor.submit( new Callable<Upload>() { @Override public Upload call() throws Exception { return upload(file, project, uploadType); } } )); } List<Upload> uploads = Lists.newArrayList(); // Check future results and append the upload results to a list. for (Future<Upload> f : futures) { try { uploads.add(f.get()); } catch (Exception e) { throw new DeviceFarmException(e); } } return uploads; }
Example #15
Source File: DeviceFarmUtils.java From aws-device-farm-gradle-plugin with Apache License 2.0 | 5 votes |
/** * Get Device Farm testSpec by name. * * @param testSpecName String name of the Device Farm testSpec. * @param project Device Farm project * @return The Device Farm project. */ public Upload findTestSpecByName(final String testSpecName, Project project) { if (StringUtils.isBlank(testSpecName)) { return null; } for (Upload upload : getTestSpecs(project)) { if (upload.getName().equals(testSpecName)) { return upload; } } throw new DeviceFarmException(String.format("testSpec '%s' not found.", testSpecName)); }
Example #16
Source File: DeviceFarmServer.java From aws-device-farm-gradle-plugin with Apache License 2.0 | 4 votes |
/** * Upload and test the newly built apk. * * @param variantName variant of the latest build. Ex: 'debug' * @param testPackage File object to the newly built APK which contains tests * @param testedApk File object to the newly built application APK */ @Override public void uploadApks(final String variantName, final File testPackage, final File testedApk) { final Project project = utils.findProjectByName(extension.getProjectName()); logger.lifecycle(String.format("Using Project \"%s\", \"%s\"", project.getName(), project.getArn())); final DevicePool devicePool = utils.findDevicePoolByName(project, extension.getDevicePool()); logger.lifecycle(String.format("Using Device Pool \"%s\", \"%s\"", devicePool.getName(), devicePool.getArn())); final String appArn = uploader.upload(testedApk == null ? testPackage : testedApk, project, UploadType.ANDROID_APP).getArn(); logger.lifecycle(String.format("Will test app in \"%s\", \"%s\"", testedApk == null ? testPackage.getName() : testedApk.getName(), appArn)); final Collection<Upload> auxApps = uploadAuxApps(project); final String extraDataArn = uploadExtraDataZip(project); // For few frameworks , you can specify a testSpec final Upload testSpec = utils.findTestSpecByName(extension.getTest().getTestSpecName(), project); if (testSpec != null) { logger.lifecycle(String.format("Using TestSpec \"%s\", \"%s\"", testSpec.getName(), testSpec.getArn())); } final ScheduleRunTest runTest = new ScheduleRunTest() .withParameters(extension.getTest().getTestParameters()) .withType(extension.getTest().getTestType()) .withFilter(extension.getTest().getFilter()) .withTestPackageArn(uploadTestPackageIfNeeded(project, testPackage)) .withTestSpecArn(testSpec == null ? null: testSpec.getArn()); runTest.addParametersEntry(RUNPARAM_APP_PERF_MONITORING, Boolean.toString(extension.getPerformanceMonitoring())); final ExecutionConfiguration executionConfiguration = new ExecutionConfiguration() .withJobTimeoutMinutes(extension.getExecutionTimeoutMinutes()) .withVideoCapture(extension.getVideoRecording()); final ScheduleRunConfiguration configuration = new ScheduleRunConfiguration() .withAuxiliaryApps(getAuxAppArns(auxApps)) .withExtraDataPackageArn(extraDataArn) .withLocale(extension.getDeviceState().getLocale().toString()) .withLocation(extension.getDeviceState().getLocation()) .withBillingMethod(extension.isMetered() ? BillingMethod.METERED : BillingMethod.UNMETERED) .withRadios(extension.getDeviceState().getRadios()); final ScheduleRunRequest request = new ScheduleRunRequest() .withAppArn(appArn) .withConfiguration(configuration) .withDevicePoolArn(devicePool.getArn()) .withProjectArn(project.getArn()) .withTest(runTest) .withExecutionConfiguration(executionConfiguration) .withName(String.format("%s (Gradle)", testedApk == null ? testPackage.getName() : testedApk.getName())); final ScheduleRunResult response = api.scheduleRun(request); logger.lifecycle(String.format("View the %s run in the AWS Device Farm Console: %s", runTest.getType(), utils.getRunUrlFromArn(response.getRun().getArn()))); }
Example #17
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Private method to handle uploading apps and tests to Device Farm. * * @param file The file to upload. * @param project The Device Farm project to upload to. * @param uploadType The type of upload (app/test/etc.). * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ private Upload upload(File file, Project project, AWSDeviceFarmUploadType uploadType) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(file, project, uploadType, true); }
Example #18
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, AppiumWebNodeTest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.APPIUM_WEB_NODE); }
Example #19
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, AppiumWebRubyTest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.APPIUM_WEB_RUBY); }
Example #20
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, AppiumWebPythonTest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.APPIUM_WEB_PYTHON); }
Example #21
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, AppiumWebJavaJUnitTest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.APPIUM_WEB_JAVA_JUNIT); }
Example #22
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, AppiumWebJavaTestNGTest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.APPIUM_WEB_JAVA_TESTNG); }
Example #23
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, AppiumNodeTest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.APPIUM_NODE); }
Example #24
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, AppiumRubyTest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.APPIUM_RUBY); }
Example #25
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, AppiumPythonTest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.APPIUM_PYTHON); }
Example #26
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, AppiumJavaJUnitTest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.APPIUM_JAVA_JUNIT); }
Example #27
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, AppiumJavaTestNGTest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.APPIUM_JAVA_TESTNG); }
Example #28
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, XCTestUITest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.XCTEST_UI); }
Example #29
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, XCTestTest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.XCTEST); }
Example #30
Source File: AWSDeviceFarm.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 2 votes |
/** * Upload a test to Device Farm. * * @param project The Device Farm project to upload to. * @param test Test object containing relevant test information. * @return The Device Farm Upload object. * @throws IOException * @throws AWSDeviceFarmException */ public Upload uploadTest(Project project, UIAutomationTest test) throws InterruptedException, IOException, AWSDeviceFarmException { return upload(project, test.getTests(), AWSDeviceFarmUploadType.UIAUTOMATION); }