Ejemplo n.º 1
0
        NPSBDummyLib.EchoCondition GetTestEchoConfig()
        {
            var config        = GetTestBaseConfig();
            var repeatCount   = textBox8.Text.ToInt32();
            var repeatTimeSec = textBox7.Text.ToInt32();

            var echoCondi = new NPSBDummyLib.EchoCondition();

            echoCondi.IP            = DummyManager.GetDummyInfo.RmoteIP;
            echoCondi.Port          = DummyManager.GetDummyInfo.RemotePort;
            echoCondi.PacketSizeMin = textBox10.Text.ToInt32();
            echoCondi.PacketSizeMax = textBox11.Text.ToInt32();
            echoCondi.Set(repeatCount, repeatTimeSec);

            return(echoCondi);
        }
        public async Task TestRepeatEchoAsync(Int64 testUniqueId, EchoCondition echoCondi)
        {
            var startTime   = DateTime.Now;
            var testResults = new List <Task <(bool, string)> >();

            for (int i = 0; i < DummyList.Count; ++i)
            {
                var dummy = DummyList[i];
                testResults.Add(Task <(bool, string)> .Run(async() => {
                    var echoAction = new ActionEcho();
                    return(await echoAction.EchoAsync(dummy, echoCondi));
                }));
            }

            await Task.WhenAll(testResults.ToArray());

            TestResultMgr.AddTestResult(testUniqueId, Config.ActionCase, DummyList, startTime);
        }
Ejemplo n.º 3
0
        //public Action<string> MsgFunc; //[진행중] [완료] [실패]

        public async Task <(bool, string)> EchoAsync(Dummy dummy, EchoCondition cond)
        {
            var clientSocket = dummy.ClientSocket;

            SendPacket.Init(cond.PacketSizeMax);
            RecvPacket.Init(cond.PacketSizeMax);

            int curEchoCount = 0;

            try
            {
                var(result, error) = await clientSocket.ConnectAsync(cond.IP, cond.Port);

                if (result == false)
                {
                    return(false, error);
                }

                while (true)
                {
                    // 스레드 잘 사용하는지 알기 위해 스레드 번호찍기
                    //Utils.Logger.Debug($"Echo-Send. ClientIndex: {dummy.Index}");

                    SendPacket.SetData(cond.PacketSizeMin, cond.PacketSizeMax);
                    var sendError = await clientSocket.SendAsync(SendPacket.BufferSize, SendPacket.BufferData);

                    if (sendError != "")
                    {
                        return(End(dummy, curEchoCount, false, sendError));
                    }


                    // 스레드 잘 사용하는지 알기 위해 스레드 번호찍기
                    //Utils.Logger.Debug($"Echo-Recv. ClientIndex: {dummy.Index}");

                    var(recvCount, recvError) = await clientSocket.ReceiveAsync(RecvPacket.BufferSize, RecvPacket.RecvBuffer);

                    if (recvError != "")
                    {
                        return(End(dummy, curEchoCount, false, recvError));
                    }

                    if (recvCount > 0)
                    {
                        RecvPacket.Received(recvCount);
                    }
                    else if (recvCount == 0)
                    {
                        return(End(dummy, curEchoCount, false, "연결 종료"));
                    }


                    if (SendPacket.BodyData() != RecvPacket.BodyData())
                    {
                        return(End(dummy, curEchoCount, false, "데이터 틀림"));
                    }


                    ++curEchoCount;

                    if (cond.IsEnd(curEchoCount))
                    {
                        break;
                    }
                }

                return(End(dummy, curEchoCount, true, ""));
            }
            catch (Exception ex)
            {
                return(false, ex.ToString());
            }
        }