Ejemplo n.º 1
0
        public void InstantCompareLinuxToVMSCGI()
        {
            //http://www.usbr.gov/pn-bin/webdaycsv.pl?parameter=mddo%20ch,wcao%20q&syer=2015&smnth=4&sdy=5&eyer=2015&emnth=4&edy=5&format=2
            string payload = "parameter=mddo ch,wcao q,boii Z,boii ob,&syer=2015&smnth=10&sdy=30&eyer=2015&emnth=11&edy=4&format=2";
            //Program.Main(new string[] { "--cgi=instant", "--payload=?"+payload });

            TimeSeriesDatabase  db = TimeSeriesDatabase.InitDatabase(new Arguments(new string[] {}));
            CsvTimeSeriesWriter c  = new CsvTimeSeriesWriter(db);
            var fn = FileUtility.GetTempFileName(".txt");

            c.Run(TimeInterval.Hourly, payload, fn);

            TextFile tf = new TextFile(fn);

            tf.DeleteLines(0, 1);

            var fnhyd0 = FileUtility.GetTempFileName(".txt");

            Web.GetFile("http://www.usbr.gov/pn-bin/webdaycsv.pl?" + payload, fnhyd0);

            var tf2  = new TextFile(fnhyd0);
            var diff = TextFile.Compare(tf, tf2);

            if (diff.Length > 0)
            {
                for (int i = 0; i < tf.Length; i++)
                {
                    Console.WriteLine(tf[i]);
                }
            }
            Assert.IsTrue(diff.Length == 0);
        }
Ejemplo n.º 2
0
        private static void RunTest(string payload)
        {
            Performance         p  = new Performance();
            TimeSeriesDatabase  db = TimeSeriesDatabase.InitDatabase(new Arguments(new string[] { }));
            CsvTimeSeriesWriter c  = new CsvTimeSeriesWriter(db);
            var fn = FileUtility.GetTempFileName(".txt");

            fn = "";
            c.Run(TimeInterval.Hourly, payload, fn);

            if (File.Exists(fn))
            {
                p.Report(File.ReadAllLines(fn).Length + " lines read");
            }
            else
            {
                p.Report();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Examples:
        ///
        /// --cgi=sites --propertyFilter=program:agrimet --json_required_properties=json_extra
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            string propertyFilter      = "";
            var    cgi                 = "";
            var    json_property_stubs = "";
            var    payload             = "";
            var    p       = new OptionSet();
            var    format  = "json";
            var    verbose = false;

            p.Add("server");
            p.Add("cgi=", "required cgi to execute cgi=sites or cgi=series", x => cgi = x);
            p.Add("json_property_stubs=", "comma separated list of properties (i.e. 'region,url,') to created empty stubs if neeed ",
                  x => json_property_stubs = x);
            p.Add("propertyFilter=", "property filter like program:agrimet", x => propertyFilter = x);
            p.Add("payload=", "test query data for a CGI", x => payload = x);
            p.Add("format=", "format json(default) | csv ", x => format = x);
            p.Add("verbose", " get more details", x => verbose          = true);
            try
            {
                p.Parse(args);
            }
            catch (OptionException e)
            {
                Console.WriteLine(e.Message);
            }
            if (cgi == "")
            {
                ShowHelp(p);
                return;
            }

            if (verbose)
            {
                Logger.EnableLogger();
                Logger.WriteLine("verbose =true");
            }

            var db = TimeSeriesDatabase.InitDatabase(new Arguments(args));

            if (cgi == "inventory")
            {
                Console.Write("Content-Type: text/html\n\n");
                db.Inventory();
            }
            else
            if (cgi == "sites")
            {
                if (format == "json")
                {
                    JSONSites d = new JSONSites(db);
                    d.Execute(json_property_stubs.Split(','), propertyFilter);
                }
                else if (format == "csv")
                {
                    CsvTable c = new CsvTable(db);
                    c.Execute(propertyFilter);
                }
            }
            else
            if (cgi == "instant")
            {
                CsvTimeSeriesWriter c = new CsvTimeSeriesWriter(db);
                c.Run(TimeInterval.Hourly, payload);
            }
            else
            if (cgi == "site")
            {
                SiteInfo si = new SiteInfo(db);
                si.Run(payload);
            }
            else
            if (cgi == "test-perf-large")
            {
                TestCGI c = new TestCGI();
                c.PerfTestLarge();
            }
            else
            if (cgi == "test-perf-small")
            {
                TestCGI c = new TestCGI();
                c.PerfTestSmall();
            }
            else
            if (cgi == "dump")
            {
                TestCGI c = new TestCGI();
                c.DumpTest();
            }
            else
            {
                Console.WriteLine("invalid cgi: " + cgi);
            }
        }