Esempio n. 1
0
        public static void ConcurrentOperationsDoNotCorruptState()
        {
            var database = new AgentStore();

            RunActionConcurrently(() =>
            {
                for (var i = 0; i < 1000; i++)
                {
                    var id = Guid.NewGuid();

                    Assert.That(database.IsAgentProcessActive(id, out _), Is.False);
                    Assert.That(database.IsReady(id, out _), Is.False);

                    database.AddAgent(id, DummyProcess);
                    Assert.That(database.IsAgentProcessActive(id, out _), Is.True);
                    Assert.That(database.IsReady(id, out _), Is.False);

                    database.Register(new DummyTestAgent(id));
                    Assert.That(database.IsAgentProcessActive(id, out _), Is.True);
                    Assert.That(database.IsReady(id, out _), Is.True);

                    database.MarkTerminated(id);
                    Assert.That(database.IsAgentProcessActive(id, out _), Is.False);
                    Assert.That(database.IsReady(id, out _), Is.False);
                }
            }, threadCount: Environment.ProcessorCount);
        }
Esempio n. 2
0
        public static void AgentMustNotRegisterAfterTerminating()
        {
            var database = new AgentStore();

            database.AddAgent(DummyAgent.Id, DummyProcess);
            database.MarkTerminated(DummyAgent.Id);
            Assert.That(() => database.Register(DummyAgent), Throws.ArgumentException.With.Property("ParamName").EqualTo("agent"));
        }
Esempio n. 3
0
        public static void AgentIsNotReadyWhenTerminated()
        {
            var database = new AgentStore();

            database.AddAgent(DummyAgent.Id, DummyProcess);
            database.Register(DummyAgent);
            database.MarkTerminated(DummyAgent.Id);
            Assert.That(database.IsReady(DummyAgent.Id, out _), Is.False);
        }
        public static void AgentIsNotRunningWhenTerminated()
        {
            var database = new AgentStore();

            database.Start(DummyAgent.Id, DummyProcess);
            database.Register(DummyAgent);
            database.MarkTerminated(DummyAgent.Id);
            Assert.That(database.IsAgentProcessActive(DummyAgent.Id, out _), Is.False);
        }
        public static void IdCannotBeReused()
        {
            var database = new AgentStore();

            database.Start(DummyAgent.Id, DummyProcess);
            Assert.That(() => database.Start(DummyAgent.Id, DummyProcess), Throws.ArgumentException.With.Property("ParamName").EqualTo("agentId"));

            database.Register(DummyAgent);
            Assert.That(() => database.Start(DummyAgent.Id, DummyProcess), Throws.ArgumentException.With.Property("ParamName").EqualTo("agentId"));

            database.MarkTerminated(DummyAgent.Id);
            Assert.That(() => database.Start(DummyAgent.Id, DummyProcess), Throws.ArgumentException.With.Property("ParamName").EqualTo("agentId"));
        }
Esempio n. 6
0
        private void OnAgentExit(Process process, Guid agentId)
        {
            _agents.MarkTerminated(agentId);

            string errorMsg;

            switch (process.ExitCode)
            {
            case AgentExitCodes.OK:
                return;

            case AgentExitCodes.PARENT_PROCESS_TERMINATED:
                errorMsg = "Remote test agent believes agency process has exited.";
                break;

            case AgentExitCodes.UNEXPECTED_EXCEPTION:
                errorMsg = "Unhandled exception on remote test agent. " +
                           "To debug, try running with the --inprocess flag, or using --trace=debug to output logs.";
                break;

            case AgentExitCodes.FAILED_TO_START_REMOTE_AGENT:
                errorMsg = "Failed to start remote test agent.";
                break;

            case AgentExitCodes.DEBUGGER_SECURITY_VIOLATION:
                errorMsg = "Debugger could not be started on remote agent due to System.Security.Permissions.UIPermission not being set.";
                break;

            case AgentExitCodes.DEBUGGER_NOT_IMPLEMENTED:
                errorMsg = "Debugger could not be started on remote agent as not available on platform.";
                break;

            case AgentExitCodes.UNABLE_TO_LOCATE_AGENCY:
                errorMsg = "Remote test agent unable to locate agency process.";
                break;

            default:
                errorMsg = $"Remote test agent exited with non-zero exit code {process.ExitCode}";
                break;
            }

            throw new NUnitEngineException(errorMsg);
        }
Esempio n. 7
0
        public static void AgentMustBeStartedBeforeTerminating()
        {
            var database = new AgentStore();

            Assert.That(() => database.MarkTerminated(DummyAgent.Id), Throws.ArgumentException.With.Property("ParamName").EqualTo("agentId"));
        }