Example #1
0
 public Instance(DurationFlowNode _parent, ExecutionMetadata _metadata, int _goal, Action <Instance> _onCompletion)
 {
     Parent       = _parent;
     Metadata     = _metadata;
     Goal         = _goal;
     OnCompletion = _onCompletion;
 }
Example #2
0
        public void Run(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

            Logger.Info($"ForkedRuntime started at {DateTime.UtcNow} (UTC) with cmd-arguments {string.Join(" ", args)}");

            var cmdlineOptions = ParseArguments(args);

            Logger.Info($"JobRunId:  {cmdlineOptions.JobRunId}");
            Logger.Info($"JobServer: {cmdlineOptions.JobServer}");
            Logger.Info($"IsDebug:   {cmdlineOptions.IsDebug}");

            WaitForDebugger(cmdlineOptions.IsDebug);

            // Create client
            var jobbrRuntimeClient = new ForkedExecutionRestClient(cmdlineOptions.JobServer, cmdlineOptions.JobRunId);

            this.forkedExecutionRestClient = jobbrRuntimeClient;

            jobbrRuntimeClient.PublishState(JobRunState.Connected);

            var jobRunInfoDto = this.forkedExecutionRestClient.GetJobRunInfo();

            var jobRunInfo = new ExecutionMetadata
            {
                JobType           = jobRunInfoDto.JobType,
                JobParameter      = jobRunInfoDto.JobParameter,
                InstanceParameter = jobRunInfoDto.InstanceParameter,
                UserId            = jobRunInfoDto.UserId,
                UserDisplayName   = jobRunInfoDto.UserDisplayName
            };

            this.coreRuntime.Execute(jobRunInfo);
        }
Example #3
0
        public override void Execute(ExecutionMetadata metadata)
        {
            Instance newInstance = new Instance(this, metadata, this.Get <int> ("Duration"), (instance) => OnInstanceComplete(instance));

            Instances.Add(newInstance);

            Executor.CurrentExecutor.OnTick += newInstance.Incriment;

            base.Execute(metadata);
        }
Example #4
0
        public override void Execute(ExecutionMetadata metadata)
        {
            if (this.Get <bool> ("Condition"))
            {
                this.GetHook("True").EnqueueAndExecuteNextNextNodes();
            }
            else
            {
                this.GetHook("False").EnqueueAndExecuteNextNextNodes();
            }

            base.Execute(metadata);
        }
Example #5
0
        // TODO: Execution logic could use a major refacoring, as it has been quite spaghettified at the moment.
        public void ExecuteAll(ExecutionMetadata metadata = null)
        {
            if (metadata == null) // If null, then create a fresh one.
            {
                metadata = new ExecutionMetadata();
            }

            if (IsExecuting)
            {
                return;
            }

            IsExecuting = true;

            while (ExecutionQueue.Count != 0)
            {
                IExecutable executable = ExecutionQueue.Dequeue();
                executable.Execute(metadata);
            }

            IsExecuting = false;
        }
Example #6
0
 public void Execute(ExecutionMetadata metadata)
 {
     NextHook.EnqueueAndExecuteNextNextNodes();
 }
Example #7
0
 public void Execute(ExecutionMetadata metadata)
 {
     Action.Execute(this, this);
     NextHook.EnqueueAndExecuteNextNextNodes();
 }
Example #8
0
        void describe_()
        {
            ExecutionMetadata obj       = null;
            List <string>     files     = null;
            Exception         exception = null;
            StringWriter      stderr    = null;

            act = () =>
            {
                exception = null;
                try
                {
                    stderr = new StringWriter();
                    Console.SetError(stderr);
                    obj = Program.GenerateExecutionMetadata(files);
                }
                catch (Exception e)
                {
                    exception = e;
                }
            };

            context["a web.config file exists"] = () =>
            {
                before = () => files = new List <string> {
                    @"app\foo", @"app\bar", @"app\Web.Config"
                };

                it["sets WebAppServer as the start command (Diego)"] = () =>
                {
                    obj.StartCommand.should_be(@"..\tmp\lifecycle\WebAppServer.exe");
                    obj.StartCommandArgs.should_be(new string[] { });
                };
            };

            context["an exe file exists"] = () =>
            {
                before = () => files = new List <string> {
                    @"app\foo", @"app\bar", @"app\jane.exe"
                };

                it["sets the exe as the start command (Diego)"] = () =>
                {
                    obj.StartCommand.should_be(@"jane.exe");
                    obj.StartCommandArgs.should_be_empty();
                };
            };

            context["an Procfile exists"] = () =>
            {
                string filename = null;
                before = () =>
                {
                    filename = Path.Combine(Path.GetTempPath(), "Procfile");
                    files    = new List <string> {
                        filename
                    };
                };
                after = () => File.Delete(filename);

                context["with a `web` line"] = () =>
                {
                    before = () => File.WriteAllLines(filename,
                                                      new string[] { "worker2: issfdsi.exe", "web: billybob.exe fred jane jim", "worker1: isudf.exe" });

                    it["sets the Procfile as the start command (Diego)"] = () =>
                    {
                        obj.StartCommand.should_be(@"billybob.exe");
                        obj.StartCommandArgs.should_be(new string[] { "fred", "jane", "jim" });
                    };

                    context["and a web.config also exist"] = () =>
                    {
                        before = () => files = new List <string> {
                            "Web.config", filename
                        };

                        it["goes with the Procfile"] = () =>
                        {
                            obj.StartCommand.should_be(@"billybob.exe");
                            obj.StartCommandArgs.should_be(new string[] { "fred", "jane", "jim" });
                        };
                    };
                };

                context["without a 'web' line"] = () =>
                {
                    before = () => File.WriteAllLines(filename,
                                                      new string[] { "worker2: issfdsi.exe", "worker1: isudf.exe" });

                    it["throws an exception"] = () =>
                    {
                        exception.should_not_be_null();
                        exception.Message.should_be("Procfile didn't contain a web line");
                    };
                };

                context["Procfile has letters before procfile"] = () =>
                {
                    before = () =>
                    {
                        filename = Path.Combine(Path.GetTempPath(), "iausgdProcfile");
                        File.WriteAllLines(filename, new string[] { "worker2: issfdsi.exe", "web: stuff more stuff", "worker1: isudf.exe" });
                        files = new List <string> {
                            filename
                        };
                    };

                    it["prints a message on stdout"] = () =>
                    {
                        stderr.ToString().should_contain("No start command detected");
                    };
                };
            };

            context["two exe files exist"] = () =>
            {
                before = () => files = new List <string> {
                    @"app\foo", @"app\jill.exe", @"app\bar", @"app\jane.exe"
                };

                it["throws an exception"] = () =>
                {
                    exception.should_not_be_null();
                    exception.Message.should_be("Directory contained more than 1 executable file.");
                };
            };

            context["neither web.config nor exe file exist"] = () =>
            {
                before = () => files = new List <string> {
                    "foo"
                };

                it["prints a message on stdout"] = () =>
                {
                    stderr.ToString().should_contain("No start command detected");
                };
            };

            context["both web.config and an exe file exist"] = () =>
            {
                before = () => files = new List <string> {
                    "foo.exe", "Web.config"
                };

                it["goes with the Web.config"] = () =>
                {
                    obj.StartCommand.should_be(@"..\tmp\lifecycle\WebAppServer.exe");
                    obj.StartCommandArgs.should_be(new string[] { });
                };
            };
        }
Example #9
0
 public void Execute(ExecutionMetadata metadata)
 {
 }