This C# program should run on a DTM/WHQL server.  It's used by the
whql_submission test to schedule and monitor device submission jobs.

Note: the binary is copied to the server at run time, so it doesn't need to be
packaged in winutils.iso.

Signed-off-by: Michael Goldish <[email protected]>
---
 client/tests/kvm/deps/whql_submission_15.cs  |  254 ++++++++++++++++++++++++++
 client/tests/kvm/deps/whql_submission_15.exe |  Bin 0 -> 10240 bytes
 2 files changed, 254 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/deps/whql_submission_15.cs
 create mode 100644 client/tests/kvm/deps/whql_submission_15.exe

diff --git a/client/tests/kvm/deps/whql_submission_15.cs 
b/client/tests/kvm/deps/whql_submission_15.cs
new file mode 100644
index 0000000..540674a
--- /dev/null
+++ b/client/tests/kvm/deps/whql_submission_15.cs
@@ -0,0 +1,254 @@
+// DTM submission automation program
+// Author: Michael Goldish <[email protected]>
+// Based on sample code by Microsoft.
+
+// Note: this program has only been tested with DTM version 1.5.
+// It might fail to work with other versions, specifically because it uses
+// a few undocumented methods/attributes.
+
+using System;
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+using Microsoft.DistributedAutomation.DeviceSelection;
+using Microsoft.DistributedAutomation.SqlDataStore;
+
+namespace automate0
+{
+    class AutoJob
+    {
+        static int Main(string[] args)
+        {
+            if (args.Length != 5)
+            {
+                Console.WriteLine("Error: incorrect number of command line 
arguments");
+                Console.WriteLine("Usage: {0} serverName clientName 
machinePoolName submissionName timeout",
+                    System.Environment.GetCommandLineArgs()[0]);
+                return 1;
+            }
+            string serverName = args[0];
+            string clientName = args[1];
+            string machinePoolName = args[2];
+            string submissionName = args[3];
+            double timeout = Convert.ToDouble(args[4]);
+
+            try
+            {
+                // Initialize DeviceScript and connect to data store
+                Console.WriteLine("Initializing DeviceScript object");
+                DeviceScript script = new DeviceScript();
+                Console.WriteLine("Connecting to data store");
+
+                script.ConnectToNamedDataStore(serverName);
+
+                // Find client machine
+                IResourcePool rootPool = script.GetResourcePoolByName("$");
+                Console.WriteLine("Looking for client machine '{0}'", 
clientName);
+                IResource machine = null;
+                while (true)
+                {
+                    try
+                    {
+                        machine = rootPool.GetResourceByName(clientName);
+                    }
+                    catch (Exception e)
+                    {
+                        Console.WriteLine("Warning: " + e.Message);
+                    }
+                    // Make sure the machine is valid
+                    if (machine != null &&
+                        machine.OperatingSystem != null &&
+                        machine.OperatingSystem.Length > 0 &&
+                        machine.ProcessorArchitecture != null &&
+                        machine.ProcessorArchitecture.Length > 0 &&
+                        machine.GetDevices().Length > 0)
+                        break;
+                    System.Threading.Thread.Sleep(1000);
+                }
+                Console.WriteLine("Client machine '{0}' found ({1}, {2})",
+                    clientName, machine.OperatingSystem, 
machine.ProcessorArchitecture);
+
+                // Create machine pool and add client machine to it
+                // (this must be done because jobs cannot be scheduled for 
machines in the
+                // default pool)
+                try
+                {
+                    script.CreateResourcePool(machinePoolName, 
rootPool.ResourcePoolId);
+                }
+                catch (Exception e)
+                {
+                    Console.WriteLine("Warning: " + e.Message);
+                }
+                IResourcePool newPool = 
script.GetResourcePoolByName(machinePoolName);
+                Console.WriteLine("Moving the client machine to pool '{0}'", 
machinePoolName);
+                machine.ChangeResourcePool(newPool);
+
+                // Reset client machine
+                if (machine.Status != "Ready")
+                {
+                    Console.WriteLine("Changing the client machine's status to 
'Reset'");
+                    while (true)
+                    {
+                        try
+                        {
+                            machine.ChangeResourceStatus("Reset");
+                            break;
+                        }
+                        catch (Exception e)
+                        {
+                            Console.WriteLine("Warning: " + e.Message);
+                        }
+                        System.Threading.Thread.Sleep(5000);
+                    }
+                    Console.WriteLine("Waiting for client machine to be 
ready");
+                    while (machine.Status != "Ready")
+                    {
+                        try
+                        {
+                            machine = rootPool.GetResourceByName(clientName);
+                        }
+                        catch (Exception e)
+                        {
+                            Console.WriteLine("Warning: " + e.Message);
+                        }
+                        System.Threading.Thread.Sleep(1000);
+                    }
+                }
+                Console.WriteLine("Client machine is ready");
+
+                // Get requested device regex and look for a matching device
+                Console.WriteLine("Device to test: ");
+                Regex deviceRegex = new Regex(Console.ReadLine(), 
RegexOptions.IgnoreCase);
+                Console.WriteLine("Looking for device '{0}'", deviceRegex);
+                IDevice device = null;
+                foreach (IDevice d in machine.GetDevices())
+                {
+                    if (deviceRegex.IsMatch(d.FriendlyName))
+                    {
+                        device = d;
+                        Console.WriteLine("Found device '{0}'", 
d.FriendlyName);
+                        break;
+                    }
+                }
+                if (device == null)
+                {
+                    Console.WriteLine("Error: device '{0}' not found", 
deviceRegex);
+                    return 1;
+                }
+
+                // Create submission
+                Object[] existingSubmissions = 
script.GetSubmissionByName(submissionName);
+                if (existingSubmissions.Length > 0)
+                {
+                    Console.WriteLine("Submission '{0}' already exists -- 
removing it",
+                        submissionName);
+                    
script.DeleteSubmission(((ISubmission)existingSubmissions[0]).Id);
+                }
+                Console.WriteLine("Creating submission '{0}'", submissionName);
+                ISubmission submission = 
script.CreateHardwareSubmission(submissionName,
+                    newPool.ResourcePoolId, device.InstanceId);
+
+                // Get DeviceData objects from the user
+                List<Object> deviceDataList = new List<Object>();
+                while (true)
+                {
+                    ISubmissionDeviceData dd = 
script.CreateNewSubmissionDeviceData();
+                    Console.WriteLine("DeviceData name: ");
+                    dd.Name = Console.ReadLine();
+                    if (dd.Name.Length == 0)
+                        break;
+                    Console.WriteLine("DeviceData data: ");
+                    dd.Data = Console.ReadLine();
+                    deviceDataList.Add(dd);
+                }
+
+                // Set the submission's DeviceData
+                submission.SetDeviceData(deviceDataList.ToArray());
+
+                // Get descriptors from the user
+                List<Object> descriptorList = new List<Object>();
+                while (true)
+                {
+                    Console.WriteLine("Descriptor path: ");
+                    string descriptorPath = Console.ReadLine();
+                    if (descriptorPath.Length == 0)
+                        break;
+                    
descriptorList.Add(script.GetDescriptorByPath(descriptorPath));
+                }
+
+                // Set the submission's descriptors
+                submission.SetLogoDescriptors(descriptorList.ToArray());
+
+                // Create a schedule
+                ISchedule schedule = script.CreateNewSchedule();
+                Console.WriteLine("Scheduling jobs:");
+                foreach (IJob j in submission.GetJobs())
+                {
+                    Console.WriteLine("  " + j.Name);
+                    schedule.AddDeviceJob(device, j);
+                }
+                schedule.AddSubmission(submission);
+                schedule.SetResourcePool(newPool);
+                script.RunSchedule(schedule);
+
+                // Wait for jobs to complete
+                Console.WriteLine("Waiting for all jobs to complete 
(timeout={0})", timeout);
+                DateTime endTime = DateTime.Now.AddSeconds(timeout);
+                int numCompleted = 0, numFailed = 0;
+                while (numCompleted < submission.GetResults().Length && 
DateTime.Now < endTime)
+                {
+                    // Sleep for 30 seconds
+                    System.Threading.Thread.Sleep(30000);
+                    // Count completed submission jobs
+                    numCompleted = 0;
+                    foreach (IResult r in submission.GetResults())
+                        if (r.ResultStatus != "InProgress")
+                            numCompleted++;
+                    // Report results in a Python readable format and count 
failed schedule jobs
+                    // (submission jobs are a subset of schedule jobs)
+                    Console.WriteLine();
+                    Console.WriteLine("---- [");
+                    numFailed = 0;
+                    foreach (IResult r in schedule.GetResults())
+                    {
+                        Console.WriteLine("  {");
+                        Console.WriteLine("    'job': r'''{0}''',", 
r.Job.Name);
+                        Console.WriteLine("    'logs': r'''{0}''',", 
r.LogLocation);
+                        if (r.ResultStatus != "InProgress")
+                            Console.WriteLine("    'report': r'''{0}''',",
+                                submission.GetSubmissionResultReport(r));
+                        Console.WriteLine("    'status': '{0}',", 
r.ResultStatus);
+                        Console.WriteLine("    'pass': {0}, 'fail': {1}, 
'notrun': {2}, 'notapplicable': {3}",
+                            r.Pass, r.Fail, r.NotRun, r.NotApplicable);
+                        Console.WriteLine("  },");
+                        numFailed += r.Fail;
+                    }
+                    Console.WriteLine("] ----");
+                }
+                Console.WriteLine();
+
+                // Cancel incomplete jobs
+                foreach (IResult r in schedule.GetResults())
+                    if (r.ResultStatus == "InProgress")
+                        r.Cancel();
+
+                // Report failures
+                if (numCompleted < submission.GetResults().Length)
+                    Console.WriteLine("Some jobs did not complete on time.");
+                if (numFailed > 0)
+                    Console.WriteLine("Some jobs failed.");
+
+                if (numFailed > 0 || numCompleted < 
submission.GetResults().Length)
+                    return 1;
+
+                Console.WriteLine("All jobs completed.");
+
+                return 0;
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine("Error: " + e.Message);
+                return 1;
+            }
+        }
+    }
+}
diff --git a/client/tests/kvm/deps/whql_submission_15.exe 
b/client/tests/kvm/deps/whql_submission_15.exe
new file mode 100644
index 
0000000000000000000000000000000000000000..1e513a1783db619fbc8b17f9245783087f235232
GIT binary patch
literal 10240
zcmehm...@zb$@#wyyJ;hy...@m3m56l*fs*9!w`vbt^1fk(6={Dakxawi_wZ@@_?~
za(8>4-IGb%X%qx09Kcp=AT0_tZR(<Fn*s&w#6{z#wu^qaC}0OkksvM#t4?7!MrzbS
zn)D+^qW<3OF7HT5u7dWT0$Flr-+S}koA)&{y...@{3l~md1!u?b)v80$=a...@mzx
z?&O_+mZaxeU+wv-HuGxF`~}O=YtmknMnx|g)vE343#KmXRo$xUQ^yN>#V(n-_V&a!
zU-gM;q8Tkrk6*icCK&Av3Tf-KIMG&6...@zjs(K{Pt<aopVKc!WH=0V(_WNtbbh&R3Ym
zKTWh={WqRI>aoyc&|6...@5oai+u!rjq`q5$hl9u$sj+xlfbzgaxkiua>p6MxP%mt5d)
zcB4U`^3}H+n7VYLb2;hAA~0p!IDi)1I_{=x9M<QgS+>E*w$eG=tZN7ErfZz&a1*M)
zzu>syV%tI#r5|L8-cA!~z;W|vKi9QoG(ts4k~{vwsx*...@0qh&?cnGP!v$+Y8E_+
zj-8>*)kLV{>blUTt8JmpSKC9KSF<tnq$bd*12g3b...@6ud`7dqahksxd)^...@uyu
zzeQF7$CTa;>6mDV+3T1dyVjYG%V*Fh;x?j_$hLFC_FN+o8#*9jb`r?YZXdAk0G1is
z...@}7~0|kKD`a70R4)U8Ew<w...@xxkfdt@ff6e3jN_?3tA_+6&qQ%|-$li!%2MlWU
z3~Ig6plIB4Cn48|s1{f5h?q#&8P*iDJMfU_(3RZ;Xx|e^jx00e4vcn21+...@u<Q3
zb>1lJZWu*>40d^Dzan1?qz6Y=1+C4KZo5%>#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f...@ujte
zg`U4CozoMgidE&$U<2...@r)qv-6~5d_ec*k7dcm!iel-0-i=c5xzbty_...@jny)<V
zg^Q>0g>M>;8PIaI(gk_n3?dh2...@=18ns(_`SA4Jv(xr...@87v0p=g;^ggpJU<|
z{q3ZWE9mx`5Kf`g(3kQ13gL&8%d6$Qle`nRpkKHNo#odk0maMElYo9_oM?&@<X>+e
zCi;GmK+vW__~nRB;Whd!+G)J36>yq$9i...@jooh0q2=i<lubidk...@eem{p|^OV
zj...@mlui+lqzsl5jcv#teerpu)zYK=F!V9oDTYVtM@(&6a!Aueh;>4u*n6Nx4zt{
z>9XP(#RrS`w+H*kC=?8#thJSqd7Wy0y=aW1gLf2_-{3t3UJ337&nWhR#?85F13!Di
zuM7OL&#xB2#|-;Ek8`?tHKq$$ehD)%PFC4819(w...@fz+qfw&6kB3^Cq*+Oj3xYB>z
zr?cm*kkz+xx...@dz3%koa5a%@dwdbuNwZaZ|oDtU;=*g3p#&ImSLIxKgvOr-u>E3
z2M#S&$~um`_zdM>?^tfMS2wFgn@@WV_MV(SGQ77}=W~vdQMRk*!QN%l={<CJd*T2-
zpUuibd0B^os&lZnF01<;oDNhBXSfoalMNT`%6`MC<Svc%>Nse#&g1m)RP$(1rRyuo
z...@+gv@I0;&15q^w-rag2{9qgt...@y0d7dwi^^snntv>PAeD%D2oA&JLRdN{HF^hE^
z4=(#SC=v%!u+uD^kk%!fN-mntZED>eXw`8w^k69}*4g42^O9NC%iJF9HJp6)lKnAL
z_Ud(OqR2;a2Yb&OWykcLQc6Z{VohNB$ST_pjI0C!3<pMn3<2S6|Khss2w-Bhf%%Q5
p{pyr2f5g_wj...@ru|}y

literal 0
HcmV?d00001

-- 
1.5.4.1

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to