Exemplo n.º 1
0
        private string UploadApplication(string projectArn, string applicationLocation, UploadType uploadType)
        {
            string applicationName = Path.GetFileName(applicationLocation);
            var    uploadResponse  = DFClient.CreateUpload(new CreateUploadRequest()
            {
                Name        = applicationName,
                ProjectArn  = projectArn,
                Type        = uploadType,
                ContentType = ContentType
            });

            PresignedPut(uploadResponse.Upload.Url, applicationLocation, ContentType);
            return(uploadResponse.Upload.Arn);
        }
Exemplo n.º 2
0
        public void DeviceFarmCreateUpload()
        {
            #region createupload-example-1470864711775

            var client   = new AmazonDeviceFarmClient();
            var response = client.CreateUpload(new CreateUploadRequest
            {
                Name       = "MyAppiumPythonUpload",
                Type       = "APPIUM_PYTHON_TEST_PACKAGE",
                ProjectArn = "arn:aws:devicefarm:us-west-2:123456789101:project:EXAMPLE-GUID-123-456" // You can get the project ARN by using the list-projects CLI command.
            });

            Upload upload = response.Upload;

            #endregion
        }
Exemplo n.º 3
0
        private string UploadApk(string apkPath)
        {
            var createUploadResponse = client.CreateUpload(new CreateUploadRequest
            {
                ProjectArn = ProjectArn,
                Name       = "android.apk",
                Type       = UploadType.ANDROID_APP
            });

            // Send the APK
            ReportProgress("Sending APK...");
            UploadFile(apkPath, createUploadResponse.Upload.Url);

            // Check upload status
            var          appArn       = createUploadResponse.Upload.Arn;
            UploadStatus uploadStatus = GetUploadStatus(appArn);

            return(uploadStatus == UploadStatus.SUCCEEDED ? appArn : null);
        }
Exemplo n.º 4
0
        private void Run(Options options)
        {
            this.options = options;
            client       = new AmazonDeviceFarmClient(AwsAccessKey, AwsSecretKey, RegionEndpoint.USWest2);

            if (options.ListDevicePools)
            {
                ListDevicePools();
                return;
            }

            if (options.DeleteCompletedRuns)
            {
                DeleteCompletedRuns();
                return;
            }

            var devicePoolArn = FindDevicePoolByName(options.DevicePool);

            if (string.IsNullOrEmpty(devicePoolArn))
            {
                ReportError($"Error: device pool '{options.DevicePool}' not found");
                return;
            }

            if (string.IsNullOrEmpty(options.FeaturesDir))
            {
                options.FeaturesDir = Path.Combine(Environment.CurrentDirectory, "features");
            }

            if (!Directory.Exists(options.FeaturesDir))
            {
                ReportError($"Directory '{options.FeaturesDir}' not found");
                return;
            }

            if (!options.UseLastApk && string.IsNullOrEmpty(options.Apk))
            {
                ReportError("You need to specifcy the package to use");
                return;
            }

            var appArn = options.UseLastApk
                                ? GetLatestAppArn()
                                : UploadApk(options.Apk);

            if (string.IsNullOrEmpty(appArn))
            {
                ReportError($"Package not found or failed to upload");
                return;
            }

            var testServersPath = Path.Combine(Environment.CurrentDirectory, "test_servers");

            if (Directory.Exists(testServersPath))
            {
                Directory.Delete(testServersPath, true);
            }

            var featuresZip = Path.Combine(Path.GetDirectoryName(options.FeaturesDir), "features.zip");

            File.Delete(featuresZip);
            ZipFile.CreateFromDirectory(options.FeaturesDir, featuresZip, CompressionLevel.Fastest, true);

            // Upload the tests
            var createUploadResponse = client.CreateUpload(new CreateUploadRequest
            {
                ProjectArn = ProjectArn,
                Name       = "features.zip",
                Type       = UploadType.CALABASH_TEST_PACKAGE
            });

            Console.WriteLine("Sending features.zip");
            UploadFile(featuresZip, createUploadResponse.Upload.Url);

            var testPackageArn = createUploadResponse.Upload.Arn;
            var uploadStatus   = GetUploadStatus(testPackageArn);

            if (uploadStatus == UploadStatus.FAILED)
            {
                ReportError("Failed to upload features.zip");
                return;
            }

            // Schedule test run
            var scheduleResponse = client.ScheduleRun(new ScheduleRunRequest
            {
                ProjectArn    = ProjectArn,
                AppArn        = appArn,
                DevicePoolArn = devicePoolArn,
                Name          = options.TestName ?? $"Run {DateTime.Now.ToString()}",
                Test          = new ScheduleRunTest
                {
                    Type           = TestType.CALABASH,
                    TestPackageArn = testPackageArn
                },
                Configuration = new ScheduleRunConfiguration
                {
                    Radios = new Radios {
                        Wifi = true
                    },
                    Locale = "en_US",
                }
            });

            GetRunResponse runResponse;

            ReportProgress("Waiting test to finish (it takes a long time, please be patient)");

            do
            {
                Console.Write(".");
                runArn      = scheduleResponse.Run.Arn;
                runResponse = client.GetRun(runArn);
                Thread.Sleep(3000);
            }while (runResponse.Run.Status != ExecutionStatus.COMPLETED);

            if (runResponse.Run.Result != ExecutionResult.PASSED)
            {
                ReportError("Test run failed");
                return;
            }

            DownloadAllArtifacts();
            ReportProgress("Test run finished successfully");
        }