public void AgentRestart()
        {
            TestAgent t = new TestAgent(output);

            t.Start();
            Assert.AreEqual<ThreadState>(ThreadState.Running, t.State, "Agent state is wrong after initial start");
            Thread.Sleep(100);

            t.Stop();
            Assert.AreEqual<ThreadState>(ThreadState.Stopped, t.State, "Agent state is wrong after initial stop");
            Thread.Sleep(100);

            try
            {
                t.Start();
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while restarting agent: " + ex.ToString());
                throw;
            }
            Assert.AreEqual<ThreadState>(ThreadState.Running, t.State, "Agent state is wrong after restart");
            Thread.Sleep(100);

            t.Stop();
            Assert.AreEqual<ThreadState>(ThreadState.Stopped, t.State, "Agent state is wrong after final stop");
            Thread.Sleep(100);
        }
        public void AgentRestart()
        {
            TestAgent t = new TestAgent(output);

            t.Start();
            Assert.Equal(ThreadState.Running, t.State); // "Agent state is wrong after initial start"
            Thread.Sleep(100);

            t.Stop();
            Assert.Equal(ThreadState.Stopped, t.State); // "Agent state is wrong after initial stop"
            Thread.Sleep(100);

            try
            {
                t.Start();
            }
            catch (Exception ex)
            {
                Assert.True(false, "Exception while restarting agent: " + ex);
                throw;
            }
            Assert.Equal(ThreadState.Running, t.State); // "Agent state is wrong after restart"
            Thread.Sleep(100);

            t.Stop();
            Assert.Equal(ThreadState.Stopped, t.State); // "Agent state is wrong after final stop"
            Thread.Sleep(100);
        }
Example #3
0
		public override bool Load(TestPackage package)
		{
            log.Info("Loading " + package.Name);
			Unload();

            RuntimeFramework runtimeFramework = package.Settings["RuntimeFramework"] as RuntimeFramework;
            if ( runtimeFramework == null )
                 runtimeFramework = RuntimeFramework.CurrentFramework;

            bool loaded = false;

			try
			{
				if (this.agent == null)
					this.agent = Services.TestAgency.GetAgent( 
						runtimeFramework, 
						20000 );
		
				if (this.agent == null)
					return false;
	
				if ( this.TestRunner == null )
					this.TestRunner = agent.CreateRunner(this.runnerID);

				loaded = base.Load (package);
                return loaded;
			}
			finally
			{
                // Clean up if the load failed
				if ( !loaded ) Unload();
			}
		}
Example #4
0
        public void AgentRestart()
        {
            TestAgent t = new TestAgent(output);

            t.Start();
            Assert.AreEqual <ThreadState>(ThreadState.Running, t.State, "Agent state is wrong after initial start");
            Thread.Sleep(100);

            t.Stop();
            Assert.AreEqual <ThreadState>(ThreadState.Stopped, t.State, "Agent state is wrong after initial stop");
            Thread.Sleep(100);

            try
            {
                t.Start();
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while restarting agent: " + ex.ToString());
                throw;
            }
            Assert.AreEqual <ThreadState>(ThreadState.Running, t.State, "Agent state is wrong after restart");
            Thread.Sleep(100);

            t.Stop();
            Assert.AreEqual <ThreadState>(ThreadState.Stopped, t.State, "Agent state is wrong after final stop");
            Thread.Sleep(100);
        }
Example #5
0
        public async Task JsonParserErrorWithMissingTitleAndStatusCode()
        {
            var settings        = CreateServiceAgentSettings();
            var serviceProvider = CreateServiceProvider(settings);
            var agent           = new TestAgent(serviceProvider, Options.Create(settings));

            agent.HttpClient = CreateClient();
            var message = new HttpResponseMessage();
            var body    = JsonConvert.SerializeObject(new
            {
                identifier      = "dbcd3004-3af0-4862-bad1-2c4013dec85f",
                extraParameters = (string)null
            });

            message.Content = new StringContent(body);

            var result = await Assert.ThrowsAsync <ServiceAgentException>(async() => await agent.ParseJsonWithError(message));

            Assert.True(result.Messages.Count() == 1);
            var extraParam = result.Messages.FirstOrDefault();

            Assert.NotNull(extraParam);
            Assert.Equal("json", extraParam.Key);
            Assert.True(extraParam.Value.Count() == 1);
            var errorMessage = extraParam.Value.FirstOrDefault();

            Assert.NotNull(errorMessage);
            Assert.Equal(body, errorMessage);
        }
Example #6
0
        public async Task JsonParserErrorWith1Param()
        {
            var settings        = CreateServiceAgentSettings();
            var serviceProvider = CreateServiceProvider(settings);
            var agent           = new TestAgent(serviceProvider, Options.Create(settings));

            agent.HttpClient = CreateClient();
            var message = new HttpResponseMessage();

            message.Content = new StringContent(@"
            {""identifier"": ""dbcd3004-3af0-4862-bad1-2c4013dec85f"",
               ""title"": ""Client validation failed."",
               ""status"": 400,
               ""extraParameters"": {
                                ""naam"": [""Naam moet uniek zijn"",""Test""],
                                    }
                        }");

            var result = await Assert.ThrowsAsync <ServiceAgentException>(async() => await agent.ParseJsonWithError(message));

            Assert.True(result.Messages.Count() == 1);
            var extraParam = result.Messages.FirstOrDefault();

            Assert.NotNull(extraParam);
            Assert.Equal("naam", extraParam.Key);
            Assert.True(extraParam.Value.Count() == 2);
            var errorMessage = extraParam.Value.FirstOrDefault();

            Assert.NotNull(errorMessage);
            Assert.Equal("Naam moet uniek zijn", errorMessage);
            errorMessage = extraParam.Value.LastOrDefault();
            Assert.NotNull(errorMessage);
            Assert.Equal("Test", errorMessage);
        }
Example #7
0
        /** {@inheritDoc} */
        public Boolean interrupt()
        {
            try
            {
                Monitor.Enter(interruptLock);
                TestAgent samp = currentSampler; // fetch once; must be done under lock
                if (samp is Interruptible)
                {                                // (also protects against null)
//                   log.warn("Interrupting: " + threadName + " sampler: " +samp.getName());
                    try
                    {
                        Boolean found = ((Interruptible)samp).interrupt();
                        if (!found)
                        {
//                            log.warn("No operation pending");
                        }
                        return(found);
                    }
                    catch (Exception e)
                    {
//                        log.warn("Caught Exception interrupting sampler: "+e.toString());
                    }
                }
                else if (samp != null)
                {
//                    log.warn("Sampler is not Interruptible: "+samp.getName());
                }
            }
            finally
            {
                Monitor.Exit(interruptLock);
            }
            return(false);
        }
        public void AgentRestart()
        {
            TestAgent t = new TestAgent(output);

            t.Start();
            Assert.Equal(ThreadState.Running, t.State); // "Agent state is wrong after initial start"
            Thread.Sleep(100);

            t.Stop();
            Assert.Equal(ThreadState.Stopped, t.State); // "Agent state is wrong after initial stop"
            Thread.Sleep(100);

            try
            {
                t.Start();
            }
            catch (Exception ex)
            {
                Assert.True(false, "Exception while restarting agent: " + ex);
                throw;
            }
            Assert.Equal(ThreadState.Running, t.State); // "Agent state is wrong after restart"
            Thread.Sleep(100);

            t.Stop();
            Assert.Equal(ThreadState.Stopped, t.State); // "Agent state is wrong after final stop"
            Thread.Sleep(100);
        }
Example #9
0
        public void TestAgent_Should_Provide_Dynamic_Call_Arguments()
        {
            var agent = new TestAgent();

             ((dynamic)agent).someMethod(arg: "Some String");

             Assert.True(agent.CalledMethod("someMethod").GetArgument<string>() == "Some String");
        }
Example #10
0
        public void TestAgent_Should_Save_Info_On_Dynamic_Calls()
        {
            var agent = new TestAgent();

             ((dynamic)agent).someMethod();

             Assert.True(agent.WasCalled("someMethod"));
        }
Example #11
0
        void LoadComplete()
        {
            AppContext.LoadingProgress -= _progressScreen.Progress;

            if (Settings.TestAgentEnabled)
            {
                _analyzer = new TestAgent(new AndroidViewProxy(AppContext, _baseActivity));
            }
        }
		public void Register( TestAgent agent )
		{
			AgentRecord r = agentData[agent.Id];
			if ( r == null )
                throw new ArgumentException(
                    string.Format("Agent {0} is not in the agency database", agent.Id),
                    "agentId");
            r.Agent = agent;
		}
Example #13
0
        public void CanReuseReleasedAgents()
        {
            TestAgent agent1 = agency.GetAgent(AgentType.ProcessAgent, 2000);
            int       id1    = agent1.Id;

            agency.ReleaseAgent(agent1);
            TestAgent agent2 = agency.GetAgent(AgentType.ProcessAgent, 2000);

            Assert.AreEqual(id1, agent2.Id);
        }
Example #14
0
        // TODO: Decide if we really want to do this
        //[Test]
        public void CanReuseReleasedAgents()
        {
            TestAgent agent1 = agency.GetAgent(20000);
            Guid      id1    = agent1.Id;

            agency.ReleaseAgent(agent1);
            TestAgent agent2 = agency.GetAgent(20000);

            Assert.AreEqual(id1, agent2.Id);
        }
		public override bool Load(TestPackage package)
		{
			if ( this.agent == null )
				this.agent = Services.TestAgency.GetAgent( AgentType.ProcessAgent, 5000 );		
	
			if ( this.TestRunner == null )
				this.TestRunner = agent.CreateRunner(this.runnerID);

			return base.Load (package);
		}
Example #16
0
        public TestAgentNav(TestAgent agent)
            : this()
        {
            var itemGroup = Find(z => z.ControllerName.Equals("TestAgents", StringComparison.OrdinalIgnoreCase));

            itemGroup.Children.
            Add(new NavItem {
                Text = agent.Name, ControllerName = "TestAgents", ActionName = "show", RouteValues = new RouteValueDictionary(new { id = agent.Id })
            });
        }
 public void Setup()
 {
     Adk.Initialize();
      TransportPlugin tp = new InMemoryTransportPlugin();
      Adk.InstallTransport(tp);
      fAgent = new TestAgent();
      fAgent.Initialize();
      fAgent.Properties.TransportProtocol=tp.Protocol;
      fZone = (TestZoneImpl)fAgent.ZoneFactory.GetInstance("test", "http://test");
 }
		public void Dispose()
		{
			if ( TestRunner != null )
				this.TestRunner.Unload();

			if ( this.agent != null )
				Services.TestAgency.ReleaseAgent(this.agent);

			this.TestRunner = null;
			this.agent = null;
		}
        public void Setup()
        {
            Adk.Initialize();
            TransportPlugin tp = new InMemoryTransportPlugin();

            Adk.InstallTransport(tp);
            fAgent = new TestAgent();
            fAgent.Initialize();
            fAgent.Properties.TransportProtocol = tp.Protocol;
            fZone = (TestZoneImpl)fAgent.ZoneFactory.GetInstance("test", "http://test");
        } //end method Setup
Example #20
0
        public async Task GetAsString()
        {
            var settings = CreateServiceAgentSettings();
            var serviceProvider = CreateServiceProvider(settings);
            var agent = new TestAgent(serviceProvider, Options.Create(settings));
            agent.HttpClient = CreateClient();

            var response = await agent.GetTestDataAsStringAsync();

            Assert.NotNull(response);
            Assert.Equal("{\"name\":\"Name\",\"number\":150}", response);
        }
Example #21
0
        /**
         * Configures sampler from SamplePackage extracted from Test plan and returns it
         * @param sampler {@link Sampler}
         * @return {@link SamplePackage}
         */
        public ExecutionPackage configureSampler(TestAgent sampler)
        {
            ExecutionPackage pack;

            if (samplerConfigMap.TryGetValue(sampler, out pack))
            {
                pack.SetSampler(sampler);
                ConfigureWithConfigElements(sampler, pack.GetConfigs());
            }

            return(pack);
        }
Example #22
0
        public async Task Get()
        {
            var settings = CreateServiceAgentSettings();
            var serviceProvider = CreateServiceProvider(settings);
            var agent = new TestAgent(serviceProvider, Options.Create(settings));
            agent.HttpClient = CreateClient();

            var response = await agent.GetTestDataAsync();

            Assert.NotNull(response);
            Assert.Equal("Name", response.Name);
            Assert.Equal(150, response.Number);
        }
Example #23
0
        public async Task Delete()
        {
            var settings = CreateServiceAgentSettings();
            var serviceProvider = CreateServiceProvider(settings);
            var agent = new TestAgent(serviceProvider, Options.Create(settings));
            agent.HttpClient = CreateClient();
            await agent.DeleteAsync();

            var sentData = await agent.GetPreviousDataAsync();
            Assert.NotNull(sentData);
            Assert.Equal("Deleted", sentData.Name);
            Assert.Equal(123, sentData.Number);
        }
Example #24
0
        public async Task PostWithOtherReturnType()
        {
            var settings = CreateServiceAgentSettings();
            var serviceProvider = CreateServiceProvider(settings);
            var agent = new TestAgent(serviceProvider, Options.Create(settings));
            agent.HttpClient = CreateClient();

            var response = await agent.PostTestDataWithOtherReturnTypeAsync(new TestModel { Name = "Name2", Number = 250 });

            Assert.NotNull(response);
            Assert.Equal("Name2", response.Something);
            Assert.Equal(250, response.Id);
        }
Example #25
0
        public async Task Put()
        {
            var settings = CreateServiceAgentSettings();
            var serviceProvider = CreateServiceProvider(settings);
            var agent = new TestAgent(serviceProvider, Options.Create(settings));
            agent.HttpClient = CreateClient();

            var response = await agent.PutTestDataAsync(new TestModel { Name = "Name2", Number = 250 });

            Assert.NotNull(response);
            Assert.Equal("Name2", response.Name);
            Assert.Equal(250, response.Number);
        }
Example #26
0
 private void Init()
 {
     variables              = null;
     previousResult         = null;
     currentSampler         = null;
     previousSampler        = null;
     samplingStarted        = false;
     threadNum              = 0;
     nThread                = null;
     isReinitSubControllers = false;
     samplerContext.Clear();
     restartNextLoop = false;
 }
Example #27
0
        public override void Dispose()
        {
            // Do this first, because the next step will
            // make the downstream runner inaccessible.
            base.Dispose();

            if (this.agent != null)
            {
                log.Info("Stopping remote agent");
                agent.Stop();
                this.agent = null;
            }
        }
Example #28
0
        public void CanLaunchAndConnectToAgent()
        {
            TestAgent agent = null;

            try
            {
                agent = agency.GetAgent(AgentType.ProcessAgent, 2000);
                Assert.IsNotNull(agent);
            }
            finally
            {
                agency.ReleaseAgent(agent);
            }
        }
Example #29
0
        public async Task JsonParserError401()
        {
            var settings = CreateServiceAgentSettings();
            var serviceProvider = CreateServiceProvider(settings);
            var agent = new TestAgent(serviceProvider, Options.Create(settings));
            agent.HttpClient = CreateClient();
            var message = new HttpResponseMessage();
            message.Content = new StringContent("");
            message.StatusCode = System.Net.HttpStatusCode.Unauthorized;

            var result = await Assert.ThrowsAsync<UnauthorizedException>(async () => await agent.ParseJsonWithError(message));

            Assert.NotNull(result);
        }
Example #30
0
        public void DisposeAllDisposables()
        {
            TestDisposable disposable1 = new TestDisposable();
            TestDisposable disposable2 = new TestDisposable();

            using (TestAgent agent = new TestAgent(Substitute.For <IMessageBoard>()))
            {
                agent.MarkForDispose(disposable1);
                agent.MarkForDispose(disposable2);
            }

            disposable1.IsDisposed.Should().BeTrue("all disposables should be disposed on dispose.");
            disposable2.IsDisposed.Should().BeTrue("all disposables should be disposed on dispose.");
        }
Example #31
0
        public async Task PutWithEmptyResult()
        {
            var settings = CreateServiceAgentSettings();
            var serviceProvider = CreateServiceProvider(settings);
            var agent = new TestAgent(serviceProvider, Options.Create(settings));
            agent.HttpClient = CreateClient();

            await agent.PutWithEmptyResultAsync(new TestModel { Name = "Name3", Number = 350 });

            var sentData = await agent.GetPreviousDataAsync();
            Assert.NotNull(sentData);
            Assert.Equal("Name3", sentData.Name);
            Assert.Equal(350, sentData.Number);
        }
Example #32
0
        public override void Unload()
        {
            if (Test != null)
            {
                log.Info("Unloading " + Path.GetFileName(Test.TestName.Name));
                this.TestRunner.Unload();
                this.TestRunner = null;
            }

            if (this.agent != null)
            {
                log.Info("Stopping remote agent");
                agent.Stop();
                this.agent = null;
            }
		}
Example #33
0
 // Update is called once per frame
 void Update()
 {
     if (_newAgentsAvailable)
     {
         foreach (AgentObject agent in _agents)
         {
             TestAgent castedAgent = (TestAgent)agent;
             castedAgent.CalcualteFitness();
             castedAgent.KillAgent();
         }
     }
     else if (_startNewGen)
     {
         _startNewGen = false;
     }
 }
Example #34
0
        public void CanLaunchAndConnectToAgent()
        {
            TestAgent agent = null;

            try
            {
                agent = agency.GetAgent(10000);
                Assert.IsNotNull(agent);
            }
            finally
            {
                if (agent != null)
                {
                    agency.ReleaseAgent(agent);
                }
            }
        }
        public async Task JsonParserErrorOtherStatus()
        {
            var client          = CreateClient();
            var settings        = CreateServiceAgentSettings();
            var serviceProvider = CreateServiceProvider(settings);

            var agent = new TestAgent(client, serviceProvider, Options.Create(settings));

            var message = new HttpResponseMessage();

            message.Content    = new StringContent(@"<HTML><h1>STATUS 500</h1></HTML>");
            message.StatusCode = HttpStatusCode.InternalServerError;

            var result = await Assert.ThrowsAsync <ServiceAgentException>(async() => await agent.ParseJsonWithError(message));

            Assert.NotNull(result);
            Assert.Equal(await message.Content.ReadAsStringAsync(), result.Messages.FirstOrDefault().Value.FirstOrDefault());
            Assert.Equal(result.Code, $"Status: {HttpStatusCode.InternalServerError.ToString()}");
        }
Example #36
0
        public void AgentStartWhileStarted()
        {
            TestAgent t = new TestAgent(output);

            t.Start();
            Thread.Sleep(100);

            try
            {
                t.Start();
            }
            catch (Exception ex)
            {
                Assert.True(false,"Exception while starting agent that is already started: " + ex.ToString());
                throw;
            }

            t.Stop();
        }
        public void AgentStartWhileStarted()
        {
            TestAgent t = new TestAgent(output, this.serviceProvider);

            t.Start();
            Thread.Sleep(100);

            try
            {
                t.Start();
            }
            catch (Exception ex)
            {
                Assert.True(false, "Exception while starting agent that is already started: " + ex.ToString());
                throw;
            }

            t.Stop();
        }
Example #38
0
        public void AgentStartWhileStarted()
        {
            TestAgent t = new TestAgent(output);

            t.Start();
            Thread.Sleep(100);

            try
            {
                t.Start();
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while starting agent that is already started: " + ex.ToString());
                throw;
            }

            t.Stop();
        }
        public void AgentStopWhileStopped()
        {
            TestAgent t = new TestAgent();

            t.Start();
            Thread.Sleep(100);

            t.Stop();
            Thread.Sleep(100);

            try
            {
                t.Stop();
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while stopping agent that is already stopped: " + ex.ToString());
                throw;
            }
        }
Example #40
0
        public void Initialize(string agentName)
        {
            //find current agent in repository
            var agentRepo = _uow.Repository <TestAgent>();

            _agent = agentRepo.Query().FirstOrDefault(z => z.Name == agentName);

            Debug.WriteLine("{1} TestAgent: {0}", agentName, _agent == null ? "Create" : "Update");

            //create or update agent in repository
            if (_agent == null)
            {
                _agent = new TestAgent {
                    Name = agentName
                };
                agentRepo.Add(_agent);
            }

            _agent.Active();
            _agent.LastTalked = DateTime.Now;
            _uow.Commit();
        }
Example #41
0
        /**
         * Trigger end of loop on parent controllers up to Thread Group
         * @param sam Sampler Base sampler
         * @param threadContext
         */
        private void TriggerEndOfLoopOnParentControllers(TestAgent sam, NetMeterContext threadContext)
        {
            // Find parent controllers of current sampler
            //FindTestElementsUpToRootTraverser pathToRootTraverser=null;
            //TransactionSampler transactionSampler = null;
            //if(sam is TransactionSampler)
            //{
            //    transactionSampler = (TransactionSampler) sam;
            //    pathToRootTraverser = new FindTestElementsUpToRootTraverser((transactionSampler).getTransactionController());
            //}
            //else
            //{
            //    pathToRootTraverser = new FindTestElementsUpToRootTraverser(sam);
            //}
            //testTree.Traverse(pathToRootTraverser);
            //List<Controller> controllersToReinit = pathToRootTraverser.getControllersToRoot();

            //// Trigger end of loop condition on all parent controllers of current sampler
            //foreach (Controller cont in controllersToReinit)
            //{
            //    Controller parentController = cont;
            //    if (parentController is AbstractThreadGroup)
            //    {
            //        AbstractThreadGroup tg = (AbstractThreadGroup)parentController;
            //        tg.StartNextLoop();
            //    }
            //    else
            //    {
            //        parentController.triggerEndOfLoop();
            //    }
            //}
            //if(transactionSampler!=null)
            //{
            //    Process_sampler(transactionSampler, null, threadContext);
            //}
        }
Example #42
0
    public void TestAnswerSSH2_AGENTC_REMOVE_IDENTITY()
    {
      Agent agent = new TestAgent(allKeys);
      BlobBuilder builder = new BlobBuilder();

      /* test remove key returns success when key is removed */

      builder.AddBlob(rsaKey.GetPublicKeyBlob());
      builder.InsertHeader(Agent.Message.SSH2_AGENTC_REMOVE_IDENTITY);
      PrepareMessage(builder);
      agent.AnswerMessage(stream);
      RewindStream();
      Agent.BlobHeader header = parser.ReadHeader();
      Assert.That(header.BlobLength, Is.EqualTo(1));
      Assert.That(header.Message, Is.EqualTo(Agent.Message.SSH_AGENT_SUCCESS));
      Assert.That(agent.GetAllKeys()
        .SequenceEqual(allKeys.Where(key => key != rsaKey)));

      /* test remove key returns failure when key does not exist */

      int startCount = agent.GetAllKeys().Count();
      PrepareMessage(builder);
      agent.AnswerMessage(stream);
      RewindStream();
      header = parser.ReadHeader();
      Assert.That(header.BlobLength, Is.EqualTo(1));
      Assert.That(header.Message, Is.EqualTo(Agent.Message.SSH_AGENT_FAILURE));
      Assert.That(agent.GetAllKeys().Count(), Is.EqualTo(startCount));

      /* test returns failure when locked */

      agent.Lock(new byte[0]);
      startCount = agent.GetAllKeys().Count();
      builder.AddBlob(dsaKey.GetPublicKeyBlob());
      builder.InsertHeader(Agent.Message.SSH2_AGENTC_REMOVE_IDENTITY);
      PrepareMessage(builder);
      agent.AnswerMessage(stream);
      RewindStream();
      header = parser.ReadHeader();
      Assert.That(header.BlobLength, Is.EqualTo(1));
      Assert.That(header.Message, Is.EqualTo(Agent.Message.SSH_AGENT_FAILURE));
      Assert.That(agent.GetAllKeys().Count(), Is.EqualTo(startCount));
    }
		public override void Dispose()
		{
            // Do this first, because the next step will
            // make the downstream runner inaccessible.
            base.Dispose();

            if (this.agent != null)
            {
                log.Info("Stopping remote agent");
                try
                {
                    agent.Stop();
                }
                catch
                {
                    // Ignore any exception
                }
                finally
                {
                    this.agent = null;
                }
            }
        }
Example #44
0
        public void Run()
        {
            // threadContext is not thread-safe, so keep within thread
            NetMeterContext threadContext = NetMeterContextManager.GetContext();
            LoopIterationListener iterationListener = null;

            try
            {
                iterationListener = InitRun(threadContext);
                while (running)
                {
                    TestAgent sam = (TestAgent)controller.next();
                    while (running && sam != null)
                    {
                        ProcessTestAgent(sam, null, threadContext);
                        threadContext.CleanAfterExecute();
                        if (onErrorStartNextLoop || threadContext.restartNextLoop)
                        {
                            if (threadContext.restartNextLoop)
                            {
                                TriggerEndOfLoopOnParentControllers(sam, threadContext);
                                sam = null;
                                threadContext.GetVariables().Add(LAST_SAMPLE_OK, TRUE);
                                threadContext.restartNextLoop = false;
                            }
                            else
                            {
                                Boolean lastSampleFailed = !TRUE.Equals(threadContext.GetVariables().Get(LAST_SAMPLE_OK));
                                if(lastSampleFailed)
                                {
            //    	                		    if(log.isDebugEnabled())
            //                                    {
            //    	                    		    log.debug("StartNextLoop option is on, Last sample failed, starting next loop");
            //    	                    	    }
                                    TriggerEndOfLoopOnParentControllers(sam, threadContext);
                                    sam = null;
                                    threadContext.GetVariables().Add(LAST_SAMPLE_OK, TRUE);
                                }
                                else
                                {
                                    sam = (TestAgent)controller.next();
                                }
                            }
                        }
                        else
                        {
                            sam = (TestAgent)controller.next();
                        }
                    }
                    if (controller.isDone())
                    {
                        running = false;
                    }
                }
            }
            // Might be found by contoller.next()
            //catch (NetMeterStopTestException e)
            //{
            //    log.info("Stopping Test: " + e.toString());
            //    stopTest();
            //}
            //catch (JMeterStopTestNowException e)
            //{
            //    log.info("Stopping Test Now: " + e.toString());
            //    stopTestNow();
            //}
            //catch (JMeterStopThreadException e)
            //{
            //    log.info("Stop Thread seen: " + e.toString());
            //}
            catch (Exception ex)
            {
                log.Error("Test failed!", ex);
            }
            //catch (ThreadDeath e)
            //{
            //    throw e; // Must not ignore this one
            //}
            finally
            {
                currentSampler = null; // prevent any further interrupts
                try
                {
                    Monitor.Enter(interruptLock);  // make sure current interrupt is finished, prevent another starting yet
                    threadContext.Clear();
            //                    log.info("Thread finished: " + threadName);
                    ThreadFinished(iterationListener);
                    monitor.ThreadFinished(this); // Tell the monitor we are done
                    NetMeterContextManager.RemoveContext(); // Remove the ThreadLocal entry
                }
                finally
                {
                    Monitor.Exit(interruptLock); // Allow any pending interrupt to complete (OK because currentSampler == null)
                }
            }
        }
Example #45
0
 public void Setup()
 {
     messageBoard = Substitute.For <IMessageBoard>();
     testAgent    = new TestAgent(messageBoard);
 }
Example #46
0
    public void TestAnswerSSH2_AGENTC_SIGN_REQUEST()
    {
      const string signatureData = "this is the data that gets signed";
      byte[] signatureDataBytes = Encoding.UTF8.GetBytes(signatureData);
      BlobBuilder builder = new BlobBuilder();

      Agent agent = new TestAgent(allKeys);
      Agent.BlobHeader header;
      byte[] signatureBlob;
      BlobParser signatureParser;
      string algorithm;
      byte[] signature;
      ISigner signer;
      bool signatureOk;
      BigInteger r, s;
      DerSequence seq;

      /* test signatures */

      foreach (ISshKey key in allKeys.Where(key => key.Version == SshVersion.SSH2)) {
        builder.Clear();
        builder.AddBlob(key.GetPublicKeyBlob());
        builder.AddStringBlob(signatureData);
        builder.InsertHeader(Agent.Message.SSH2_AGENTC_SIGN_REQUEST);
        PrepareMessage(builder);
        agent.AnswerMessage(stream);
        RewindStream();

        /* check that proper response type was received */
        header = parser.ReadHeader();
        Assert.That(header.Message,
                    Is.EqualTo(Agent.Message.SSH2_AGENT_SIGN_RESPONSE));
        signatureBlob = parser.ReadBlob();
        signatureParser = new BlobParser(signatureBlob);
        algorithm = signatureParser.ReadString();
        Assert.That(algorithm, Is.EqualTo(key.Algorithm.GetIdentifierString()));
        signature = signatureParser.ReadBlob();
        if (key.Algorithm == PublicKeyAlgorithm.SSH_RSA) {
          Assert.That(signature.Length == key.Size / 8);
        } else if (key.Algorithm == PublicKeyAlgorithm.SSH_DSS) {
          Assert.That(signature.Length, Is.EqualTo(40));
          r = new BigInteger(1, signature, 0, 20);
          s = new BigInteger(1, signature, 20, 20);
          seq = new DerSequence(new DerInteger(r), new DerInteger(s));
          signature = seq.GetDerEncoded();
        } else if (key.Algorithm == PublicKeyAlgorithm.ECDSA_SHA2_NISTP256 ||
          key.Algorithm == PublicKeyAlgorithm.ECDSA_SHA2_NISTP384 ||
          key.Algorithm == PublicKeyAlgorithm.ECDSA_SHA2_NISTP521) {
          Assert.That(signature.Length, Is.AtLeast(key.Size / 4 + 8));
          Assert.That(signature.Length, Is.AtMost(key.Size / 4 + 10));
          BlobParser sigParser = new BlobParser(signature);
          r = new BigInteger(sigParser.ReadBlob());
          s = new BigInteger(sigParser.ReadBlob());
          seq = new DerSequence(new DerInteger(r), new DerInteger(s));
          signature = seq.GetDerEncoded();
        } else if (key.Algorithm == PublicKeyAlgorithm.ED25519) {
            Assert.That(signature.Length, Is.EqualTo(64));
        }
        signer = key.GetSigner();
        signer.Init(false, key.GetPublicKeyParameters());
        signer.BlockUpdate(signatureDataBytes, 0, signatureDataBytes.Length);
        signatureOk = signer.VerifySignature(signature);
        Assert.That(signatureOk, Is.True, "invalid signature");
        Assert.That(header.BlobLength, Is.EqualTo(stream.Position - 4));
      }

      /* test DSA key old signature format */

      builder.Clear();
      builder.AddBlob(dsaKey.GetPublicKeyBlob());
      builder.AddStringBlob(signatureData);
      builder.AddInt((uint)Agent.SignRequestFlags.SSH_AGENT_OLD_SIGNATURE);
      builder.InsertHeader(Agent.Message.SSH2_AGENTC_SIGN_REQUEST);
      PrepareMessage(builder);
      agent.AnswerMessage(stream);
      RewindStream();
      header = parser.ReadHeader();
      Assert.That(header.Message,
                  Is.EqualTo(Agent.Message.SSH2_AGENT_SIGN_RESPONSE));
      signatureBlob = parser.ReadBlob();
      signatureParser = new BlobParser(signatureBlob);
      signature = signatureParser.ReadBlob();
      Assert.That(signature.Length == 40);
      r = new BigInteger(1, signature, 0, 20);
      s = new BigInteger(1, signature, 20, 20);
      seq = new DerSequence(new DerInteger(r), new DerInteger(s));
      signature = seq.GetDerEncoded();
      signer = dsaKey.GetSigner();
      signer.Init(false, dsaKey.GetPublicKeyParameters());
      signer.BlockUpdate(signatureDataBytes, 0, signatureDataBytes.Length);
      signatureOk = signer.VerifySignature(signature);
      Assert.That(signatureOk, Is.True, "invalid signature");
      Assert.That(header.BlobLength, Is.EqualTo(stream.Position - 4));

      /* test key not found */

      agent = new TestAgent();
      builder.Clear();
      builder.AddBlob(dsaKey.GetPublicKeyBlob());
      builder.AddStringBlob(signatureData);
      builder.InsertHeader(Agent.Message.SSH2_AGENTC_SIGN_REQUEST);
      PrepareMessage(builder);
      agent.AnswerMessage(stream);
      RewindStream();
      Agent.BlobHeader header2 = parser.ReadHeader();
      Assert.That(header2.BlobLength, Is.EqualTo(1));
      Assert.That(header2.Message, Is.EqualTo(Agent.Message.SSH_AGENT_FAILURE));

      /* test confirm constraint */

      agent = new TestAgent();
      Agent.KeyConstraint testConstraint = new Agent.KeyConstraint();
      testConstraint.Type = Agent.KeyConstraintType.SSH_AGENT_CONSTRAIN_CONFIRM;
      SshKey testKey = dsaKey.Clone();
      bool confirmCallbackReturnValue = false;
      agent.ConfirmUserPermissionCallback = delegate(ISshKey k, Process p)
      {
        return confirmCallbackReturnValue;
      };
      testKey.AddConstraint(testConstraint);
      agent.AddKey(testKey);
      builder.Clear();
      builder.AddBlob(dsaKey.GetPublicKeyBlob());
      builder.AddStringBlob(signatureData);
      builder.InsertHeader(Agent.Message.SSH2_AGENTC_SIGN_REQUEST);
      PrepareMessage(builder);
      agent.AnswerMessage(stream);
      RewindStream();
      header2 = parser.ReadHeader();
      Assert.That(header2.BlobLength, Is.EqualTo(1));
      Assert.That(header2.Message, Is.EqualTo(Agent.Message.SSH_AGENT_FAILURE));
      confirmCallbackReturnValue = true;
      PrepareMessage(builder);
      agent.AnswerMessage(stream);
      RewindStream();
      header2 = parser.ReadHeader();
      Assert.That(header2.BlobLength, Is.Not.EqualTo(1));
      Assert.That(header2.Message, Is.EqualTo(Agent.Message.SSH2_AGENT_SIGN_RESPONSE));
    }
    //Update the genetic algorithm.
    public void update(TestAgent agent)
    {
        //End of current target test.
        if (++tick == TICKS_PER_GENOME) {

            //Move to next target.
            currTarget = (currTarget+1) % agent.totalTargets();

            //Notify agent of end of target test
            agent.endOfTarget(currTarget);

            //calculate fitness and add to genomes current total.
            population[populationIndex].totalFitness += agent.calculateFitness();

            //Reset the agent back to starting values.
            agent.reset();

            //Finished testing current genome
            if(!agent.targetsEnabled || currTarget == 0) {

                //Notify agent
                agent.endOfTests();

                //Calculate fitness for current genome
                population[populationIndex].fitness = population[populationIndex].totalFitness/(agent.targetsEnabled?agent.totalTargets():1);

                //Add fitness to total.
                totalFitness += population[populationIndex].fitness;

                Debug.Log("Population["+populationIndex+"] " +population[populationIndex].fitness);

                //Save the best fitness for the generation.
                bestFitness = Math.Max(bestFitness, population[populationIndex].fitness);

                //Move to next genome
                ++populationIndex;

                //Replace weights in agent with new genome's weights.
                agent.replaceBrain(population[populationIndex%populationSize].weights);

                //End of one generation
                if(populationIndex == populationSize) {
                    Debug.Log("Generation "+generation +" completed");

                    createNewPopulation();

                    populationIndex = 0;
                    totalFitness = 0;
                    bestFitness = 0;
                    ++generation;
                }
            }

            tick = 0;
        }
    }
Example #48
0
            public AgentRecord this[TestAgent agent]
            {
                get
                {
                    foreach( System.Collections.DictionaryEntry entry in agentData )
                    {
                        AgentRecord r = (AgentRecord)entry.Value;
                        if ( r.Agent == agent )
                            return r;
                    }

                    return null;
                }
            }
Example #49
0
    public void TestAnswerSSH2_AGENTC_REMOVE_ALL_IDENTITIES()
    {
      Agent agent = new TestAgent(allKeys);

      /* test that remove all keys removes keys */

      PrepareSimpleMessage(Agent.Message.SSH2_AGENTC_REMOVE_ALL_IDENTITIES);
      agent.AnswerMessage(stream);
      RewindStream();
      Agent.BlobHeader header = parser.ReadHeader();
      Assert.That(header.BlobLength, Is.EqualTo(1));
      Assert.That(header.Message, Is.EqualTo(Agent.Message.SSH_AGENT_SUCCESS));
      int actualKeyCount = agent.GetAllKeys()
        .Count(key => key.Version != SshVersion.SSH2);
      int expectedKeyCount = allKeys.Count(key => key.Version != SshVersion.SSH2);
      Assert.That(actualKeyCount, Is.EqualTo(expectedKeyCount));

      /* test that remove all keys returns success even when there are no keys */
      agent = new TestAgent();
      PrepareSimpleMessage(Agent.Message.SSH2_AGENTC_REMOVE_ALL_IDENTITIES);
      agent.AnswerMessage(stream);
      RewindStream();
      header = parser.ReadHeader();
      Assert.That(header.BlobLength, Is.EqualTo(1));
      Assert.That(header.Message, Is.EqualTo(Agent.Message.SSH_AGENT_SUCCESS));

      /* test that returns failure when locked */
      agent.Lock(new byte[0]);
      PrepareSimpleMessage(Agent.Message.SSH2_AGENTC_REMOVE_ALL_IDENTITIES);
      agent.AnswerMessage(stream);
      RewindStream();
      header = parser.ReadHeader();
      Assert.That(header.BlobLength, Is.EqualTo(1));
      Assert.That(header.Message, Is.EqualTo(Agent.Message.SSH_AGENT_FAILURE));
    }
Example #50
0
 protected void setSubSampler(TestAgent subSampler)
 {
     this.subSampler = subSampler;
 }
Example #51
0
 private void Init()
 {
     variables = null;
     previousResult = null;
     currentSampler = null;
     previousSampler = null;
     samplingStarted = false;
     threadNum = 0;
     nThread = null;
     isReinitSubControllers = false;
     samplerContext.Clear();
     restartNextLoop = false;
 }
Example #52
0
    public void Loop()
    {
        if (!enabled || !gameObject.activeSelf)
        {
            return;
        }
        if (!unit.enabled)
        {
            unit.OnEnable();
            unit.ChangeAgentType(unit._baseData.eAgentType == EAgentType.ingoreObstacle? EAgentType.ingoreObstacle : EAgentType.astar);
            unit.agent.TargetPos = unit._defaultTargetPos;
        }
        CalculateEnemies();
        TestAgent agent       = null;
        FP        tagetDstSqr = FP.MaxValue;

        if (_targetId >= 0)
        {
            agent = _testPathFinding.GetAgent(_targetId);
            if (agent != null)
            {
                tagetDstSqr = (agent.unit.position - unit.position).sqrMagnitude;
            }
        }

        for (int i = 0; i < _listEnemyAgents.Count; i++)
        {
            FP trueRange = attackRange + _listEnemyAgents[i].colliderRadius;
            FP dstSqr    = (_listEnemyAgents[i].position - unit.position).sqrMagnitude;

            if (dstSqr < trueRange * trueRange) //in attackage range
            {
                if (unit.AgentType != EAgentType.none)
                {
                    unit.SetNewTargetPos(_listEnemyAgents[i].position);//////////////////////////
                    unit.stopMoving           = true;
                    unit._nextCheckActionTime = 0;
                    unit._frameOffset         = 20;
                    _targetId = _listEnemyAgents[i].baseData.id;
                }
                break;
            }
            if (_targetId >= 0 && dstSqr >= tagetDstSqr - GridMap.GetNodeSize() * GridMap.GetNodeSize() &&
                _targetId != unit.Id)
            {
                if (agent != null && unit.CanSetTargetPos(agent.unit.position))
                {
                    break;
                }
            }
            if (unit.SetNewTargetPos(_listEnemyAgents[i].position))
            {
                int idx1 = unit.map.GetGridNodeId(unit.NewTargetPos);
                int idx2 = unit.map.GetGridNodeId(unit.targetPos);
                if (idx1 != idx2)
                {
                    unit.stopMoving = false;
                }
                _targetId = _listEnemyAgents[i].baseData.id;
                break;
            }
        }
        if (_listEnemyAgents.Count == 0 || _targetId == 0)
        {
            TSVector targetPos = CustomMath.Vector3ToTsvec(_testPathFinding.destObj[unit.playerId].transform.position);
            // unit.ChangeAgentType(EAgentType.flowFiled);
            if ((targetPos - unit.position).sqrMagnitude > GridMap._checkDeltaDstSqr)
            {
                unit.stopMoving = false;
            }
            if (unit.NewTargetPos == TSVector.MinValue || unit.NewTargetPos == TSVector.MaxValue || _targetId == 0)
            // || (unit.NewTargetPos - unit.position).sqrMagnitude<unit.neighbourRadius*unit.neighbourRadius*225/100)
            {
                unit.SetNewTargetPos(targetPos);
            }

            //unit.agent.TargetPos = unit._defaultTargetPos;
        }
        if (unit.AgentType == EAgentType.astar && unit.agent != null)
        {
            AStarAgent ag = unit.agent as AStarAgent;
            if (debugDrawPath)
            {
                for (int i = 1; i < ag._vecRunningPath.Count; i++)
                {
                    UnityEngine.Debug.DrawLine(CustomMath.TsVecToVector3(ag._vecRunningPath[i - 1]), CustomMath.TsVecToVector3(ag._vecRunningPath[i]), UnityEngine.Color.green, 1);
                }
            }
#if UNITY_EDITOR
            ag._showDebug = debugDrawPath;
#endif
            _pathNodeIdx        = ag.TowardPathIdx;
            _totalPathNodeCount = ag._vecRunningPath.Count;
        }
    }
Example #53
0
    public void TestAnswerSSH_AGENTC_LOCKandSSH_AGENTC_UNLOCK()
    {
      const string password = "******";

      Agent agent = new TestAgent();
      Assert.That(agent.IsLocked, Is.False, "Agent initial state was locked!");

      bool agentLockedCalled = false;
      Agent.BlobHeader replyHeader;

      Agent.LockEventHandler agentLocked =
        delegate(object aSender, Agent.LockEventArgs aEventArgs)
        {
          Assert.That(agentLockedCalled, Is.False,
            "LockEvent fired without resetting agentLockedCalled");
          agentLockedCalled = true;
        };

      agent.Locked += new Agent.LockEventHandler(agentLocked);


      /* test that unlock does nothing when already unlocked */

      PrepareLockMessage(false, password);
      agentLockedCalled = false;
      agent.AnswerMessage(stream);
      RewindStream();
      replyHeader = parser.ReadHeader();
      Assert.That(replyHeader.Message,
        Is.EqualTo(Agent.Message.SSH_AGENT_FAILURE),
        "Unlock should have failed because agent was already unlocked");
      Assert.That(agent.IsLocked, Is.False, "Agent should still be unlocked");
      Assert.That(agentLockedCalled, Is.False,
        "agentLocked should not have been called because state did not change.");

      /* test that locking works */

      PrepareLockMessage(true, password);
      agentLockedCalled = false;
      agent.AnswerMessage(stream);
      RewindStream();
      replyHeader = parser.ReadHeader();
      Assert.That(replyHeader.Message,
        Is.EqualTo(Agent.Message.SSH_AGENT_SUCCESS),
        "Locking should have succeeded");
      Assert.That(agent.IsLocked, Is.True, "Agent should be locked");
      Assert.That(agentLockedCalled, Is.True,
        "agentLocked should have been called");


      /* test that trying to lock when already locked fails */

      PrepareLockMessage(true, password);
      agentLockedCalled = false;
      agent.AnswerMessage(stream);
      RewindStream();
      replyHeader = parser.ReadHeader();
      Assert.That(replyHeader.Message,
        Is.EqualTo(Agent.Message.SSH_AGENT_FAILURE),
        "Unlock should have failed because agent was already unlocked");
      Assert.That(agent.IsLocked, Is.True, "Agent should still be locked");
      Assert.That(agentLockedCalled, Is.False,
        "agentLocked should not have been called because state did not change.");

      /* test that unlocking with wrong password fails */

      PrepareLockMessage(false, password + "x");
      agentLockedCalled = false;
      agent.AnswerMessage(stream);
      RewindStream();
      replyHeader = parser.ReadHeader();
      Assert.That(replyHeader.Message,
        Is.EqualTo(Agent.Message.SSH_AGENT_FAILURE),
        "Unlock should have failed because password was incorrect");
      Assert.That(agent.IsLocked, Is.True, "Agent should still be locked");
      Assert.That(agentLockedCalled, Is.False,
        "agentLocked should not have been called because state did not change.");

      /* test that unlocking works */

      PrepareLockMessage(false, password);
      agentLockedCalled = false;
      agent.AnswerMessage(stream);
      RewindStream();
      replyHeader = parser.ReadHeader();
      Assert.That(replyHeader.Message,
        Is.EqualTo(Agent.Message.SSH_AGENT_SUCCESS),
        "Unlock should have succeeded");
      Assert.That(agent.IsLocked, Is.False, "Agent should be unlocked");
      Assert.That(agentLockedCalled, Is.True,
        "agentLocked should have been called");

      agent.Locked -= new Agent.LockEventHandler(agentLocked);
    }
Example #54
0
 public void SetCurrentSampler(TestAgent sampler)
 {
     this.previousSampler = currentSampler;
     this.currentSampler = sampler;
 }
Example #55
0
		public void ReleaseAgent( TestAgent agent )
		{
			AgentRecord r = agentData[agent.Id];
			if ( r == null )
				NTrace.Error( string.Format( "Unable to release agent {0} - not in database", agent.Id ) );
			else
			{
				r.Status = AgentStatus.Ready;
				NTrace.Debug( "Releasing agent " + agent.Id.ToString() );
			}
		}
Example #56
0
 public AgentRecord( Guid id, Process p, TestAgent a, AgentStatus s )
 {
     this.Id = id;
     this.Process = p;
     this.Agent = a;
     this.Status = s;
 }
Example #57
0
		public void DestroyAgent( TestAgent agent )
		{
			AgentRecord r = agentData[agent.Id];
			if ( r != null )
			{
				if( !r.Process.HasExited )
					r.Agent.Stop();
				agentData[r.Process.Id] = null;
			}
		}
Example #58
0
        /**
         * Process the current sampler, handling transaction samplers.
         *
         * @param current sampler
         * @param parent sampler
         * @param threadContext
         * @return SampleResult if a transaction was processed
         */
        private ExecuteResult ProcessTestAgent(TestAgent current, TestAgent parent, NetMeterContext threadContext)
        {
            ExecuteResult transactionResult = null;
            try
            {
                // Check if we have a sampler to sample
                if(current != null)
                {
                    threadContext.SetCurrentSampler(current);
                    // Get the sampler ready to sample
                    ExecutionPackage pack = compiler.ConfigureSampler(current);
                    // runPreProcessors(pack.getPreProcessors());

                    // Hack: save the package for any transaction controllers
                    threadVars.PutObject(PACKAGE_OBJECT, pack);

                    //delay(pack.getTimers());
                    TestAgent sampler = pack.GetSampler();
                    sampler.SetThreadContext(threadContext);
                    // TODO should this set the thread names for all the subsamples?
                    // might be more efficient than fetching the name elsewehere
                    sampler.SetThreadName(threadName);
                    // TestBeanHelper.prepare(sampler);

                    // Perform the actual sample
                    currentSampler = sampler;
                    ExecuteResult result = sampler.Execute(null);
                    currentSampler = null;
                    // TODO: remove this useless Entry parameter

                    // If we got any results, then perform processing on the result
                    if (result != null)
                    {
                        result.SetGroupThreads(threadGroup.GetNumberOfThreads());
                        result.SetAllThreads(NetMeterContextManager.GetNumberOfThreads());
                        result.SetThreadName(threadName);
                        threadContext.SetPreviousResult(result);
                        RunPostProcessors(pack.GetPostProcessors());
                        CheckTestAssertions(pack.GetAssertions(), result, threadContext);
                        // Do not send subsamples to listeners which receive the transaction sample
                        List<ExecutionListener> sampleListeners = GetSampleListeners(pack);
                        NotifyListeners(sampleListeners, result);
                        compiler.Done(pack);

                        // Check if thread or test should be stopped
                        if (result.isStopThread() || (!result.Success && onErrorStopThread))
                        {
                            StopThread();
                        }
                        if (result.isStopTest() || (!result.Success && onErrorStopTest))
                        {
                            StopTest();
                        }
                        if (result.isStopTestNow() || (!result.Success && onErrorStopTestNow))
                        {
                            StopTestNow();
                        }
                        if(result.isStartNextThreadLoop())
                        {
                            threadContext.restartNextLoop = true;
                        }
                    }
                    else
                    {
                        compiler.Done(pack); // Finish up
                    }
                }
                if (scheduler)
                {
                    // checks the scheduler to stop the iteration
                    StopScheduler();
                }
            }
            catch (Exception e)
            {
                if (current != null)
                {
                     log.Error("Error while processing sampler '"+current.GetName()+"' :", e);
                }
                else
                {
                     log.Error("", e);
                }
                StopThread();
            }
            return transactionResult;
        }
Example #59
0
 public TestAgentClient()
 {
     Agent = new TestAgent();
 }
Example #60
0
        /**
         * Trigger end of loop on parent controllers up to Thread Group
         * @param sam Sampler Base sampler
         * @param threadContext
         */
        private void TriggerEndOfLoopOnParentControllers(TestAgent sam, NetMeterContext threadContext)
        {
            // Find parent controllers of current sampler
            //FindTestElementsUpToRootTraverser pathToRootTraverser=null;
            //TransactionSampler transactionSampler = null;
            //if(sam is TransactionSampler)
            //{
            //    transactionSampler = (TransactionSampler) sam;
            //    pathToRootTraverser = new FindTestElementsUpToRootTraverser((transactionSampler).getTransactionController());
            //}
            //else
            //{
            //    pathToRootTraverser = new FindTestElementsUpToRootTraverser(sam);
            //}
            //testTree.Traverse(pathToRootTraverser);
            //List<Controller> controllersToReinit = pathToRootTraverser.getControllersToRoot();

            //// Trigger end of loop condition on all parent controllers of current sampler
            //foreach (Controller cont in controllersToReinit)
            //{
            //    Controller parentController = cont;
            //    if (parentController is AbstractThreadGroup)
            //    {
            //        AbstractThreadGroup tg = (AbstractThreadGroup)parentController;
            //        tg.StartNextLoop();
            //    }
            //    else
            //    {
            //        parentController.triggerEndOfLoop();
            //    }
            //}
            //if(transactionSampler!=null)
            //{
            //    Process_sampler(transactionSampler, null, threadContext);
            //}
        }