Пример #1
0
        public static void UploadCounters(DeviceFarmOverrides dfConfOverrides = null)
        {
            AQALogger logger = new AQALogger();

            var testResults = CloudTestManager.Instance.GetTestResults(dfConfOverrides);

            logger.Log($"Uploading counters {testResults.ToString()}");
            var postUrl = $"{AutomatedQARuntimeSettings.DEVICE_TESTING_API_ENDPOINT}/v1/counters";

            logger.Log($"Counters = {testResults}");
            byte[]           counterPayload = GetBytes(testResults);
            UploadHandlerRaw uH             = new UploadHandlerRaw(counterPayload);

            uH.contentType = "application/json";


            using (var uwr = new UnityWebRequest(postUrl, UnityWebRequest.kHttpVerbPOST))
            {
                uwr.uploadHandler = uH;
                AsyncOperation request = uwr.SendWebRequest();

                while (!request.isDone)
                {
                }

                if (uwr.IsError())
                {
                    logger.LogError($"Couldn't upload counters. Error - {uwr.error}");
                }
                else
                {
                    logger.Log($"Uploaded counters.");
                }
            }
        }
Пример #2
0
        public JobStatusResponse RunCloudTests(string buildId, List <string> cloudTests, string accessToken, string projectId)
        {
            Debug.Log($"RunCloudTests - buildId: {buildId}");
            var url = $"{AutomatedQARuntimeSettings.DEVICE_TESTING_API_ENDPOINT}/v1/job/create?projectId={projectId}";

            var jsonObject = new CloudTestPayload();

            jsonObject.buildId   = buildId;
            jsonObject.testNames = cloudTests;
            string data = JsonUtility.ToJson(jsonObject);

            byte[]           payload = GetBytes(data);
            UploadHandlerRaw uH      = new UploadHandlerRaw(payload);

            uH.contentType = "application/json";

            Debug.Log(url);
            Debug.Log(data);

            using (var uwr = new UnityWebRequest(url, UnityWebRequest.kHttpVerbPOST))
            {
                uwr.uploadHandler   = uH;
                uwr.downloadHandler = new DownloadHandlerBuffer();
                uwr.SetRequestHeader("Content-Type", "application/json");
                uwr.SetRequestHeader("Authorization", "Bearer " + accessToken);

                AsyncOperation request = uwr.SendWebRequest();

                while (!request.isDone)
                {
                    EditorUtility.DisplayProgressBar("Run Cloud Tests", "Starting tests", request.progress);
                }
                EditorUtility.ClearProgressBar();

                if (uwr.IsError())
                {
                    HandleError($"Couldn't start cloud tests. Error - {uwr.error}");
                }
                else
                {
                    string response = uwr.downloadHandler.text;
                    Debug.Log($"response: {response}");
                    return(JsonUtility.FromJson <JobStatusResponse>(response));
                }
            }

            return(new JobStatusResponse());
        }