Esempio n. 1
0
        private static void TestPacketSniffAdminCommandLock(string[] args)
        {
            Console.WriteLine("-");
            Console.WriteLine("Testing packet sniff under admin command lock...");

            string exe = Exec.GetQizmtExe();

            try
            {
                MySpace.DataMining.AELight.AELight.EnterAdminCmd();
                Console.WriteLine("Admin command lock obtained...");

                Console.WriteLine("Running packet sniff...");
                string output   = Exec.Shell(exe + " packetsniff", false);
                string expected = "sniffing";
                if (output.IndexOf(expected, StringComparison.OrdinalIgnoreCase) > -1)
                {
                    Console.WriteLine("[PASSED] - " + string.Join(" ", args));
                }
                else
                {
                    Console.WriteLine("[FAILED] - " + string.Join(" ", args));
                }
            }
            finally
            {
                MySpace.DataMining.AELight.AELight.CleanThisExecQ();
                Console.WriteLine("Admin command lock released...");
            }
        }
Esempio n. 2
0
        public static void TestDSpaceGetBinaryFilePermissions(string[] args)
        {
            string exe         = Exec.GetQizmtExe();
            string username    = Environment.UserName.ToLower();
            string userdomain  = Environment.UserDomainName.ToLower();
            string useraccount = userdomain + @"\" + username;

            Console.WriteLine();
            Console.WriteLine("-");
            Console.WriteLine("Testing: Qizmt getbinary file permissions...");

            Exec.Shell(exe + " del TestDSpaceGetBinaryFilePermissions*", false);
            Exec.Shell(exe + " gen TestDSpaceGetBinaryFilePermissions1.txt 40MB", false);
            Exec.Shell(exe + " gen TestDSpaceGetBinaryFilePermissions2.txt 40MB", false);

            string dir = Environment.CurrentDirectory + @"\TestDSpaceGetBinaryFilePermissions";

            if (System.IO.Directory.Exists(dir))
            {
                System.IO.Directory.Delete(dir, true);
            }
            System.IO.Directory.CreateDirectory(dir);
            dir = dir.Replace(":", "$");
            dir = @"\\" + System.Net.Dns.GetHostName() + @"\" + dir;

            string dir2 = dir + "2";

            if (System.IO.Directory.Exists(dir2))
            {
                System.IO.Directory.Delete(dir2, true);
            }
            System.IO.Directory.CreateDirectory(dir2);
            dir  = dir + @"\";
            dir2 = dir2 + @"\";

            Exec.Shell(exe + " get TestDSpaceGetBinaryFilePermissions*.txt " + dir, false);
            Exec.Shell(exe + " putbinary " + dir + "*.* TestDSpaceGetBinaryFilePermissions.blob", false);
            Exec.Shell(exe + " getbinary TestDSpaceGetBinaryFilePermissions.blob " + dir2);

            if (HasFullControl(useraccount, dir2))
            {
                Console.WriteLine("[PASSED] - " + string.Join(" ", args));
            }
            else
            {
                Console.WriteLine("[FAILED] - " + string.Join(" ", args));
            }

            System.IO.Directory.Delete(dir, true);
            System.IO.Directory.Delete(dir2, true);
            Exec.Shell(exe + " del TestDSpaceGetBinaryFilePermissions*", false);
        }
Esempio n. 3
0
        public static void TestDSpaceGetFilePermissions(string[] args)
        {
            string exe         = Exec.GetQizmtExe();
            string username    = Environment.UserName.ToLower();
            string userdomain  = Environment.UserDomainName.ToLower();
            string useraccount = userdomain + @"\" + username;

            Console.WriteLine();
            Console.WriteLine("-");
            Console.WriteLine("Testing: Qizmt get file permissions...");

            Exec.Shell(exe + " del TestDSpaceGetFilePermissions*", false);
            Exec.Shell(exe + " gen TestDSpaceGetFilePermissionsA1.txt 100MB", false);
            Exec.Shell(exe + " gen TestDSpaceGetFilePermissionsA2.txt 100MB", false);
            Exec.Shell(exe + " gen TestDSpaceGetFilePermissionsB1.txt 100MB", false);
            Exec.Shell(exe + " gen TestDSpaceGetFilePermissionsB2.txt 100MB", false);

            string dir = Environment.CurrentDirectory + @"\TestDSpaceGetFilePermissions\";

            if (System.IO.Directory.Exists(dir))
            {
                System.IO.Directory.Delete(dir, true);
            }
            System.IO.Directory.CreateDirectory(dir);

            dir = dir.Replace(":", "$");
            dir = @"\\" + System.Net.Dns.GetHostName() + @"\" + dir;

            Exec.Shell(exe + " get TestDSpaceGetFilePermissionsA1.txt " + dir + "A1.txt", false);
            Exec.Shell(exe + " get TestDSpaceGetFilePermissionsA1.txt " + dir + "A1.gz", false);
            Exec.Shell(exe + " get TestDSpaceGetFilePermissionsA*.txt " + dir, false);
            Exec.Shell(exe + " get parts=0-1 TestDSpaceGetFilePermissionsB1.txt " + dir + "B1.txt", false);
            Exec.Shell(exe + " get parts=0-1 TestDSpaceGetFilePermissionsB1.txt " + dir + "B1.gz", false);
            Exec.Shell(exe + " get parts=0-1 TestDSpaceGetFilePermissionsB*.txt " + dir, false);

            if (HasFullControl(useraccount, dir))
            {
                Console.WriteLine("[PASSED] - " + string.Join(" ", args));
            }
            else
            {
                Console.WriteLine("[FAILED] - " + string.Join(" ", args));
            }

            System.IO.Directory.Delete(dir, true);
            Exec.Shell(exe + " del TestDSpaceGetFilePermissions*", false);
        }
Esempio n. 4
0
        private static bool GenerateDfsFile(string fname, string dfspath, string dspacedir, ref string fpath)
        {
            string exe = Exec.GetQizmtExe();

            Exec.Shell(exe + @" del " + fname);
            Exec.Shell(exe + @" gen " + fname + " 100B");

            System.Xml.XmlDocument dfs = new System.Xml.XmlDocument();
            try
            {
                dfs.Load(dfspath);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error loading dfs.xml: {0}", e.Message);
                return(false);
            }

            System.Xml.XmlNode fnode = dfs.SelectSingleNode(@"//DfsFile[Name='" + fname + @"']/Nodes/FileNode[1]");
            if (fnode == null)
            {
                Console.Error.WriteLine("File node of generated file not found in dfs.xml");
                return(false);
            }

            string name = fnode["Name"].InnerText;
            string host = fnode["Host"].InnerText.Split(';')[0];

            fpath = @"\\" + host + @"\" + dspacedir + name;

            if (!System.IO.File.Exists(fpath))
            {
                Console.Error.WriteLine("Cannot find the file that was just generated.");
                return(false);
            }
            return(true);
        }
Esempio n. 5
0
        public static void TestClearLogs(string[] args)
        {
            if (args.Length < 2)
            {
                Console.Error.WriteLine("Error: Command clearlogs needs argument: <dfsXmlPath>");
                return;
            }

            string dfspath = args[1];

            if (!dfspath.StartsWith(@"\\"))
            {
                Console.Error.WriteLine("Error: Argument <dfsXmlPath> must be a network path");
                return;
            }

            string dspacedir = null;

            {
                int del = dfspath.IndexOf('$');
                if (del > 0)
                {
                    string temp = dfspath.Substring(del - 1).Trim();
                    del = temp.LastIndexOf(@"\");
                    if (del > -1)
                    {
                        dspacedir = temp.Substring(0, del);
                    }
                }
            }
            if (dspacedir == null)
            {
                Console.Error.WriteLine("Error: Cannot parse Qizmt dir.");
                return;
            }

            string[] hosts = null;
            {
                try
                {
                    System.Xml.XmlDocument dc = new System.Xml.XmlDocument();
                    dc.Load(dfspath);
                    System.Xml.XmlNode node = dc.SelectSingleNode("//SlaveList");
                    if (node == null)
                    {
                        Console.Error.WriteLine("SlaveList node is not found in dfs.xml");
                        return;
                    }
                    hosts = node.InnerText.Split(';');
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine("Error while loading dfs.xml: {0}", e.ToString());
                    return;
                }
            }

            Console.WriteLine("-");
            Console.WriteLine("Testing clearlogs...");

            string dir = @"\\" + System.Net.Dns.GetHostName() + @"\" + Environment.CurrentDirectory.Replace(':', '$') + @"\RegressionTest\ClearLogsTest\";

            if (System.IO.Directory.Exists(dir))
            {
                System.IO.Directory.Delete(dir, true);
            }
            System.IO.Directory.CreateDirectory(dir);

            System.IO.File.WriteAllText(dir + "regressionTest_clearlogs.xml", @"
<SourceCode>
  <Jobs>
    <Job Name=`local` Custodian=`` Email=``>
      <IOSettings>
        <JobType>local</JobType>
      </IOSettings>
      <Local>
        <![CDATA[
        public virtual void Local()
        {
            Shell(@`Qizmt del regressionTest_clearlogs_Output*.txt`);
        }
        ]]>
      </Local>
    </Job>
    <Job Name=`remote` Custodian=`` Email=``>
      <IOSettings>
        <JobType>remote</JobType>
        <DFS_IO_Multi>
          <DFSReader></DFSReader>
          <DFSWriter>dfs://regressionTest_clearlogs_Output####.txt</DFSWriter>
          <Mode>ALL MACHINES</Mode>
        </DFS_IO_Multi>
      </IOSettings>
      <Remote>
        <![CDATA[
          public virtual void Remote(RemoteInputStream dfsinput, RemoteOutputStream dfsoutput)
          {        
                dfsoutput.WriteLine(`x`);                
                string s = null;
                int x = s.Length;
           }
        ]]>
      </Remote>
    </Job>
  </Jobs>
</SourceCode>
".Replace('`', '"'));

            string exe = Exec.GetQizmtExe();

            Exec.Shell(exe + " del regressionTest_clearlogs.xml", false);
            Exec.Shell(exe + " importdir " + dir, false);

            try
            {
                Exec.Shell(exe + " exec regressionTest_clearlogs.xml");
            }
            catch
            {
            }

            //Make sure there exists slave-log.txt.
            bool found = false;

            for (int i = 0; i < hosts.Length; i++)
            {
                if (System.IO.File.Exists(@"\\" + hosts[i] + @"\" + dspacedir + @"\slave-log.txt"))
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                Console.Error.WriteLine("Slave-log.txt is not located.");
                return;
            }

            Exec.Shell(exe + " del regressionTest_clearlogs.xml", false);
            Exec.Shell(exe + " del regressionTest_clearlogs_Output*.xml", false);
            System.IO.Directory.Delete(dir, true);

            string output = Exec.Shell(exe + " clearlogs");

            if (output.IndexOf("Done", StringComparison.OrdinalIgnoreCase) > -1)
            {
                found = false;
                for (int i = 0; i < hosts.Length; i++)
                {
                    if (System.IO.File.Exists(@"\\" + hosts[i] + @"\" + dspacedir + @"\slave-log.txt"))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    Console.WriteLine("[PASSED] - " + string.Join(" ", args));
                    return;
                }
            }

            Console.WriteLine("[FAILED] - " + string.Join(" ", args));
        }
Esempio n. 6
0
        public static void TestFormatMetaOnlySwitch(string[] args)
        {
            if (args.Length < 2)
            {
                Console.Error.WriteLine("Error: FormatMetaOnlySwitch command needs argument: <dfsXmlPath>");
                return;
            }

            string dfspath = args[1];

            if (!dfspath.StartsWith(@"\\"))
            {
                Console.Error.WriteLine("Argument: <dfsXmlPath> must be a network path");
                return;
            }

            System.Xml.XmlDocument dfs = new System.Xml.XmlDocument();
            string slavelist           = null;

            try
            {
                dfs.Load(dfspath);
                System.Xml.XmlNode node = dfs.SelectSingleNode("//SlaveList");
                if (node == null)
                {
                    Console.Error.WriteLine("SlaveList node is not found in dfs.xml");
                    return;
                }
                slavelist = node.InnerText.ToUpper();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error loading dfs.xml: {0}", e.Message);
                return;
            }

            string dspacedir = "";

            {
                int del = dfspath.LastIndexOf(@"\");
                dspacedir = dfspath.Substring(0, del + 1);
                del       = dspacedir.IndexOf(@"\", 2);
                dspacedir = dspacedir.Substring(del + 1);
            }

            Console.WriteLine("-");
            Console.WriteLine("Testing: Qizmt format metaOnly switch...");

            string fpath = "";

            if (!GenerateDfsFile("regressionTest_formatMetaOnlySwitchTest.txt", dfspath, dspacedir, ref fpath))
            {
                return;
            }

            //format with metaonly=1
            string exe = Exec.GetQizmtExe();

            Exec.Shell(exe + " @format slaves=" + slavelist + " metaonly=1");

            bool ok = false;

            if (System.IO.File.Exists(fpath))
            {
                if (!GenerateDfsFile("regressionTest_formatMetaOnlySwitchTest.txt", dfspath, dspacedir, ref fpath))
                {
                    return;
                }

                //format with metaonly=0
                Exec.Shell(exe + " @format slaves=" + slavelist);

                if (!System.IO.File.Exists(fpath))
                {
                    ok = true;
                }
            }

            if (ok)
            {
                Console.WriteLine("[PASSED] - " + string.Join(" ", args));
            }
            else
            {
                Console.WriteLine("[FAILED] - " + string.Join(" ", args));
            }
        }
Esempio n. 7
0
        public static void TestDSpaceHosts(string[] args)
        {
            if (args.Length < 2)
            {
                Console.Error.WriteLine("Error: QizmtHosts command needs argument: <dfsXmlPath>");
                return;
            }

            string dfspath = args[1];

            if (!dfspath.StartsWith(@"\\"))
            {
                Console.Error.WriteLine("Argument: <dfsXmlPath> must be a network path");
                return;
            }

            System.Xml.XmlDocument dfs = new System.Xml.XmlDocument();
            string slavelist           = null;

            try
            {
                dfs.Load(dfspath);
                System.Xml.XmlNode node = dfs.SelectSingleNode("//SlaveList");
                if (node == null)
                {
                    Console.Error.WriteLine("SlaveList node is not found in dfs.xml");
                    return;
                }

                slavelist = node.InnerText.ToUpper();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error loading dfs.xml: {0}", e.Message);
                return;
            }

            string mr = @"<SourceCode>
  <Jobs>
    <Job Name=`Preprocessing` Custodian=`` Email=``>
      <IOSettings>
        <JobType>local</JobType>
      </IOSettings>
      <Local>
        <![CDATA[
        public virtual void Local()
        {
            Shell(@`Qizmt del regression_test_Qizmt_Hosts_Input.txt`);
            Shell(@`Qizmt del regression_test_Qizmt_Hosts_Output.txt`);            
            
            string hosts = ``;
            for(int i = 0; i < StaticGlobals.Qizmt_Hosts.Length; i++)
            {
                if(i != 0)
                {
                    hosts += `;`;
                }
                hosts += StaticGlobals.Qizmt_Hosts[i];
            }
            
            Qizmt_Log(`local:` + hosts + `:`);
        }
        ]]>
      </Local>
    </Job>
    <Job Name=`CreateSampleData` Custodian=`` Email=``>
      <IOSettings>
        <JobType>remote</JobType>
        <DFS_IO>
          <DFSReader></DFSReader>
          <DFSWriter>dfs://regression_test_Qizmt_Hosts_Input.txt</DFSWriter>
        </DFS_IO>
      </IOSettings>
      <Remote>
        <![CDATA[
          public virtual void Remote(RemoteInputStream dfsinput, RemoteOutputStream dfsoutput)
          {             
                //Create sample data.
                dfsoutput.WriteLine(`1`);
                
                string hosts = ``;
                for(int i = 0; i < StaticGlobals.Qizmt_Hosts.Length; i++)
                {
                    if(i != 0)
                    {
                        hosts += `;`;
                    }
                    hosts += StaticGlobals.Qizmt_Hosts[i];
                }
                
                Qizmt_Log(`remote:` + hosts + `:`);
           }
        ]]>
      </Remote>
    </Job>
    <Job Name=`mr` Custodian=`` Email=``>
      <IOSettings>
        <JobType>mapreduce</JobType>
        <KeyLength>1</KeyLength>
        <DFSInput>dfs://regression_test_Qizmt_Hosts_Input.txt</DFSInput>
        <DFSOutput>dfs://regression_test_Qizmt_Hosts_Output.txt</DFSOutput>
        <OutputMethod>grouped</OutputMethod>
      </IOSettings>
      <MapReduce>
        <Map>
          <![CDATA[
          public virtual void Map(ByteSlice line, MapOutput output)
          {
                output.Add(line, line);
                
                string hosts = ``;
                for(int i = 0; i < StaticGlobals.Qizmt_Hosts.Length; i++)
                {
                    if(i != 0)
                    {
                        hosts += `;`;
                    }
                    hosts += StaticGlobals.Qizmt_Hosts[i];
                }
                
                Qizmt_Log(`map:` + hosts + `:`);
          }
        ]]>
        </Map>
        <Reduce>
          <![CDATA[
          public override void Reduce(ByteSlice key, ByteSliceList values, ReduceOutput output)
          {
                string hosts = ``;
                for(int i = 0; i < StaticGlobals.Qizmt_Hosts.Length; i++)
                {
                    if(i != 0)
                    {
                        hosts += `;`;
                    }
                    hosts += StaticGlobals.Qizmt_Hosts[i];
                }
                
                Qizmt_Log(`reduce:` + hosts + `:`);
          }
        ]]>
        </Reduce>
      </MapReduce>
    </Job>
    <Job Name=`Post-processing` Custodian=`` Email=``>
      <IOSettings>
        <JobType>local</JobType>
      </IOSettings>
      <Local>
        <![CDATA[
        public virtual void Local()
        {
            Shell(@`Qizmt del regression_test_Qizmt_Hosts_Input.txt`);
            Shell(@`Qizmt del regression_test_Qizmt_Hosts_Output.txt`);
        }
        ]]>
      </Local>
    </Job>
  </Jobs>
</SourceCode>".Replace('`', '"');

            Console.WriteLine("-");
            Console.WriteLine("Testing Qizmt_Hosts...");

            string dir = @"\\" + System.Net.Dns.GetHostName() + @"\" + Environment.CurrentDirectory.Replace(':', '$') + @"\RegressionTest\DSpaceHostsTest\";

            if (System.IO.Directory.Exists(dir))
            {
                System.IO.Directory.Delete(dir, true);
            }
            System.IO.Directory.CreateDirectory(dir);

            System.IO.File.WriteAllText(dir + @"regressionTest_dspaceHosts.xml", mr);

            string exe = Exec.GetQizmtExe();

            Exec.Shell(exe + @" del regressionTest_dspaceHosts.xml");
            Exec.Shell(exe + @" importdir " + dir);
            string results = Exec.Shell(exe + @" exec regressionTest_dspaceHosts.xml");

            bool ok = true;

            string[] expected = new string[] { "local:" + slavelist + ":", "remote:" + slavelist + ":", "map:" + slavelist + ":", "reduce:" + slavelist + ":" };
            foreach (string exp in expected)
            {
                if (results.IndexOf(exp, StringComparison.OrdinalIgnoreCase) == -1)
                {
                    ok = false;
                    break;
                }
            }

            if (ok)
            {
                Console.WriteLine("[PASSED] - " + string.Join(" ", args));
            }
            else
            {
                Console.WriteLine("[FAILED] - " + string.Join(" ", args));
            }

            Exec.Shell(exe + @" del regressionTest_dspaceHosts.xml");
            System.IO.Directory.Delete(dir, true);
        }
Esempio n. 8
0
        public static void TestClusterCheck(string[] args)
        {
            if (args.Length < 2)
            {
                Console.Error.WriteLine("Error: ClusterCheck command needs argument: <dfsXmlPath>");
                return;
            }

            string dfspath = args[1];

            if (!dfspath.StartsWith(@"\\"))
            {
                Console.Error.WriteLine("Argument: <dfsXmlPath> must be a network path");
                return;
            }

            bool verbose = false;

            if (args.Length > 2 && string.Compare(args[2], "verbose", true) == 0)
            {
                verbose = true;
            }

#if DEBUG
            verbose = true;
#endif

            string surrogate = dfspath.Substring(2, dfspath.IndexOf(@"\", 2) - 2).ToUpper();
            int    si        = 2 + surrogate.Length + 1;
            string dir       = dfspath.Substring(si, dfspath.LastIndexOf(@"\") - si);

            System.Xml.XmlDocument dfs = new System.Xml.XmlDocument();
            string slavelist           = null;
            bool   cont = false;

            try
            {
                dfs.Load(dfspath);
                System.Xml.XmlNode node = dfs.SelectSingleNode("//SlaveList");
                if (node == null)
                {
                    Console.Error.WriteLine("SlaveList node is not found in dfs.xml");
                    return;
                }

                slavelist = node.InnerText.ToUpper();
                string[] parts = slavelist.Split(new char[] { ',', ';' });
                if (parts.Length < 2)
                {
                    Console.Error.WriteLine("Must have at least 2 hosts in SlaveList tag in dfs.xml");
                    return;
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error loading dfs.xml: {0}", e.Message);
                return;
            }

            string dfsback = null;
            if (!DFSUtils.MakeFileBackup(dfspath, ref dfsback))
            {
                Console.Error.WriteLine("Error backing up dfs.xml");
                return;
            }

            string allhosts = slavelist;
            if (slavelist.IndexOf(surrogate) == -1)
            {
                allhosts += ";" + surrogate;
            }

            string exe = Exec.GetQizmtExe();

            //Participating surrogate.
            try
            {
                string sl = slavelist;
                if (sl.IndexOf(surrogate) == -1)
                {
                    sl += ";" + surrogate;
                    DFSUtils.ChangeDFSXMLSlaveList(dfs, dfspath, sl);
                }

                string result = Exec.Shell(exe + " clustercheck " + allhosts);

                if (verbose)
                {
                    Console.Write(result);
                }
                Console.WriteLine();
                Console.WriteLine("-");
                Console.WriteLine("Test case: Participating surrogate:");

                string expResult = @"Participating surrogate: \\" + surrogate.ToUpper();
                if (result.IndexOf(expResult) > -1)
                {
                    Console.WriteLine("[PASSED] - " + string.Join(" ", args));
                }
                else
                {
                    Console.WriteLine("[FAILED] - " + string.Join(" ", args));
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error during participating surrogate test case: {0}", e.Message);
            }
            finally
            {
                cont = DFSUtils.UndoFileChanges(dfspath, dfsback);
            }

            if (!cont)
            {
                return;
            }

            //Non-particpating surrogate.
            try
            {
                if (slavelist.IndexOf(surrogate) > -1)
                {
                    string[] parts = slavelist.Split(new char[] { ',', ';' });
                    string   sl    = "";
                    foreach (string p in parts)
                    {
                        if (string.Compare(p, surrogate, true) != 0)
                        {
                            sl += ";" + p;
                        }
                    }
                    sl = sl.Trim(';');
                    DFSUtils.ChangeDFSXMLSlaveList(dfs, dfspath, sl);
                }

                string result = Exec.Shell(exe + " clustercheck " + allhosts);

                if (verbose)
                {
                    Console.Write(result);
                }
                Console.WriteLine();
                Console.WriteLine("-");
                Console.WriteLine("Test case: Non-participating surrogate:");

                string expResult = @"Non-participating surrogate: \\" + surrogate.ToUpper();
                if (result.IndexOf(expResult) > -1)
                {
                    Console.WriteLine("[PASSED] - " + string.Join(" ", args));
                }
                else
                {
                    Console.WriteLine("[FAILED] - " + string.Join(" ", args));
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error during non-participating surrogate test case: {0}", e.Message);
            }
            finally
            {
                cont = DFSUtils.UndoFileChanges(dfspath, dfsback);
            }

            if (!cont)
            {
                return;
            }

            //Inaccessible host.
            try
            {
                string sl = allhosts + ";" + "BOGUSHOSTNAME";
                DFSUtils.ChangeDFSXMLSlaveList(dfs, dfspath, sl);

                string result = Exec.Shell(exe + " clustercheck " + sl);

                if (verbose)
                {
                    Console.Write(result);
                }
                Console.WriteLine();
                Console.WriteLine("-");
                Console.WriteLine("Test case: Inaccessible host:");

                string expResult = @"Inaccessible host: \\BOGUSHOSTNAME";
                if (result.IndexOf(expResult) > -1)
                {
                    Console.WriteLine("[PASSED] - " + string.Join(" ", args));
                }
                else
                {
                    Console.WriteLine("[FAILED] - " + string.Join(" ", args));
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error during inaccessible host test case: {0}", e.Message);
            }
            finally
            {
                cont = DFSUtils.UndoFileChanges(dfspath, dfsback);
            }

            if (!cont)
            {
                return;
            }

            //Bad meta data backup.
            try
            {
                {
                    System.Xml.XmlDocument thisdoc = new System.Xml.XmlDocument();
                    thisdoc.Load(dfspath);
                    System.Xml.XmlNode node = thisdoc.SelectSingleNode("//MetaBackup");
                    if (node == null)
                    {
                        node = thisdoc.CreateElement("MetaBackup");
                        thisdoc.DocumentElement.AppendChild(node);
                    }
                    node.InnerText = @"\\" + surrogate + @"\c$\" + Guid.NewGuid().ToString();
                    thisdoc.Save(dfspath);
                }

                string result = Exec.Shell(exe + " clustercheck " + allhosts);

                if (verbose)
                {
                    Console.Write(result);
                }
                Console.WriteLine();
                Console.WriteLine("-");
                Console.WriteLine("Test case: Bad meta data backup:");

                string expResult = @"Bad meta backup surrogate";
                if (result.IndexOf(expResult) > -1)
                {
                    Console.WriteLine("[PASSED] - " + string.Join(" ", args));
                }
                else
                {
                    Console.WriteLine("[FAILED] - " + string.Join(" ", args));
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error during bad meta data backup test case: {0}", e.Message);
            }
            finally
            {
                cont = DFSUtils.UndoFileChanges(dfspath, dfsback);
            }

            if (!cont)
            {
                return;
            }

            //Broken surrogate.
            string slavedat     = "";
            string slavedatback = "";
            string slave        = "";
            {
                string[] parts = slavelist.Split(new char[] { ',', ';' });
                foreach (string p in parts)
                {
                    if (string.Compare(p, surrogate, true) != 0)
                    {
                        slave = p;
                        break;
                    }
                }

                if (slave == "")
                {
                    Console.Error.WriteLine("Cannot perform broken surrogate, uninstalled host, or orphaned worker tests: must have a host in the cluster besides the surrogate itself.");
                    return;
                }

                slavedat = @"\\" + slave + @"\" + dir + @"\slave.dat";

                if (!DFSUtils.MakeFileBackup(slavedat, ref slavedatback))
                {
                    Console.Error.WriteLine("Cannot perform broken surrogate, uninstalled host, or orphaned worker tests.  Error while backing up slave.dat: {0}", slavedat);
                    return;
                }
            }

            try
            {
                System.IO.File.WriteAllText(slavedat, "master=BOGUSHOSTNAME");
                string result = Exec.Shell(exe + " clustercheck " + allhosts);

                if (verbose)
                {
                    Console.Write(result);
                }
                Console.WriteLine();
                Console.WriteLine("-");
                Console.WriteLine("Test case: Broken surrogate:");

                string expResult = @"Broken surrogate: \\" + surrogate;
                if (result.IndexOf(expResult) > -1)
                {
                    Console.WriteLine("[PASSED] - " + string.Join(" ", args));
                }
                else
                {
                    Console.WriteLine("[FAILED] - " + string.Join(" ", args));
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error during broken surrogate test case: {0}", e.Message);
            }
            finally
            {
                cont = DFSUtils.UndoFileChanges(slavedat, slavedatback);
            }

            if (!cont)
            {
                return;
            }

            //Uninstalled host.
            try
            {
                System.IO.File.Delete(slavedat);
                string result = Exec.Shell(exe + " clustercheck " + allhosts);

                if (verbose)
                {
                    Console.Write(result);
                }
                Console.WriteLine();
                Console.WriteLine("-");
                Console.WriteLine("Test case: Uninstalled host:");

                string expResult = @"Uninstalled host: \\" + slave;
                if (result.IndexOf(expResult) > -1)
                {
                    Console.WriteLine("[PASSED] - " + string.Join(" ", args));
                }
                else
                {
                    Console.WriteLine("[FAILED] - " + string.Join(" ", args));
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error during uninstalled host test case: {0}", e.Message);
            }
            finally
            {
                cont = DFSUtils.UndoFileChanges(slavedat, slavedatback);
            }

            if (!cont)
            {
                return;
            }

            //Orphaned worker.
            {
                string[] parts = slavelist.Split(new char[] { ',', ';' });
                string   sl    = "";
                foreach (string p in parts)
                {
                    if (string.Compare(p, slave, true) != 0)
                    {
                        sl += ";" + p;
                    }
                }
                sl = sl.Trim(';');
                if (sl.Length == 0)
                {
                    Console.Error.WriteLine("Cannot perform orphaned worker test.  Must have at least 2 machines in Slavelist tag in dfs.xml.");
                }
                else
                {
                    try
                    {
                        DFSUtils.ChangeDFSXMLSlaveList(dfs, dfspath, sl);

                        string result = Exec.Shell(exe + " clustercheck " + allhosts);
                        if (verbose)
                        {
                            Console.Write(result);
                        }
                        Console.WriteLine();
                        Console.WriteLine("-");
                        Console.WriteLine("Test case: Orphaned worker:");

                        string expResult = @"Orphaned worker: \\" + slave;
                        if (result.IndexOf(expResult) > -1)
                        {
                            Console.WriteLine("[PASSED] - " + string.Join(" ", args));
                        }
                        else
                        {
                            Console.WriteLine("[FAILED] - " + string.Join(" ", args));
                        }
                    }
                    catch (Exception e)
                    {
                        Console.Error.WriteLine("Error during orphaned worker test case: {0}", e.Message);
                    }
                    finally
                    {
                        cont = DFSUtils.UndoFileChanges(dfspath, dfsback);
                    }
                }
            }

            if (!cont)
            {
                return;
            }

            System.IO.File.Delete(dfsback);
            System.IO.File.Delete(slavedatback);
        }
Esempio n. 9
0
        public static void TestHost(string[] args)
        {
            if (args.Length < 2)
            {
                Console.Error.WriteLine("Error: LocalJobHost command needs argument: <dfsXmlPath>");
                return;
            }

            string dfspath = args[1];

            if (!dfspath.StartsWith(@"\\"))
            {
                Console.Error.WriteLine("Argument: <dfsXmlPath> must be a network path");
                return;
            }

            string surrogate = dfspath.Substring(2, dfspath.IndexOf(@"\", 2) - 2).ToUpper();

            System.Xml.XmlDocument dfs = new System.Xml.XmlDocument();
            string slavelist           = null;

            try
            {
                dfs.Load(dfspath);
                System.Xml.XmlNode node = dfs.SelectSingleNode("//SlaveList");
                if (node == null)
                {
                    Console.Error.WriteLine("SlaveList node is not found in dfs.xml");
                    return;
                }

                slavelist = node.InnerText.ToUpper();
                string[] parts = slavelist.Split(new char[] { ',', ';' });
                if (parts.Length < 2)
                {
                    Console.Error.WriteLine("Must have at least 2 hosts in SlaveList tag in dfs.xml");
                    return;
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error loading dfs.xml: {0}", e.Message);
                return;
            }

            string exe = Exec.GetQizmtExe();

            //Test Host tag, empty and non-empty.
            {
                string[] hosts        = slavelist.Split(new char[] { ',', ';' });
                string   nonsurrogate = null;
                string   firsthost    = hosts[0];
                foreach (string host in hosts)
                {
                    if (string.Compare(surrogate, host, true) != 0)
                    {
                        nonsurrogate = host;
                        break;
                    }
                }
                if (nonsurrogate == null)
                {
                    Console.Error.WriteLine("Non-surrogate is not found from dfs.xml");
                    return;
                }

                string mr = @"<SourceCode>
  <Jobs>
    <Job Name=`mash_Preprocessing` Custodian=`` Email=``>
      <IOSettings>
        <JobType>local</JobType>
        <Host>xxx</Host>
      </IOSettings>
      <Local>
        <![CDATA[
        public virtual void Local()
        {
            Qizmt_Log(`DNS=` + System.Net.Dns.GetHostName());
        }
        ]]>
      </Local>
    </Job>
  </Jobs>
</SourceCode>".Replace('`', '"').Replace("xxx", nonsurrogate);

                string dir = @"\\" + System.Net.Dns.GetHostName() + @"\" + Environment.CurrentDirectory.Replace(':', '$') + @"\RegressionTest\LocalJobHostTest\";
                if (System.IO.Directory.Exists(dir))
                {
                    System.IO.Directory.Delete(dir, true);
                }
                System.IO.Directory.CreateDirectory(dir);

                System.IO.File.WriteAllText(dir + "regressionTest_localJobHost_nonEmptyHost.xml", mr);

                mr = @"<SourceCode>
  <Jobs>
    <Job Name=`mash_Preprocessing` Custodian=`` Email=``>
      <IOSettings>
        <JobType>local</JobType>
      </IOSettings>
      <Local>
        <![CDATA[
        public virtual void Local()
        {
            Qizmt_Log(`DNS=` + System.Net.Dns.GetHostName());
        }
        ]]>
      </Local>
    </Job>
  </Jobs>
</SourceCode>".Replace('`', '"');

                System.IO.File.WriteAllText(dir + "regressionTest_localJobHost_emptyHost.xml", mr);

                Exec.Shell(exe + " del regressionTest_localJobHost_nonEmptyHost.xml");
                Exec.Shell(exe + " del regressionTest_localJobHost_emptyHost.xml");
                Exec.Shell(exe + " importdir " + dir);

                Console.WriteLine("-");
                Console.WriteLine("Testing non-empty host in local job...");

                string output   = Exec.Shell(exe + " exec regressionTest_localJobHost_nonEmptyHost.xml");
                string expected = "DNS=" + nonsurrogate;
                if (output.IndexOf(expected, StringComparison.OrdinalIgnoreCase) > -1)
                {
                    Console.WriteLine("[PASSED] - " + string.Join(" ", args));
                }
                else
                {
                    Console.WriteLine("[FAILED] - " + string.Join(" ", args));
                }

                Console.WriteLine("-");
                Console.WriteLine("Testing empty host in local job...");

                output   = Exec.Shell(exe + " exec regressionTest_localJobHost_emptyHost.xml");
                expected = "DNS=" + firsthost;
                if (output.IndexOf(expected, StringComparison.OrdinalIgnoreCase) > -1)
                {
                    Console.WriteLine("[PASSED] - " + string.Join(" ", args));
                }
                else
                {
                    Console.WriteLine("[FAILED] - " + string.Join(" ", args));
                }

                //Clean up
                System.IO.Directory.Delete(dir, true);
                Exec.Shell(exe + " del regressionTest_localJobHost_nonEmptyHost.xml");
                Exec.Shell(exe + " del regressionTest_localJobHost_emptyHost.xml");
            }
        }
Esempio n. 10
0
        public static void TestAddRefNonParticipatingCluster(string[] args)
        {
            if (args.Length < 2)
            {
                Console.Error.WriteLine("Error: LocalJobAddRefNonParticipatingCluster command needs argument: <dfsXmlPath>");
                return;
            }

            string dfspath = args[1];

            if (!dfspath.StartsWith(@"\\"))
            {
                Console.Error.WriteLine("Argument: <dfsXmlPath> must be a network path");
                return;
            }

            string surrogate = dfspath.Substring(2, dfspath.IndexOf(@"\", 2) - 2).ToUpper();

            System.Xml.XmlDocument dfs = new System.Xml.XmlDocument();
            string slavelist           = null;

            try
            {
                dfs.Load(dfspath);
                System.Xml.XmlNode node = dfs.SelectSingleNode("//SlaveList");
                if (node == null)
                {
                    Console.Error.WriteLine("SlaveList node is not found in dfs.xml");
                    return;
                }

                slavelist = node.InnerText.ToUpper();
                string[] parts = slavelist.Split(new char[] { ',', ';' });
                if (parts.Length < 2)
                {
                    Console.Error.WriteLine("Must have at least 2 hosts in SlaveList tag in dfs.xml");
                    return;
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error loading dfs.xml: {0}", e.Message);
                return;
            }

            string dfsback = null;
            bool   ok      = false;

            try
            {
                if (slavelist.IndexOf(surrogate, StringComparison.OrdinalIgnoreCase) > -1)
                {
                    if (!DFSUtils.MakeFileBackup(dfspath, ref dfsback))
                    {
                        Console.Error.WriteLine("Error while backing up dfs.xml.");
                        return;
                    }
                    string   newslavelist = "";
                    string[] hosts        = slavelist.Split(new char[] { ',', ';' });
                    foreach (string host in hosts)
                    {
                        if (string.Compare(surrogate, host, true) != 0)
                        {
                            newslavelist = ";" + host;
                        }
                    }
                    newslavelist = newslavelist.Trim(';');
                    DFSUtils.ChangeDFSXMLSlaveList(dfs, dfspath, newslavelist);
                }

                string mr = @"<SourceCode>
  <Jobs>
    <Job>
      <Narrative>
        <Name>regression_test_put_dll_Preprocessing</Name>
        <Custodian></Custodian>
        <email></email>
      </Narrative>
      <IOSettings>
        <JobType>local</JobType>
      </IOSettings>
      <Local>
        <![CDATA[
        public virtual void Local()
        {
            Shell(@`Qizmt del regressionTestLocalJobAddRef4A30DE94_testdll.dll`);
        }
        ]]>
      </Local>
    </Job>
    <Job>
      <Narrative>
        <Name>regression_test_put_dll PUT DLL</Name>
        <Custodian></Custodian>
        <email></email>
      </Narrative>
      <IOSettings>
        <JobType>local</JobType>
      </IOSettings>
      <Local>
        <![CDATA[
        public virtual void Local()
        {
            string localdir = IOUtils.GetTempDirectory();            
            string fn = `regressionTestLocalJobAddRef4A30DE94_testdll.dll`;
            string localfn = localdir + @`\` + Guid.NewGuid().ToString() + fn;            
            string testdlldatab64 = `TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyB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AAAAAAAgAAAMAAAAMDcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA`;
            byte[] testdlldata = System.Convert.FromBase64String(testdlldatab64);
            System.IO.File.WriteAllBytes(localfn, testdlldata);
            try
            {
                Shell(@`Qizmt dfs put ` + localfn + ` ` + fn);
            }
            finally
            {
                System.IO.File.Delete(localfn);
            }
        }
        ]]>
      </Local>
    </Job>
    <Job Name=`testdll` Custodian=`` email=``>
      <Add Reference=`regressionTestLocalJobAddRef4A30DE94_testdll.dll` Type=`dfs` />
      <Using>regressionTestLocalJobAddRef4A30DE94_testdll</Using>
      <IOSettings>
        <JobType>local</JobType>
      </IOSettings>
      <Local>
        <![CDATA[
        public virtual void Local()
        {
            Qizmt_Log(TestClass.SayHi());
        }
        ]]>
      </Local>
    </Job>
    <Job Name=`testdll` Custodian=`` email=``>
      <IOSettings>
        <JobType>local</JobType>
      </IOSettings>
      <Local>
        <![CDATA[
        public virtual void Local()
        {
            Shell(@`Qizmt del regressionTestLocalJobAddRef4A30DE94_testdll.dll`);
        }
        ]]>
      </Local>
    </Job>
  </Jobs>
</SourceCode>
".Replace('`', '"');

                string dir = @"\\" + System.Net.Dns.GetHostName() + @"\" + Environment.CurrentDirectory.Replace(':', '$') + @"\RegressionTest\LocalJobAddRefTest\";
                if (System.IO.Directory.Exists(dir))
                {
                    System.IO.Directory.Delete(dir, true);
                }
                System.IO.Directory.CreateDirectory(dir);

                System.IO.File.WriteAllText(dir + "regressionTest_localJobAddRef.xml", mr);

                string exe = Exec.GetQizmtExe();
                Exec.Shell(exe + " del regressionTest_localJobAddRef.xml");
                Exec.Shell(exe + " importdir " + dir);

                Console.WriteLine("-");
                Console.WriteLine("Testing add reference in a local job on a non-participating cluster...");

                string output   = Exec.Shell(exe + " exec regressionTest_localJobAddRef.xml");
                string expected = "hi there";
                if (output.IndexOf(expected, StringComparison.OrdinalIgnoreCase) > -1)
                {
                    Console.WriteLine("[PASSED] - " + string.Join(" ", args));
                }
                else
                {
                    Console.WriteLine("[FAILED] - " + string.Join(" ", args));
                }

                //Clean up
                Exec.Shell(exe + " del regressionTest_localJobAddRef.xml");
                System.IO.Directory.Delete(dir, true);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error during local job add reference testing: {0}", e.Message);
            }
            finally
            {
                if (dfsback != null)
                {
                    ok = DFSUtils.UndoFileChanges(dfspath, dfsback);
                }
            }

            if (dfsback != null && ok)
            {
                System.IO.File.Delete(dfsback);
            }
        }
Esempio n. 11
0
        public static void TestKillallProxy(string[] args)
        {
            string job = @"<SourceCode>
  <Jobs>
    <Job Name=`m_Preprocessing`>
      <IOSettings>
        <JobType>local</JobType>
      </IOSettings>
      <Local>
        <![CDATA[
        public virtual void Local()
        {
            System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
        }
        ]]>
      </Local>
    </Job>
    <Job Name=`m_Preprocessing`>
      <IOSettings>
        <JobType>local</JobType>
      </IOSettings>
      <Local>
        <![CDATA[
        public virtual void Local()
        {
            Qizmt_Log(`B40735E5-8B8D-4638-8908-CD2AB024C3A7`);
        }
        ]]>
      </Local>
    </Job>
  </Jobs>
</SourceCode>".Replace('`', '"');

            string dir = @"\\" + System.Net.Dns.GetHostName() + @"\" + Environment.CurrentDirectory.Replace(':', '$') + @"\RegressionTest\B40735E5-8B8D-4638-8908-CD2AB024C3A7\";

            if (System.IO.Directory.Exists(dir))
            {
                System.IO.Directory.Delete(dir, true);
            }
            System.IO.Directory.CreateDirectory(dir);

            System.IO.File.WriteAllText(dir + @"B40735E5-8B8D-4638-8908-CD2AB024C3A7.xml", job);

            string exe = Exec.GetQizmtExe();

            Exec.Shell(exe + @" del B40735E5-8B8D-4638-8908-CD2AB024C3A7.xml");
            Exec.Shell(exe + @" importdir " + dir);
            System.IO.Directory.Delete(dir, true);

            bool guidfound = false;
            bool jobdone   = false;

            System.Threading.Thread th = new Thread(new ThreadStart(delegate()
            {
                try
                {
                    Console.WriteLine("Running job...");
                    string results = Exec.Shell(exe + @" exec B40735E5-8B8D-4638-8908-CD2AB024C3A7.xml");
                    Console.WriteLine("Job output: {0}", results);
                    if (results.IndexOf("B40735E5-8B8D-4638-8908-CD2AB024C3A7") > -1)
                    {
                        guidfound = true;
                    }
                }
                catch
                {
                }
                jobdone = true;
            }));

            th.Start();
            System.Threading.Thread.Sleep(5000);

            if (guidfound)
            {
                throw new Exception("Job exited normally.  Job error.");
            }
            if (jobdone)
            {
                throw new Exception("Job finished too early, cannot run killall to kill it.");
            }

            Console.WriteLine("Running killall proxy...");
            Exec.Shell(exe + " killall -f proxy");

            System.Threading.Thread.Sleep(2000);

            if (guidfound)
            {
                throw new Exception("Job exited normally.  Job error.");
            }
            if (!jobdone)
            {
                throw new Exception("Job didn't return.  Killall didn't kill the job.");
            }

            Console.WriteLine("[PASSED] - " + string.Join(" ", args));

            Exec.Shell(exe + @" del B40735E5-8B8D-4638-8908-CD2AB024C3A7.xml");
        }