Example #1
0
        public static async Task <RunSet> FromId(string id, Config config, Commit commit, string buildURL, string logURL)
        {
            var obj = await ParseInterface.RunWithRetry(() => ParseObject.GetQuery ("RunSet").GetAsync(id));

            //Console.WriteLine ("GetAsync RunSet");
            if (obj == null)
            {
                throw new Exception("Could not fetch run set.");
            }

            var runSet = new RunSet {
                parseObject    = obj,
                StartDateTime  = obj.Get <DateTime> ("startedAt"),
                FinishDateTime = obj.Get <DateTime> ("finishedAt"),
                BuildURL       = obj.Get <string> ("buildURL"),
                LogURL         = logURL
            };

            var configObj  = obj.Get <ParseObject> ("config");
            var commitObj  = obj.Get <ParseObject> ("commit");
            var machineObj = obj.Get <ParseObject> ("machine");

            await ParseInterface.RunWithRetry(() => ParseObject.FetchAllAsync(new ParseObject[] { configObj, commitObj, machineObj }));

            //Console.WriteLine ("FindAllAsync config, commit, machine");

            if (!config.EqualToParseObject(configObj))
            {
                throw new Exception("Config does not match the one in the database.");
            }
            if (commit.Hash != commitObj.Get <string> ("hash"))
            {
                throw new Exception("Commit does not match the one in the database.");
            }
            if (buildURL != runSet.BuildURL)
            {
                throw new Exception("Build URL does not match the one in the database.");
            }
            if (!AreWeOnParseMachine(machineObj))
            {
                throw new Exception("Machine does not match the one in the database.");
            }

            runSet.Config = config;
            runSet.Commit = commit;

            foreach (var o in obj.Get <List <object> > ("timedOutBenchmarks"))
            {
                runSet.timedOutBenchmarks.Add(await Benchmark.FromId(((ParseObject)o).ObjectId));
            }
            foreach (var o in obj.Get <List <object> > ("crashedBenchmarks"))
            {
                runSet.crashedBenchmarks.Add(await Benchmark.FromId(((ParseObject)o).ObjectId));
            }

            return(runSet);
        }