private (IIpcMoniker ipcMoniker, PipId servicePipId) CreateService(TestPipGraphFragment fragment)
        {
            var ipcMoniker       = fragment.GetIpcMoniker();
            var apiServerMoniker = fragment.GetApiServerMoniker();

            var shutdownBuilder = fragment.GetProcessBuilder();

            new ArgumentsBuilder(shutdownBuilder)
            .AddIpcMonikerOption("--ipcMoniker", ipcMoniker)
            .AddIpcMonikerOption("--serverMoniker", apiServerMoniker)
            .AddOutputOption("--output", fragment.CreateOutputFile("shutdown.txt"));
            shutdownBuilder.ServiceKind = global::BuildXL.Pips.Operations.ServicePipKind.ServiceShutdown;
            (Process shutdownProcess, ProcessOutputs _) = fragment.ScheduleProcessBuilder(shutdownBuilder);

            var finalProcessBuilder = fragment.GetIpcProcessBuilder();

            new ArgumentsBuilder(finalProcessBuilder)
            .AddOption("--command", "final")
            .AddIpcMonikerOption("--ipcMoniker", ipcMoniker);
            var finalOutputFile = fragment.CreateOutputFile("final.txt");
            var finalizationPip = fragment.ScheduleIpcPip(
                ipcMoniker,
                null,
                finalProcessBuilder,
                finalOutputFile,
                true);

            XAssert.IsTrue(finalizationPip.IsValid);

            var serviceProcessBuilder = fragment.GetProcessBuilder();

            new ArgumentsBuilder(serviceProcessBuilder)
            .AddIpcMonikerOption("--ipcMoniker", ipcMoniker)
            .AddIpcMonikerOption("--serverMoniker", apiServerMoniker)
            .AddOutputOption("--output", fragment.CreateOutputFile("service.txt"));
            serviceProcessBuilder.ServiceKind          = global::BuildXL.Pips.Operations.ServicePipKind.Service;
            serviceProcessBuilder.ShutDownProcessPipId = shutdownProcess.PipId;
            serviceProcessBuilder.FinalizationPipIds   = ReadOnlyArray <PipId> .FromWithoutCopy(new[] { finalizationPip });

            (Process serviceProcess, ProcessOutputs _) = fragment.ScheduleProcessBuilder(serviceProcessBuilder);

            var createProcessBuilder = fragment.GetIpcProcessBuilder();

            new ArgumentsBuilder(createProcessBuilder)
            .AddOption("--command", "create")
            .AddIpcMonikerOption("--ipcMoniker", ipcMoniker);
            var createOutputFile = fragment.CreateOutputFile("create.txt");
            var createPip        = fragment.ScheduleIpcPip(
                ipcMoniker,
                serviceProcess.PipId,
                createProcessBuilder,
                createOutputFile,
                false);

            XAssert.IsTrue(createPip.IsValid);

            return(ipcMoniker, serviceProcess.PipId);
        }
Пример #2
0
        public static (IIpcMoniker ipcMoniker, PipId servicePipId) CreateService(TestPipGraphFragment fragment, ServiceRelatedPips pips = null)
        {
            var ipcMoniker       = fragment.GetIpcMoniker();
            var apiServerMoniker = fragment.GetApiServerMoniker();

            var shutdownBuilder = fragment.GetProcessBuilder();

            new ArgumentsBuilder(shutdownBuilder)
            .AddIpcMonikerOption("--ipcMoniker ", ipcMoniker)
            .AddIpcMonikerOption("--serverMoniker ", apiServerMoniker)
            .AddOutputFileOption("--output ", fragment.CreateOutputFile("shutdown.txt"))
            .Finish();
            shutdownBuilder.ServiceKind = ServicePipKind.ServiceShutdown;
            (Process shutdownProcess, ProcessOutputs _) = fragment.ScheduleProcessBuilder(shutdownBuilder);

            var finalProcessBuilder = fragment.GetIpcProcessBuilder();

            new ArgumentsBuilder(finalProcessBuilder)
            .AddStringOption("--command ", "final")
            .AddIpcMonikerOption("--ipcMoniker ", ipcMoniker)
            .Finish();
            var finalOutputFile = fragment.CreateOutputFile("final.txt");
            var finalizationPip = fragment.ScheduleIpcPip(
                ipcMoniker,
                null,
                finalProcessBuilder,
                finalOutputFile,
                true);

            XAssert.IsTrue(finalizationPip.PipId.IsValid);

            var serviceProcessBuilder = fragment.GetProcessBuilder();

            new ArgumentsBuilder(serviceProcessBuilder)
            .AddIpcMonikerOption("--ipcMoniker ", ipcMoniker)
            .AddIpcMonikerOption("--serverMoniker ", apiServerMoniker)
            .AddOutputFileOption("--output ", fragment.CreateOutputFile("service.txt"))
            .Finish();
            serviceProcessBuilder.ServiceKind          = ServicePipKind.Service;
            serviceProcessBuilder.ShutDownProcessPipId = shutdownProcess.PipId;
            serviceProcessBuilder.FinalizationPipIds   = ReadOnlyArray <PipId> .FromWithoutCopy(new[] { finalizationPip.PipId });

            (Process serviceProcess, ProcessOutputs _) = fragment.ScheduleProcessBuilder(serviceProcessBuilder);

            var createProcessBuilder = fragment.GetIpcProcessBuilder();

            new ArgumentsBuilder(createProcessBuilder)
            .AddStringOption("--command ", "create")
            .AddIpcMonikerOption("--ipcMoniker ", ipcMoniker)
            .Finish();
            var createOutputFile = fragment.CreateOutputFile("create.txt");
            var createPip        = fragment.ScheduleIpcPip(
                ipcMoniker,
                serviceProcess.PipId,
                createProcessBuilder,
                createOutputFile,
                false);

            XAssert.IsTrue(createPip.PipId.IsValid);

            if (pips != null)
            {
                pips.ShutDown     = shutdownProcess;
                pips.Final        = finalizationPip;
                pips.ServiceStart = serviceProcess;
                pips.Create       = createPip;
            }

            return(ipcMoniker, serviceProcess.PipId);
        }