public void ChangedStartMode() { string yaml = $@" id: service.exe name: Service description: The Service. executable: node.exe arguments: My Arguments startMode: manual"; this._extendedServiceDescriptor = ServiceDescriptorYaml.FromYaml(yaml).Configurations; Assert.That(this._extendedServiceDescriptor.StartMode, Is.EqualTo(StartMode.Manual)); }
public override void Configure(IWinSWConfiguration descriptor, XmlNode node) { // We expect the upper logic to process any errors // TODO: a better parser API for types would be useful this.Pidfile = XmlHelper.SingleElement(node, "pidfile", false) !; this.StopTimeout = TimeSpan.FromMilliseconds(int.Parse(XmlHelper.SingleElement(node, "stopTimeout", false) !)); this.StopParentProcessFirst = bool.Parse(XmlHelper.SingleElement(node, "stopParentFirst", false) !); this.ServiceId = descriptor.Id; // TODO: Consider making it documented string?checkWinSWEnvironmentVariable = XmlHelper.SingleElement(node, "checkWinSWEnvironmentVariable", true); this.CheckWinSWEnvironmentVariable = checkWinSWEnvironmentVariable is null ? true : bool.Parse(checkWinSWEnvironmentVariable); }
public void IncorrectStartMode() { string yaml = $@" id: service.exe name: Service description: The Service. executable: node.exe arguments: My Arguments startMode: roll"; this._extendedServiceDescriptor = ServiceDescriptorYaml.FromYaml(yaml).Configurations; Assert.That(() => this._extendedServiceDescriptor.StartMode, Throws.ArgumentException); }
public WrapperService(IWinSWConfiguration descriptor) { this.descriptor = descriptor; this.ServiceName = this.descriptor.Id; this.ExtensionManager = new WinSWExtensionManager(this.descriptor); this.CanShutdown = true; this.CanStop = true; this.CanPauseAndContinue = false; this.AutoLog = true; this.systemShuttingdown = false; // Register the event log provider eventLogProvider.Service = this; }
public override void Configure(IWinSWConfiguration descriptor, XmlNode node) { XmlNodeList?mapNodes = XmlHelper.SingleNode(node, "mapping", false) !.SelectNodes("map"); if (mapNodes != null) { for (int i = 0; i < mapNodes.Count; i++) { if (mapNodes[i] is XmlElement mapElement) { var config = SharedDirectoryMapperConfig.FromXml(mapElement); this._entries.Add(config); } } } }
public override void Configure(IWinSWConfiguration descriptor, YamlExtensionConfiguration config) { var dict = config.GetSettings(); this.Pidfile = (string)dict["pidfile"]; this.StopTimeout = TimeSpan.FromMilliseconds(int.Parse((string)dict["stopTimeOut"])); this.StopParentProcessFirst = bool.Parse((string)dict["StopParentFirst"]); try { this.CheckWinSWEnvironmentVariable = bool.Parse((string)dict["checkWinSWEnvironmentVariable"]); } catch { this.CheckWinSWEnvironmentVariable = true; } }
public override void Configure(IWinSWConfiguration descriptor, YamlExtensionConfiguration config) { var dict = config.GetSettings(); var mappingNode = dict["mapping"]; if (!(mappingNode is List <object> mappings)) { throw new InvalidDataException("SharedDirectoryMapper mapping should be a list"); } foreach (var map in mappings) { var mapConfig = SharedDirectoryMapperConfig.FromYaml(map); this._entries.Add(mapConfig); } }
public void SetUp() { string seedXml = $@"<service> <id>SERVICE_NAME</id> <name>Jenkins Slave</name> <description>This service runs a slave for Jenkins continuous integration system.</description> <executable>C:\Program Files\Java\jre7\bin\java.exe</executable> <arguments>-Xrs -jar \""%BASE%\slave.jar\"" -jnlpUrl ...</arguments> <log mode=""roll""></log> <extensions> <extension enabled=""true"" className=""{this.testExtension}"" id=""killRunawayProcess""> <pidfile>foo/bar/pid.txt</pidfile> <stopTimeout>5000</stopTimeout> <stopParentFirst>true</stopParentFirst> </extension> </extensions> </service>"; this._testServiceDescriptor = ServiceDescriptor.FromXML(seedXml); string seedYaml = $@"--- id: jenkins name: Jenkins description: This service runs Jenkins automation server. env: - name: JENKINS_HOME value: '%LocalAppData%\Jenkins.jenkins' executable: java arguments: >- -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar E:\Winsw Test\yml6\jenkins.war --httpPort=8081 extensions: - id: killRunawayProcess enabled: yes className: ""{this.testExtension}"" settings: pidfile: 'foo/bar/pid.txt' stopTimeOut: 5000 StopParentFirst: true"; this._testServiceDescriptorYaml = ServiceDescriptorYaml.FromYaml(seedYaml).Configurations; }
public void SetUp() { string yaml = $@" id: service.exe name: Service description: The Service. executable: node.exe arguments: My Arguments log: mode: roll logpath: c:\logs serviceaccount: domain: {Domain} user: {Username} password: {Password} allowservicelogon: {AllowServiceAccountLogonRight} workingdirectory: {ExpectedWorkingDirectory}"; this._extendedServiceDescriptor = ServiceDescriptorYaml.FromYaml(yaml).Configurations; }
public virtual void Configure(IWinSWConfiguration descriptor, YamlExtensionConfiguration config) { // Do nothing }
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. public virtual void Configure(IWinSWConfiguration descriptor, XmlNode node) { // Do nothing }
public WinSWExtensionManager(IWinSWConfiguration serviceDescriptor) { this.ServiceDescriptor = serviceDescriptor; this.Extensions = new Dictionary <string, IWinSWExtension>(); }
public void SetUp() { string seedXml = $@"<service> <id>SERVICE_NAME</id> <name>Jenkins Slave</name> <description>This service runs a slave for Jenkins continuous integration system.</description> <executable>C:\Program Files\Java\jre7\bin\java.exe</executable> <arguments>-Xrs -jar \""%BASE%\slave.jar\"" -jnlpUrl ...</arguments> <log mode=""roll""></log> <extensions> <extension enabled=""true"" className=""{this.testExtension}"" id=""mapNetworDirs""> <mapping> <map enabled=""false"" label=""N:"" uncpath=""\\UNC""/> <map enabled=""false"" label=""M:"" uncpath=""\\UNC2""/> </mapping> </extension> <extension enabled=""true"" className=""{this.testExtension}"" id=""mapNetworDirs2""> <mapping> <map enabled=""false"" label=""X:"" uncpath=""\\UNC""/> <map enabled=""false"" label=""Y:"" uncpath=""\\UNC2""/> </mapping> </extension> </extensions> </service>"; this._testServiceDescriptor = ServiceDescriptor.FromXML(seedXml); string seedYaml = $@"--- id: jenkins name: Jenkins description: This service runs Jenkins automation server. env: - name: JENKINS_HOME value: '%LocalAppData%\Jenkins.jenkins' executable: java arguments: >- -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar E:\Winsw Test\yml6\jenkins.war --httpPort=8081 extensions: - id: mapNetworDirs className: ""{this.testExtension}"" enabled: true settings: mapping: - enabled: false label: N uncpath: \\UNC - enabled: false label: M uncpath: \\UNC2 - id: mapNetworDirs2 className: ""{this.testExtension}"" enabled: true settings: mapping: - enabled: false label: X uncpath: \\UNC - enabled: false label: Y uncpath: \\UNC2"; this._testServiceDescriptorYaml = ServiceDescriptorYaml.FromYaml(seedYaml).Configurations; }