示例#1
0
        static void Main(string[] args)
        {
            RSACryptoManager    cMgr = new RSACryptoManager("cspblob.bin");
            HttpRequestsManager hMgr = new HttpRequestsManager("http://localhost:5000/api/ingress/influx/", true);
            ConcurrentDictionary <string, int> results = new ConcurrentDictionary <string, int>();

            Stopwatch timer2 = new Stopwatch();

            timer2.Start();

            int legitTraffic          = 500;
            int sigFailTraffic        = 200;
            int invalidPayloadTraffic = 200;

            //var tasks = Enumerable.Range(0, taskCount).Select(p => SendDataToIngress2(cMgr, hMgr, results));
            //Task.WhenAll(tasks).Wait();
            for (int i = 1; i <= legitTraffic; i++)
            {
                InfluxTelemetry inobj = generateRandomData(cMgr, true, true);
                Task <string>   task  = Task.Run <string>(async() => await SendDataToIngress2(hMgr, inobj));
                recordTestResults(task, results);
            }
            for (int i = 1; i <= sigFailTraffic; i++)
            {
                InfluxTelemetry inobj = generateRandomData(cMgr, true, false);
                Task <string>   task  = Task.Run <string>(async() => await SendDataToIngress2(hMgr, inobj));
                recordTestResults(task, results);
            }
            for (int i = 1; i <= invalidPayloadTraffic; i++)
            {
                InfluxTelemetry inobj = generateRandomData(cMgr, false, false);
                Task <string>   task  = Task.Run <string>(async() => await SendDataToIngress2(hMgr, inobj));
                recordTestResults(task, results);
            }

            timer2.Stop();
            TimeSpan timeTaken2 = timer2.Elapsed;

            Console.WriteLine(timeTaken2.ToString());

            printTestResults(results);
        }
示例#2
0
        public static InfluxTelemetry generateRandomData(RSACryptoManager cm, bool validData, bool validSig)
        {
            List <string> lst  = new List <string>();
            Random        r    = new Random();
            int           rInt = r.Next(100, 999);

            lst.Add("weather,location=us-midwest temperature=" + rInt + " 1465839830100400" + rInt);
            lst.Add("weather,location=us-east temperature=" + rInt + " 1465839830100400" + rInt);

            string payload = string.Join("", lst);

            return(validData?
                   new InfluxTelemetry()
            {
                NodeId = _nodeId, Payload = lst, Signature = validSig ? cm.signData(payload) : ""
            } :
                   new InfluxTelemetry()
            {
                NodeId = "", Signature = validSig ? cm.signData(payload) : ""
            });
        }