Пример #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 string GetTestResults(DeviceFarmOverrides dfConfOverrides = null)
        {
            DeviceFarmConfig dfConf    = GetDeviceFarmConfig(dfConfOverrides);
            string           dfConfStr = JsonUtility.ToJson(dfConf);
            Metadata         metadata  = new Metadata(dfConf.awsDeviceUDID, attemptId: "", dfConfStr);

            lock (_mutex)
            {
                var countersData = new CountersData(_testResults, metadata);
                return(JsonUtility.ToJson(countersData));
            }
        }
 public void TestFinished(ITestResult result)
 {
     if (!result.Test.IsSuite)
     {
         //TODO: Add xml reports to artifacts
         // var xmlResult = result.ToXml(true).OuterXml;
         CloudTestManager.Instance.ResetTestResults();
         CloudTestManager.Instance.SetCounter(result.Name, result.ResultState.Status == TestStatus.Passed ? 1 : 0);
         var deviceModelName = SystemInfo.deviceModel;
         var dfConfOverrides = new DeviceFarmOverrides(result.FullName, deviceModelName);
         if (_dfConf.awsDeviceUDID == null)
         {
             dfConfOverrides.awsDeviceUDID = "Local-Device-UDID";
         }
         CloudTestManager.UploadCounters(dfConfOverrides);
     }
 }
Пример #4
0
        public DeviceFarmConfig GetDeviceFarmConfig(DeviceFarmOverrides dfOverrides = null)
        {
            string configPath = Path.Combine(Application.persistentDataPath, deviceFarmConfigFile);

            DeviceFarmConfig dfConf;

            if (File.Exists(configPath))
            {
                // Read env and testName
                string configStr = File.ReadAllText(configPath);
                dfConf = JsonUtility.FromJson <DeviceFarmConfig>(configStr.ToString());
            }
            else
            {
                //TODO: Graceful shutdown with logs.
                logger.Log("config.json not found");
                dfConf             = new DeviceFarmConfig();
                dfConf.testName    = "DummyTest";
                dfConf.packageName = Application.identifier;
            }

            if (dfOverrides != null)
            {
                dfConf.testName      = dfOverrides.testName;
                dfConf.awsDeviceUDID = dfOverrides.awsDeviceUDID;
#if UNITY_IOS
                dfConf.awsDeviceModel = dfOverrides.awsDeviceModel;
                dfConf.awsDeviceName  = GetAppleDevice(dfOverrides.awsDeviceModel);
#else
                dfConf.awsDeviceModel = dfOverrides.awsDeviceModel;
#endif
            }

            logger.Log($"Test name - {dfConf.testName}, Config - {dfConf.ToString()}," +
                       $"Device Model - {dfConf.awsDeviceModel}, Device Name - {dfConf.awsDeviceName}");
            return(dfConf);
        }