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); }
public void ChangedStartMode() { const string SeedXml = "<service>" + "<id>service.exe</id>" + "<name>Service</name>" + "<description>The service.</description>" + "<executable>node.exe</executable>" + "<arguments>My Arguments</arguments>" + "<startmode>manual</startmode>" + "<logmode>rotate</logmode>" + "<serviceaccount>" + "<domain>" + Domain + "</domain>" + "<user>" + Username + "</user>" + "<password>" + Password + "</password>" + "<allowservicelogon>" + AllowServiceAccountLogonRight + "</allowservicelogon>" + "</serviceaccount>" + "<workingdirectory>" + ExpectedWorkingDirectory + "</workingdirectory>" + @"<logpath>C:\logs</logpath>" + "</service>"; _extendedServiceDescriptor = ServiceDescriptor.FromXML(SeedXml); Assert.That(_extendedServiceDescriptor.StartMode, Is.EqualTo(StartMode.Manual)); }
public void SetUp() { string testExtension = typeof(SharedDirectoryMapper).ToString(); string seedXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<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> " + " <logmode>rotate</logmode> " + " <extensions> " + " <extension enabled=\"true\" className=\"" + testExtension + "\" id=\"mapNetworDirs\"> " + " <mapping> " + " <map enabled=\"false\" label=\"N:\" uncpath=\"\\\\UNC\"/> " + " <map enabled=\"false\" label=\"M:\" uncpath=\"\\\\UNC2\"/> " + " </mapping> " + " </extension> " + " <extension enabled=\"true\" className=\"" + testExtension + "\" id=\"mapNetworDirs2\"> " + " <mapping> " + " <map enabled=\"false\" label=\"X:\" uncpath=\"\\\\UNC\"/> " + " <map enabled=\"false\" label=\"Y:\" uncpath=\"\\\\UNC2\"/> " + " </mapping> " + " </extension> " + " </extensions> " + "</service>"; _testServiceDescriptor = ServiceDescriptor.FromXML(seedXml); }
public void CanParseOutfileDisabled() { const string seedXml = "<service>" + "<outfiledisabled>true</outfiledisabled>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); Assert.That(serviceDescriptor.OutFileDisabled, Is.EqualTo(true)); }
public void CanParseErrfileDisabled() { const string seedXml = "<service>" + "<errfiledisabled>true</errfiledisabled>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); Assert.That(serviceDescriptor.ErrFileDisabled, Is.True); }
public void CanParseLogname() { const string seedXml = "<service>" + "<logname>MyTestApp</logname>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); Assert.That(serviceDescriptor.LogName, Is.EqualTo("MyTestApp")); }
public void CanParseStopParentProcessFirst() { const string seedXml = "<service>" + "<stopparentprocessfirst>true</stopparentprocessfirst>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); Assert.That(serviceDescriptor.StopParentProcessFirst, Is.True); }
public void CanParseStopTimeout() { const string seedXml = "<service>" + "<stoptimeout>60sec</stoptimeout>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); Assert.That(serviceDescriptor.StopTimeout, Is.EqualTo(TimeSpan.FromSeconds(60))); }
public void CanParseStopTimeoutFromMinutes() { const string seedXml = "<service>" + "<stoptimeout>10min</stoptimeout>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); Assert.That(serviceDescriptor.StopTimeout, Is.EqualTo(TimeSpan.FromMinutes(10))); }
public void CanParseOutfilePattern() { const string seedXml = "<service>" + "<outfilepattern>.out.test.log</outfilepattern>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); Assert.That(serviceDescriptor.OutFilePattern, Is.EqualTo(".out.test.log")); }
public void CanParseErrfilePattern() { const string seedXml = "<service>" + "<errfilepattern>.err.test.log</errfilepattern>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); Assert.That(serviceDescriptor.ErrFilePattern, Is.EqualTo(".err.test.log")); }
public void Priority() { var sd = ServiceDescriptor.FromXML("<service><id>test</id><priority>normal</priority></service>"); Assert.That(sd.Priority, Is.EqualTo(ProcessPriorityClass.Normal)); sd = ServiceDescriptor.FromXML("<service><id>test</id><priority>idle</priority></service>"); Assert.That(sd.Priority, Is.EqualTo(ProcessPriorityClass.Idle)); sd = ServiceDescriptor.FromXML("<service><id>test</id></service>"); Assert.That(sd.Priority, Is.EqualTo(ProcessPriorityClass.Normal)); }
public void VerifyServiceLogonRightOmitted() { const string seedXml = "<service>" + "<serviceaccount>" + "<domain>" + Domain + "</domain>" + "<user>" + Username + "</user>" + "<password>" + Password + "</password>" + "</serviceaccount>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); Assert.That(serviceDescriptor.AllowServiceAcountLogonRight, Is.False); }
public void VerifyServiceLogonRightGraceful() { const string seedXml = "<service>" + "<serviceaccount>" + "<domain>" + Domain + "</domain>" + "<user>" + Username + "</user>" + "<password>" + Password + "</password>" + "<allowservicelogon>true1</allowservicelogon>" + "</serviceaccount>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); Assert.That(serviceDescriptor.AllowServiceAcountLogonRight, Is.EqualTo(false)); }
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 LogModeRollBySize() { const string seedXml = "<service>" + "<logpath>c:\\</logpath>" + "<log mode=\"roll-by-size\">" + "<sizeThreshold>112</sizeThreshold>" + "<keepFiles>113</keepFiles>" + "</log>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); serviceDescriptor.BaseName = "service"; var logHandler = serviceDescriptor.LogHandler as SizeBasedRollingLogAppender; Assert.That(logHandler, Is.Not.Null); Assert.That(logHandler.SizeTheshold, Is.EqualTo(112 * 1024)); Assert.That(logHandler.FilesToKeep, Is.EqualTo(113)); }
public void LogModeRollByTime() { const string seedXml = "<service>" + "<logpath>c:\\</logpath>" + "<log mode=\"roll-by-time\">" + "<period>7</period>" + "<pattern>log pattern</pattern>" + "</log>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); serviceDescriptor.BaseName = "service"; var logHandler = serviceDescriptor.LogHandler as TimeBasedRollingLogAppender; Assert.That(logHandler, Is.Not.Null); Assert.That(logHandler.Period, Is.EqualTo(7)); Assert.That(logHandler.Pattern, Is.EqualTo("log pattern")); }
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> <logmode>rotate</logmode> <extensions> <extension enabled=""true"" className=""{testExtension}"" id=""killRunawayProcess""> <pidfile>foo/bar/pid.txt</pidfile> <stopTimeout>5000</stopTimeout> <stopParentFirst>true</stopParentFirst> </extension> </extensions> </service>"; _testServiceDescriptor = ServiceDescriptor.FromXML(seedXml); }
public void SetUp() { string seedXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<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> " + " <logmode>rotate</logmode> " + " <extensions> " + " <extension enabled=\"true\" className=\"" + testExtension + "\" id=\"killRunawayProcess\"> " + " <pidfile>foo/bar/pid.txt</pidfile>" + " <stopTimeout>5000</stopTimeout> " + " <stopParentFirst>true</stopParentFirst>" + " </extension> " + " </extensions> " + "</service>"; _testServiceDescriptor = ServiceDescriptor.FromXML(seedXml); }
public void LogModeRollBySizeTime() { const string seedXml = "<service>" + "<logpath>c:\\</logpath>" + "<log mode=\"roll-by-size-time\">" + "<sizeThreshold>10240</sizeThreshold>" + "<pattern>yyyy-MM-dd</pattern>" + "<autoRollAtTime>00:00:00</autoRollAtTime>" + "</log>" + "</service>"; var serviceDescriptor = ServiceDescriptor.FromXML(seedXml); serviceDescriptor.BaseName = "service"; var logHandler = serviceDescriptor.LogHandler as RollingSizeTimeLogAppender; Assert.That(logHandler, Is.Not.Null); Assert.That(logHandler.SizeTheshold, Is.EqualTo(10240 * 1024)); Assert.That(logHandler.FilePattern, Is.EqualTo("yyyy-MM-dd")); Assert.That(logHandler.AutoRollAtTime, Is.EqualTo((TimeSpan?)new TimeSpan(0, 0, 0))); }
public void SetUp() { const string SeedXml = "<service>" + "<id>service.exe</id>" + "<name>Service</name>" + "<description>The service.</description>" + "<executable>node.exe</executable>" + "<arguments>My Arguments</arguments>" + "<logmode>rotate</logmode>" + "<serviceaccount>" + "<domain>" + Domain + "</domain>" + "<user>" + Username + "</user>" + "<password>" + Password + "</password>" + "</serviceaccount>" + "<workingdirectory>" + ExpectedWorkingDirectory + "</workingdirectory>" + @"<logpath>C:\logs</logpath>" + "</service>"; extendedServiceDescriptor = ServiceDescriptor.FromXML(SeedXml); }
public void SetUp() { string seedXml = $@"<service> <id>service.exe</id> <name>Service</name> <description>The service.</description> <executable>node.exe</executable> <arguments>My Arguments</arguments> <log mode=""roll""></log> <serviceaccount> <domain>{Domain}</domain> <user>{Username}</user> <password>{Password}</password> <allowservicelogon>{AllowServiceAccountLogonRight}</allowservicelogon> </serviceaccount> <workingdirectory>{ExpectedWorkingDirectory}</workingdirectory> <logpath>C:\logs</logpath> </service>"; _extendedServiceDescriptor = ServiceDescriptor.FromXML(seedXml); }
public void IncorrectStartMode() { string seedXml = $@"<service> <id>service.exe</id> <name>Service</name> <description>The service.</description> <executable>node.exe</executable> <arguments>My Arguments</arguments> <startmode>roll</startmode> <log mode=""roll""></log> <serviceaccount> <domain>{Domain}</domain> <user>{Username}</user> <password>{Password}</password> <allowservicelogon>{AllowServiceAccountLogonRight}</allowservicelogon> </serviceaccount> <workingdirectory>{ExpectedWorkingDirectory}</workingdirectory> <logpath>C:\logs</logpath> </service>"; this._extendedServiceDescriptor = ServiceDescriptor.FromXML(seedXml); Assert.That(() => this._extendedServiceDescriptor.StartMode, Throws.ArgumentException); }
public void ChangedStartMode() { string seedXml = $@"<service> <id>service.exe</id> <name>Service</name> <description>The service.</description> <executable>node.exe</executable> <arguments>My Arguments</arguments> <startmode>manual</startmode> <logmode>rotate</logmode> <serviceaccount> <domain>{Domain}</domain> <user>{Username}</user> <password>{Password}</password> <allowservicelogon>{AllowServiceAccountLogonRight}</allowservicelogon> </serviceaccount> <workingdirectory>{ExpectedWorkingDirectory}</workingdirectory> <logpath>C:\logs</logpath> </service>"; _extendedServiceDescriptor = ServiceDescriptor.FromXML(seedXml); Assert.That(_extendedServiceDescriptor.StartMode, Is.EqualTo(StartMode.Manual)); }
public ServiceDescriptor ToServiceDescriptor(bool dumpConfig = false) { return(ServiceDescriptor.FromXML(this.ToXMLString(dumpConfig))); }
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; }