Пример #1
0
        /// <summary>
        /// This method executes the test cases for the configured endpoint.
        /// In case of multiple channel test cases, this endpoint value is ignored and new
        /// endpoint is used to connect to the server specified in test configuration.
        /// </summary>
        /// <param name="endpoint">This parameter stores an endpoint of the server.</param>
        public void ExecuteTestSequence(ConfiguredEndpoint endpoint)
        {
            lock (m_lock)
            {
                m_cancel = false;
            }

            if (endpoint.UpdateBeforeConnect)
            {
                // create the binding factory if it has not been created yet.
                if (m_bindingFactory == null)
                {
                    m_bindingFactory = BindingFactory.Create(m_configuration, m_messageContext);
                }

                endpoint.UpdateFromServer(m_bindingFactory);
            }

            ChannelContext selectedChannelContext = null;

            selectedChannelContext = InitializeChannel(endpoint, m_logFilePath);

            try
            {
                foreach (TestCase testCase in m_sequenceToExecute.TestCase)
                {
                    if (testCase.SkipTest || testCase.Name.StartsWith(TestCases.SerializerDirect))
                    {
                        continue;
                    }

                    try
                    {
                        TestUtils.ValidateTestCase(testCase, (int)testCase.Start);
                    }
                    catch (Exception e)
                    {
                        selectedChannelContext.EventLogger.LogErrorEvent(testCase, (int)testCase.Start, e);

                        if (m_sequenceToExecute.HaltOnError)
                        {
                            throw;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    TestCaseContext testCaseContext = TestUtils.GetExecutionContext(testCase);

                    try
                    {
                        ValidateTestContext(testCaseContext, testCase);
                    }
                    catch (Exception e)
                    {
                        selectedChannelContext.EventLogger.LogErrorEvent(testCase, (int)testCase.Start, e);

                        if (m_sequenceToExecute.HaltOnError)
                        {
                            throw;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    if (testCase.Name != TestCases.MultipleChannels)
                    {
                        ExecuteTestCase(selectedChannelContext, testCaseContext, testCase);
                    }
                    else
                    {
                        Uri defaultUrl = new Uri(endpoint.Description.EndpointUrl);

                        // In case of multiple channel get endpoint urls from the test case file.
                        List <ChannelContext>     channelContextList     = new List <ChannelContext>();
                        List <ConfiguredEndpoint> configuredEndpointList = new List <ConfiguredEndpoint>();
                        for (int serverCnt = 0; serverCnt < testCaseContext.ServerDetails.Count; serverCnt++)
                        {
                            string serverURL = testCaseContext.ServerDetails[serverCnt].Url;
                            serverURL = serverURL.Replace("localhost", defaultUrl.DnsSafeHost);

                            //ConfiguredEndpointCollection endpointCollection = new ConfiguredEndpointCollection () ;
                            //ConfiguredEndpoint serverendpoint = endpointCollection.Create(serverURL);
                            ConfiguredEndpoint serverendpoint = (ConfiguredEndpoint)endpoint.Clone();

                            // slow systems may not be able to renew tokens fast enough when overloaded with channels.
                            serverendpoint.Configuration.SecurityTokenLifetime = 60000;

                            serverendpoint.Description.EndpointUrl = serverURL;
                            configuredEndpointList.Add(serverendpoint);

                            //For each channel get the log file name as <default file name>_<server name>_<channel index>.
                            for (int channelCnt = 0; channelCnt < testCaseContext.ChannelsPerServer; channelCnt++)
                            {
                                string logFileSuffix = "_" + testCaseContext.ServerDetails[serverCnt].Name + "_" + channelCnt.ToString();
                                string logFileName   = m_logFilePath.Replace(".xml", logFileSuffix) + ".xml";

                                ChannelContext channelContext = InitializeChannel(configuredEndpointList[serverCnt],
                                                                                  logFileName);
                                channelContextList.Add(channelContext);
                            }
                        }

                        try
                        {
                            WaitHandle[] waitHandles = new WaitHandle[channelContextList.Count];

                            for (int iCtr = 0; iCtr < channelContextList.Count; iCtr++)
                            {
                                waitHandles[iCtr] = channelContextList[iCtr].TestCaseComplete;
                                ThreadPool.QueueUserWorkItem(ExecuteTestCase, new object[] { channelContextList[iCtr], testCaseContext, testCase });
                            }

                            WaitHandle.WaitAll(waitHandles);
                        }
                        finally
                        {
                            for (int iCtr = 0; iCtr < channelContextList.Count; iCtr++)
                            {
                                WindupChannel(channelContextList[iCtr]);
                            }
                        }
                    }
                }
            }
            finally
            {
                WindupChannel(selectedChannelContext);
            }

            RaiseEvent(new TestSequenceEventArgs(0, "Done", 0));
        }
Пример #2
0
        /// <summary>
        /// This method executes the test cases for the configured endpoint.
        /// In case of multiple channel test cases, this endpoint value is ignored and new
        /// endpoint is used to connect to the server specified in test configuration.
        /// </summary>
        /// <param name="endpoint">This parameter stores an endpoint of the server.</param>
        public void ExecuteTestSequence(ConfiguredEndpoint endpoint)
        {
            lock (m_lock)
            {
                m_cancel = false;
            }

            if (endpoint.UpdateBeforeConnect)
            {
                // create the binding factory if it has not been created yet.
                if (m_bindingFactory == null)
                {
                    m_bindingFactory = BindingFactory.Create(m_configuration, m_messageContext);
                }

                endpoint.UpdateFromServer(m_bindingFactory);
            }

            ChannelContext selectedChannelContext = null;

            selectedChannelContext = InitializeChannel(endpoint, m_logFilePath);

            try
            {
                foreach (TestCase testCase in m_sequenceToExecute.TestCase)
                {
                    if (testCase.SkipTest || testCase.Name.StartsWith(TestCases.SerializerDirect))
                    {
                        continue;
                    }
                    
                    try
                    {
                        TestUtils.ValidateTestCase(testCase, (int)testCase.Start);
                    }
                    catch (Exception e)
                    {
                        selectedChannelContext.EventLogger.LogErrorEvent(testCase, (int)testCase.Start, e);

                        if (m_sequenceToExecute.HaltOnError)
                        {
                            throw;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    TestCaseContext testCaseContext = TestUtils.GetExecutionContext(testCase);

                    try
                    {
                        ValidateTestContext(testCaseContext, testCase);
                    }
                    catch (Exception e)
                    {
                        selectedChannelContext.EventLogger.LogErrorEvent(testCase, (int)testCase.Start, e);

                        if (m_sequenceToExecute.HaltOnError)
                        {
                            throw;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    if (testCase.Name != TestCases.MultipleChannels)
                    {
                        ExecuteTestCase(selectedChannelContext, testCaseContext, testCase);
                    }
                    else
                    {
                        Uri defaultUrl = new Uri(endpoint.Description.EndpointUrl);

                        // In case of multiple channel get endpoint urls from the test case file.
                        List<ChannelContext> channelContextList = new List<ChannelContext>();
                        List<ConfiguredEndpoint> configuredEndpointList = new List<ConfiguredEndpoint>();
                        for (int serverCnt = 0; serverCnt < testCaseContext.ServerDetails.Count; serverCnt++)
                        {
                            string serverURL = testCaseContext.ServerDetails[serverCnt].Url;
                            serverURL = serverURL.Replace("localhost", defaultUrl.DnsSafeHost);

                            //ConfiguredEndpointCollection endpointCollection = new ConfiguredEndpointCollection () ;
                            //ConfiguredEndpoint serverendpoint = endpointCollection.Create(serverURL);
                            ConfiguredEndpoint serverendpoint = (ConfiguredEndpoint)endpoint.Clone();

                            // slow systems may not be able to renew tokens fast enough when overloaded with channels.
                            serverendpoint.Configuration.SecurityTokenLifetime = 60000;

                            serverendpoint.Description.EndpointUrl = serverURL;
                            configuredEndpointList.Add(serverendpoint);

                            //For each channel get the log file name as <default file name>_<server name>_<channel index>.
                            for (int channelCnt = 0; channelCnt < testCaseContext.ChannelsPerServer; channelCnt++)
                            {
                                string logFileSuffix = "_" + testCaseContext.ServerDetails[serverCnt].Name + "_" + channelCnt.ToString();
                                string logFileName = m_logFilePath.Replace(".xml", logFileSuffix) + ".xml";

                                ChannelContext channelContext = InitializeChannel(configuredEndpointList[serverCnt],
                                logFileName);
                                channelContextList.Add(channelContext);
                            }
                        }

                        try
                        {
                            WaitHandle[] waitHandles = new WaitHandle[channelContextList.Count];

                            for (int iCtr = 0; iCtr < channelContextList.Count; iCtr++)
                            {
                                waitHandles[iCtr] = channelContextList[iCtr].TestCaseComplete;
                                ThreadPool.QueueUserWorkItem(ExecuteTestCase, new object[] { channelContextList[iCtr], testCaseContext, testCase });
                            }

                            WaitHandle.WaitAll(waitHandles);
                        }
                        finally
                        {
                            for (int iCtr = 0; iCtr < channelContextList.Count; iCtr++)
                            {
                                WindupChannel(channelContextList[iCtr]);
                            }
                        }
                    }
                }
            }
            finally
            {
                WindupChannel(selectedChannelContext);
            }

            RaiseEvent(new TestSequenceEventArgs(0, "Done", 0));
        }