My testng.xml is as given below:
<suite name="Automation Suite" allow-return-values="true" verbose="1" parallel="tests" thread-count="2">
<test name="Login Test cases 01">
<parameter name="Operating_System" value="Windows 8"/>
<parameter name="Browser_Name" value="Internet Explorer"/>
<parameter name="Browser_Version" value="11"/>
<parameter name="Base_URL" value="https://www.google.com"/>
<classes>
<class name="com.automation.tool.Automation_01"/>
<class name="com.automation.tool.Automation_02"/>
</classes>
</test>
<test name="Login Test cases 02">
<parameter name="Operating_System" value="Windows XP"/>
<parameter name="Browser_Name" value="Mozilla Firefox"/>
<parameter name="Browser_Version" value="27"/>
<parameter name="Base_URL" value="https://www.google.com"/>
<classes>
<class name="com.automation.tool.Automation_01"/>
<class name="com.automation.tool.Automation_02"/>
</classes>
</test>
</suite>
Currently the tests are getting executed in parallel. But I wish to execute the classes also in parallel as below:
Thread 01 : Test 01 Class 01
Thread 02 : Test 01 Class 02
Thread 03 : Test 02 Class 01
Thread 04 : Test 02 Class 02
Please let me know, how to configure this setup.
Got it now...
<suite name="Automation Suite" allow-return-values="true" verbose="1" parallel="tests" thread-count="2">
<test name="Login Test cases 01" parallel="classes" thread-count="2">
<parameter name="Operating_System" value="Windows 8"/>
<parameter name="Browser_Name" value="Internet Explorer"/>
<parameter name="Browser_Version" value="11"/>
<parameter name="Base_URL" value="https://www.google.com"/>
<classes>
<class name="com.automation.tool.Automation_01"/>
<class name="com.automation.tool.Automation_02"/>
</classes>
</test>
<test name="Login Test cases 02" parallel="classes" thread-count="2">
<parameter name="Operating_System" value="Windows XP"/>
<parameter name="Browser_Name" value="Mozilla Firefox"/>
<parameter name="Browser_Version" value="27"/>
<parameter name="Base_URL" value="https://www.google.com"/>
<classes>
<class name="com.automation.tool.Automation_01"/>
<class name="com.automation.tool.Automation_02"/>
</classes>
</test>
</suite>
In suite tag change the "parallel" attribute value from "tests" to "classes" for example:
If you wish to execute
tests in parallel then use = parallel="tests"
classes in parallel then use = parallel="classes"
Methods in parallel then use = parallel="methods"
Related
I am running an aspnet core site on Linux using Kestrel. I have set up nlog to log to csv files. All is well in my Windows development environment, but when I run it on Linux I only get one entry in the log file. I turned on nlog tracing and found the following error in the output:
2016-09-09 07:22:46.2123 Error Error has been raised. Exception: System.IO.IOException: The file '/var/aspnetcore/CSWebSite/releases/20160909061254/logs/archives/own-log.20160908.csv' already exists.
at System.IO.UnixFileSystem.MoveFile(String sourceFullPath, String destFullPath)
at System.IO.File.Move(String sourceFileName, String destFileName)
at NLog.Targets.FileTarget.ArchiveByDate(String fileName, String pattern, LogEventInfo logEvent)
at NLog.Targets.FileTarget.ProcessLogEvent(LogEventInfo logEvent, String fileName, Byte[] bytesToWrite)
at NLog.Targets.FileTarget.FlushCurrentFileWrites(String currentFileName, LogEventInfo firstLogEvent, MemoryStream ms, List`1 pendingContinuations)
2016-09-09 07:22:46.2123 Error Error has been raised. Exception: System.IO.IOException: The file '/var/aspnetcore/CSWebSite/releases/20160909061254/logs/archives/all-log.20160907.csv' already exists.
at System.IO.UnixFileSystem.MoveFile(String sourceFullPath, String destFullPath)
at System.IO.File.Move(String sourceFileName, String destFileName)
at NLog.Targets.FileTarget.ArchiveByDate(String fileName, String pattern, LogEventInfo logEvent)
at NLog.Targets.FileTarget.ProcessLogEvent(LogEventInfo logEvent, String fileName, Byte[] bytesToWrite)
at NLog.Targets.FileTarget.FlushCurrentFileWrites(String currentFileName, LogEventInfo firstLogEvent, MemoryStream ms, List`1 pendingContinuations)
This is my nlog.config:
<?xml version="1.0" encoding="utf-8" ?>
<nlog
xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<!--enable NLog.Web for ASP.NET Core-->
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<targets>
<!-- https://github.com/nlog/nlog/wiki/File-target -->
<!-- http://stackoverflow.com/questions/34679727/use-nlog-in-asp-net-5-application -->
<target name="allfile" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
<target name="allfile" xsi:type="File"
fileName="${basedir}/logs/all-logfile.csv"
archiveFileName="${basedir}/logs/archives/all-log.{#}.csv"
archiveEvery="Day"
archiveNumbering="Date"
archiveDateFormat="yyyyMMdd"
maxArchiveFiles="28"
concurrentWrites="true"
keepFileOpen="false"
encoding="utf-8">
<layout xsi:type="CSVLayout">
<column name="time" layout="${longdate}" />
<column name="logger" layout="${logger}" />
<column name="authtype" layout="${aspnet-user-authtype}" />
<column name="identity" layout="${aspnet-user-identity}" />
<column name="level" layout="${uppercase:${level}}" />
<column name="message" layout="${message} ${exception:format=ToString,StackTrace}" />
</layout>
</target>
</target>
<target name="ownfile" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
<target name="ownfile" xsi:type="File"
fileName="${basedir}/logs/own-logfile.csv"
archiveFileName="${basedir}/logs/archives/own-log.{#}.csv"
archiveEvery="Day"
archiveNumbering="Date"
archiveDateFormat="yyyyMMdd"
maxArchiveFiles="28"
concurrentWrites="true"
keepFileOpen="false"
encoding="utf-8">
<layout xsi:type="CSVLayout">
<column name="time" layout="${longdate}" />
<column name="logger" layout="${logger}" />
<column name="authtype" layout="${aspnet-user-authtype}" />
<column name="identity" layout="${aspnet-user-identity}" />
<column name="level" layout="${uppercase:${level}}" />
<column name="message" layout="${message} ${exception:format=ToString,StackTrace}" />
</layout>
</target>
</target>
<target xsi:type="Null" name="blackhole" />
</targets>
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Debug" writeTo="allfile" />
<!--Skip Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />
<logger name="*" minlevel="Debug" writeTo="ownFile" />
</rules>
</nlog>
I have concurrent writes true and keepFileOpen false which seems necessary as kestrel forks multiple dotnet processes on Linux.
Is this a bug or is my configuration incorrect?
This is my NLog Config file.
<?xml version="1.0" ?>
<nlog autoReload="true" throwExceptions="true" internalLogLevel="Debug" internalLogToConsole="true"
internalLogFile="c:\\temp\\nlog.txt"
>
<targets>
<!--Useful for debugging-->
<target name="consolelog" type="ColoredConsole"
layout="${date:format=HH\:mm\:ss}|${level}|${stacktrace}|${message}" />
<target name="filelog" type="File" fileName="c:\\temp\\nlog1.txt"
layout="${date}: ${message}" />
<target name="eventlog" type="EventLog" source="My App" log="Application"
layout="${date}: ${message} ${stacktrace}" />
<target name="databaselog" type="Database">
<dbProvider>sqlserver</dbProvider>
<!-- database connection parameters -->
<!-- alternatively you could provide a single 'connectionstring' parameter -->
<connectionString>Data Source=.\SQLEXPRESS;Initial Catalog=SnSolutions;User Id=sa;Password=test#1234#;</connectionString>
<!--<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=MyTest;User Id=mytest;Password=mytest123;" providerName="System.Data.SqlClient" />-->
<commandText>
insert into NLog_Error ([time_stamp],[level],[host],[type],1,[logger],[message],[stacktrace],[allxml]) values(#time_stamp,#level,#host,#type,#source,#logger,#message,#stacktrace,#allxml);
</commandText>
<parameter name="#time_stamp" layout="${date}" />
<parameter name="#level" layout="${level}" />
<parameter name="#host" layout="${machinename}" />
<parameter name="#type" layout="${exception:format=type}" />
<parameter name="#source" layout="${callsite:className=true:fileName=false:includeSourcePath=false:methodName=false}" />
<parameter name="#logger" layout="${logger}" />
<parameter name="#message" layout="${message}" />
<parameter name="#stacktrace" layout="${exception:stacktrace}" />
<parameter name="#allxml" layout="${web_variables}" />
</target>
</targets>
<rules>
<!--
<logger name="*" minlevel="Fatal" writeTo="eventlog" />
-->
<logger name="*" minlevel="Info" writeTo="filelog" />
<logger name="*" minlevel="Info" writeTo="databaselog" />
</rules>
</nlog>
This is my NLogLogger Class
public class NLogLogger
{
private readonly Logger _logger;
public NLogLogger(Logger logger)
{
_logger = logger;
}
public NLogLogger()
{
StackFrame frame = new StackFrame(1, false);
_logger = LogManager.GetLogger(frame.GetMethod().DeclaringType.FullName);
}
public void Trace(string message)
{
_logger.Trace(message);
}
public void Debug(string message)
{
_logger.Debug(message);
}
public void Info(string message)
{
_logger.Info(message);
}
public void Warn(string message)
{
_logger.Warn(message);
}
public void Error(string message)
{
_logger.Error(message);
}
public void Fatal(string message)
{
_logger.Fatal(message);
}
}
which I am trying to use in the following way.
NLogLogger logger = new NLogLogger();
logger.Info("We're on the Index page for Activities");
But not able to see any records in the DB nor any error in the File System.
Please let me know which is the part I am missing.
Thanks in advance.
You have an error in insert command - 1 is not a valid column name.
insert into NLog_Error (...[type],1,[logger]..)
Here is an example regarding logging to DB.
I am working on a consignment booking software.
The consignment object has the following structure:
public class Consignment
{
//Other properties
public virtual Station FromStation{get;set;}
public virtual Station ToStation{get;set;}
}
and here is the station object:
public class Station
{
public virtual int StationId{get;set;}
public virtual string StationName{get;set;}
//I don't want this property but I have to keep it.
public virtual Iesi.Collections.Generic.ISet<Consginment> ConsginmentFrom
{
get;
set;
}
//I don't want this property but I have to keep it here.
public virtual Iesi.Collections.Generic.ISet<Consginment> ConsginmentTo
{
get;
set;
}
}
In the database side, there would be a Station table, and the Consignment table would have two int columns (called FromStation and ToStation), storing the ids of the station.
I am not much of an NHibernate guy, after googling and reading for half a day I came up with the following Mapping Files:
Station.hbm.xml
<class name="Station" table="Station">
<id name="StationId" >
<column name="STATION_ID" not-null="true" />
<generator class="identity" />
</id>
<property name="StationName" >
<column name="STATION_NAME" not-null="true" />
</property>
<set name="ConsginmentFrom" inverse="true" lazy="true" generic="true">
<key>
<column name="StationId" />
</key>
<one-to-many class="Consignment" />
</set>
<set name="ConsignmentTo" inverse="true" lazy="false" generic="true">
<key>
<column name="StationId" />
</key>
<one-to-many class="Consignment" />
</set>
</class>
Consignment.hbm.xml
<class name="Consignment" abstract="true"
table="Consignment" lazy="false">
<id name="ConsignmentId">
<generator class="hilo"/>
</id>
<!--Column mapping for other properties-->
<many-to-one name="FromStation" class="Station">
<column name="STATION_ID" not-null="true" />
</many-to-one>
<many-to-one name="ToStation" class="Station">
<column name="STATION_ID" not-null="true" />
</many-to-one>
</class>
But the above is generating strange DB structure.
I have to do it xml mapping files as a lot has already been written in xml.
Am I doing it correctly? Can there be a better way?
Thanks for reading this.
There are a few things I can see wrong with the mappings.
The FromStation and ToStation properties map to the same column in the Consignment table. They should map to different columns such as FROM_STATION_ID and TO_STATION_ID:
<many-to-one name="FromStation" class="Station">
<column name="FROM_STATION_ID" not-null="true" />
</many-to-one>
<many-to-one name="ToStation" class="Station">
<column name="TO_STATION_ID" not-null="true" />
</many-to-one>
The Set for ConsignmentFrom and ConsignmentTo in Station maps to StationID instead of Station_Id. Also you need to use the FROM_STATION_ID AND TO_STATION_ID as the key columns.
<set name="ConsignmentFrom" inverse="true" lazy="true" generic="true">
<key column="FROM_STATION_ID" />
<one-to-many class="Consignment" />
</set>
<set name="ConsignmentTo" inverse="true" lazy="false" generic="true">
<key colum="TO_STATION_ID" />
<one-to-many class="Consignment" />
</set>
Also consignment is misspelt in some places which may also cause some confusion.
I embedded a png in as3, it's all fine on windows, either use FB4.6 or Ant. But while build with Ant under linux(debian), I got this Error. Image path is /var/lib/jenkins/workspace/q5/dev_Flash/code/Copper/src/assets/c001_up.png. Project name is /var/lib/jenkins/workspace/q5/dev_Flash/code/Copper.
[mxmlc] /var/lib/jenkins/workspace/q5/dev_Flash/code/Copper/src/com/copper/ui/skin/DefaultAssets.as(10): col: 3: Error: unable to resolve 'assets/c001_up.png' for transcoding
[mxmlc]
[mxmlc] [Embed(source = "assets/c001_up.png")]
[mxmlc] ^
[mxmlc]
[mxmlc] /var/lib/jenkins/workspace/q5/dev_Flash/code/Copper/src/com/copper/ui/skin/DefaultAssets.as(10): col: 3: Error: Unable to transcode assets/c001_up.png.
as3 file like this
package com.copper.ui.skin {
/**
*
* #author marzwu
*
*/
public class DefaultAssets extends Assets {
[Embed(source = "assets/c001_up.png")]
private var Button_Up:Class;
My ant file is:
<?xml version="1.0" encoding="UTF-8"?>
Q5客户端构建
<!-- 配置属性 -->
<property file="build.properties" />
<property environment="env" />
<property name="FLEX_HOME" value="${env.FLEX_HOME}" />
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<target name="compile">
<echo message="${basedir}/../src" />
<compc output="../bin/copper.swc" debug="false" incremental="true">
<!-- 指定Comman项目的源码目录 -->
<source-path path-element="${basedir}/../src" />
<!-- 指定编译的文件列表 -->
<include-sources dir="${basedir}/../src">
<include name="**/*.as" />
</include-sources>
<!-- 将Flex SDK 作为外部库进行引用 -->
<compiler.external-library-path dir="${FLEX_HOME}/frameworks">
<include name="**/*.swc" />
</compiler.external-library-path>
<!-- 添加项目中的SWC包,请注意这里是外部 -->
<compiler.external-library-path dir="../libs">
<include name="**/*.swc" />
</compiler.external-library-path>
<define name="CONFIG::Debug" value="true" />
<define name="CONFIG::Release" value="false" />
<jvmarg value="-Xmx2048m"/>
<jvmarg value="-Xms512m"/>
<jvmarg value="-XX:MaxPermSize=512m"/>
</compc>
<!-- 删除缓存文件 -->
<delete>
<fileset dir="../bin" includes="*.cache" />
</delete>
<echo message="complier Flex Library Project finished!" />
</target>
<target name="deploy">
<antcall target="compile" />
<!--antcall target="copy_to_bin" /-->
<echo>前往查看结果:http://10.0.1.69/q5d/</echo>
<echo message="执行发布" />
</target>
I use jenkins to build my as3 project. It's bother me for many day. Appreciate for your helping.
Oops, compiler can't resolve the path, because I did not notice the "u" between "c001_up.png" is an upper case letter. Windows are not sensitive of letter case, but linux are. My fault, thank you for your time.
I'm a bit baffled by the results I'm seeing in my CruiseControl.Net build log. The build fails after a few minutes but I can't figure out what's causing it.
<cruisecontrol project="Bromley Live">
<request source="ITUSER-PC" buildCondition="ForceBuild">Build (ForceBuild) triggered from ITUSER-PC</request>
<parameters>
<parameter name="CCNetForceBuildReason" value="Debugging" />
<parameter name="$CCNetArtifactDirectory" value="C:\CCNet\Projects\Bromley Live\Artifacts" />
<parameter name="$CCNetBuildCondition" value="ForceBuild" />
<parameter name="$CCNetBuildDate" value="2011-06-02" />
<parameter name="$CCNetBuildTime" value="14:34:38" />
<parameter name="$CCNetFailureUsers" value="System.Collections.ArrayList" />
<parameter name="$CCNetIntegrationStatus" value="Unknown" />
<parameter name="$CCNetLabel" value="1.0.0.0" />
<parameter name="$CCNetLastIntegrationStatus" value="Failure" />
<parameter name="$CCNetListenerFile" value="C:\CCNet\Projects\Bromley Live\Artifacts\Bromley Live_ListenFile.xml" />
<parameter name="$CCNetModifyingUsers" value="System.Collections.ArrayList" />
<parameter name="$CCNetNumericLabel" value="0" />
<parameter name="$CCNetProject" value="Bromley Live" />
<parameter name="$CCNetProjectUrl" value="http://CIBuildServer/CruiseControl/server/local/project/Bromley Live/ViewProjectReport.aspx" />
<parameter name="$CCNetRequestSource" value="OCL-DEV-WEB" />
<parameter name="$CCNetUser" value="" />
<parameter name="$CCNetWorkingDirectory" value="C:\CCNet\Projects\Bromley Live\WorkingDirectory" />
</parameters>
<modifications />
<integrationProperties>
<CCNetArtifactDirectory>C:\CCNet\Projects\Bromley Live\Artifacts</CCNetArtifactDirectory>
<CCNetBuildCondition>ForceBuild</CCNetBuildCondition>
<CCNetBuildDate>2011-06-02</CCNetBuildDate>
<CCNetBuildTime>14:34:38</CCNetBuildTime>
<CCNetFailureUsers />
<CCNetIntegrationStatus>Failure</CCNetIntegrationStatus>
<CCNetLabel>1.0.0.0</CCNetLabel>
<CCNetLastIntegrationStatus>Failure</CCNetLastIntegrationStatus>
<CCNetListenerFile>C:\CCNet\Projects\Bromley Live\Artifacts\Bromley Live_ListenFile.xml</CCNetListenerFile>
<CCNetModifyingUsers />
<CCNetNumericLabel>0</CCNetNumericLabel>
<CCNetProject>Bromley Live</CCNetProject>
<CCNetProjectUrl>http://CIBuildServer/CruiseControl/server/local/project/Bromley Live/ViewProjectReport.aspx</CCNetProjectUrl>
<CCNetRequestSource>ITUSER-PC</CCNetRequestSource>
<CCNetWorkingDirectory>C:\CCNet\Projects\Bromley Live\WorkingDirectory</CCNetWorkingDirectory>
<LastIntegrationStatus>Failure</LastIntegrationStatus>
<LastSuccessfulIntegrationLabel>UNKNOWN</LastSuccessfulIntegrationLabel>
<LastModificationDate>01/06/2011 14:35:34</LastModificationDate>
<CCNetForceBuildReason>Debugging</CCNetForceBuildReason>
</integrationProperties>
<build date="2011-06-02 14:34:38" buildtime="00:00:56" error="true" buildcondition="ForceBuild">
<buildresults>
<message>The command completed successfully.</message>
</buildresults>
<buildresults>
<message>-------------------------------------------------------------------------------</message>
<message> ROBOCOPY :: Robust File Copy for Windows </message>
<message>-------------------------------------------------------------------------------</message>
<message> Started : Thu Jun 02 14:34:38 2011</message>
<message> Source : C:\CCNet\Projects\Bromley Live\WorkingDirectory\Website\</message>
<message> Dest : \\LiveServer\wwwroot$\Bromley\</message>
<message> Files : *.*</message>
<message> </message>
<message>Exc Files : Thumbs.db</message>
<message> *.scc</message>
<message> </message>
<message> Exc Dirs : .hg</message>
<message> </message>
<message> Options : *.* /NS /NC /NDL /S /E /COPY:DAT /NP /XO /XA:H /R:1000000 /W:30 </message>
<message>------------------------------------------------------------------------------</message>
<message> \\LiveServer\wwwroot$\Bromley\admin\legacy\selfAssessment\uploadVisitReport.asp</message>
<message> \\LiveServer\wwwroot$\Bromley\Bin\AjaxControlToolkit.pdb</message>
<message> C:\CCNet\Projects\Bromley Live\WorkingDirectory\Website\userControls\IconMenuTopControl.ascx</message>
<message> C:\CCNet\Projects\Bromley Live\WorkingDirectory\Website\userControls\IconMenuTopControl.ascx.vb</message>
<message>------------------------------------------------------------------------------</message>
<message> Total Copied Skipped Mismatch FAILED Extras</message>
<message> Dirs : 212 0 212 0 0 16</message>
<message> Files : 1804 45 1759 0 0 203</message>
<message> Bytes : 44.46 m 2.89 m 41.57 m 0 0 2.03 m</message>
<message> Times : 0:00:55 0:00:16 0:00:00 0:00:39</message>
<message> Speed : 185068 Bytes/sec.</message>
<message> Speed : 10.589 MegaBytes/min.</message>
<message> Ended : Thu Jun 02 14:35:34 2011</message>
</buildresults>
</build>
</cruisecontrol>
Robocopy does not return proper exit status codes (that is, 0 on success). To work around this, you have to use the successExitCodes attibute on your executable task. Setting it to "0,1,2" should work (you want the task to fail on other results). (Robocopy exit codes list as a reference.)