Jenkins Setup in 20 minitues

Feb 2016, By WZh

This some Jenkins key points to note down:

1. Get the jenkin war file from https://jenkins-ci.org/2. Install the tomcat server, to run in linux.

3. Copy the jenkins.war file to the webapp folder of the tomcat, restart tomcat.

then you can access this URL to access jenkins:

http://192.168.***.***/jenkins/

4. At this step, you are still using anonymous user to access jenkins.

5. jenkin will using a default folder to save all jenkins related data files into it.

You can change to other folder as you want , eg. /opt/jenkins

6. Go to “Manage Jenkins”–>”Configure System” to do basic config for a jenkins, major points:

1. JDK Name and JAVA_HOME  , or you can let jenkins to install the JDK automatically

2. ANT  refer to your ANT or let jenkins to install one for you.

3. MAVEN refer to your ANT or let jenkins to install one for you.

4. jenkins URL:     http://192.168.160.48/jenkins/

5. CVS or Subversion; if you use Subversion, you just need to select one version here. later in each job, you input svn URL and user accounts

just save it.

7. Create job and run job according your schedule:

Note:

1. “default” when you first time using ANT/Maven will cause issue when they are auto installer. S better to refer to the specific version for them.

2. Build periodically will use cron format, do a bit study for it.

If you want every five minitues:      */5 * * * *

If you want every one hour:         H */1 * * *

8. Maven project in you eclipse will be easily run in jenkin.

9. ANT project sometimes need to test and make the build.xml working fine both at eclipse and also the jenkins environment, and you may need to add change abit your ant xml.

10. use “Manage Jenkins”–>”Configure Global Security” to enable the security , normally will use the :

1. “Jenkins’ own user database” unless you intergrate with enterprise AD/LDAP

2. “Matrix-based security” to let each user be controlled.

Advertisements

MAVEN basics


https://maven.apache.org/guides/getting-started/index.html

Installing Apache Maven

The installation of Apache Maven is a simple process of extracting the archive and adding the bin folder with the mvn command to the PATH.

Detailed steps are:

Ensure
JAVA_HOME environment variable is set and points to your JDK installation

        unzip apache-maven-3.3.3-bin.zip

Add the bin directory of the created directory apache-maven-3.3.3 to the PATH environment variable,change your file of /etc/profile to add :

        export PATH=/opt/apache-maven-3.3.3/bin:$PATH

and also run this command too, then run this command to confirm installed in a new console
        mvn -v

create a sample project and to learn it

    cd /temp

    mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
cd my-app
mvn package
java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App

Although hardly a comprehensive list, these are the most common default lifecycle phases executed.

  • validate: validate the project is correct and all necessary information is available
  • compile: compile the source code of the project
  • test: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
  • package: take the compiled code and package it in its distributable format, such as a JAR.
  • integration-test: process and deploy the package if necessary into an environment where integration tests can be run
  • verify: run any checks to verify the package is valid and meets quality criteria
  • install: install the package into the local repository, for use as a dependency in other projects locally
  • deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

There are two other Maven lifecycles of note beyond the default list above. They are

  • clean: cleans up artifacts created by prior builds
  • site: generates site documentation for this project



This is a very simple POM but still displays the key elements every POM contains, so let’s walk through each of them to familiarize you with the POM essentials:

  • project This is the top-level element in all Maven pom.xml files.
  • modelVersion This element indicates what version of the object model this POM is using. The version of the model itself changes very infrequently but it is mandatory in order to ensure stability of use if and when the Maven developers deem it necessary to change the model.
  • groupId This element indicates the unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of a project and is typically based on the fully qualified domain name of your organization. For example org.apache.maven.plugins is the designated groupId for all Maven plug-ins.
  • artifactId This element indicates the unique base name of the primary artifact being generated by this project. The primary artifact for a project is typically a JAR file. Secondary artifacts like source bundles also use the artifactId as part of their final name. A typical artifact produced by Maven would have the form <artifactId>-<version>.<extension> (for example, myapp-1.0.jar).
  • packaging This element indicates the package type to be used by this artifact (e.g. JAR, WAR, EAR, etc.). This not only means if the artifact produced is JAR, WAR, or EAR but can also indicate a specific lifecycle to use as part of the build process. (The lifecycle is a topic we will deal with further on in the guide. For now, just keep in mind that the indicated packaging of a project can play a part in customizing the build lifecycle.) The default value for the packaging element is JAR so you do not have to specify this for most projects.
  • version This element indicates the version of the artifact generated by the project. Maven goes a long way to help you with version management and you will often see the SNAPSHOT designator in a version, which indicates that a project is in a state of development. We will discuss the use of snapshots and how they work further on in this guide.
  • name This element indicates the display name used for the project. This is often used in Maven’s generated documentation.
  • url This element indicates where the project’s site can be found. This is often used in Maven’s generated documentation.
  • description This element provides a basic description of your project. This is often used in Maven’s generated documentation.
With this information about a dependency, Maven will be able to 
reference the dependency when it builds the project. Where does Maven 
reference the dependency from? Maven looks in your local repository (~/.m2/repository is the default location) to find all dependencies. 

What about dependencies built somewhere else? How do they get into my 
local repository? Whenever a project references a dependency that isn't 
available in the local repository, Maven will download the dependency 
from a remote repository into the local repository. 

Let’s add another dependency to our project. Let’s say we’ve added some logging to the code and need to add log4j as a dependency. First, we need to know what the groupId, artifactId, and version are for log4j. We can browse ibiblio and look for it, or use Google to help by searching for “site:www.ibiblio.org maven2 log4j”.

http://mirrors.ibiblio.org/maven2/log4j/log4j/

The search shows a directory called /maven2/log4j/log4j (or /pub/packages/maven2/log4j/log4j). In that directory is a file called maven-metadata.xml. Here’s what the maven-metadata.xml for log4j looks like:

    1. <metadata>

 

  • <groupId>log4j</groupId>
  • <artifactId>log4j</artifactId>
  • <version>1.1.3</version>
  • <versioning>
  • <versions>
  • <version>1.1.3</version>
  • <version>1.2.4</version>
  • <version>1.2.5</version>
  • <version>1.2.6</version>
  • <version>1.2.7</version>
  • <version>1.2.8</version>
  • <version>1.2.11</version>
  • <version>1.2.9</version>
  • <version>1.2.12</version>
  • </versions>
  • </versioning>
  • </metadata>

Tips for load test by using Visual Studio 2012 Ultimate

Tips for load test by using Visual Studio 2012 Ultimate

 

Have some time to use the visual studio 2012 ultimate edition for load test recently.  So there is some basic tips about this.

1.      Only the ultimate edition VS 2012 has the web performance and load test ability.
Trial version VS 2012 only support Max 25 user load.
You must install all the VS update for the load test. As first version VS 2012 has many bugs in testing. Current latest UP is 3.

2.      You can follow the walk through of the Microsoft to step by step create the web test and load test.  This is fast and best way to start learn recording and concepts.

http://msdn.microsoft.com/en-us/library/vstudio/ms182551.aspx

http://msdn.microsoft.com/en-us/library/vstudio/ms182552.aspx

http://msdn.microsoft.com/en-us/library/vstudio/ms182594.aspx

And I have some tips can make you understand advanced load test skills quickly:

 

How to deploy test used resources files for the file test?

Such as you want test upload file feature , so you need source file to use,  when the web test is recorded, web test will not use the source folder of yours anymore. So you have to put the source file into the deploy folder of your test project. What you need to do is to add the folder or files into your project, by add files from “local.testsettings”—deploy, you can realize this.

http://msdn.microsoft.com/en-us/library/vstudio/ms182475.aspx

 

How to make the web site host URL as the parameter input for web test?

There is feature called “Parameterize Web Servers” feature in the web test, can auto extract the site host name and port number from the requests. This can save the time if you want switch your test from a UAT server to a production server.   What you to do is just modify the “WebServer1” and other  parameters to change the host name.

How switch test from a http site to a https site?

If your target has enable the https, but all site content are same. What you need to do is change the “Parameterize Web Servers” data to make it as https, you do not need to re-record all your request.

What you need to do from a web test to a load test?

1.      Your web test may run fine if you just run once every time, but start to run it as the load test may get issues as concurrent user will cause the conflicts if user conflict at the features, such as check in and check out same file, rename/delete same file etc.

2.      A load test recorded by default will create random unique resource names, such as you upload a file, load test will create unique file name for you at the upload request. Open your request and check the  file name , under the properties, there is some thing called “Generate Unique Name” to control whether or not create unique name for each request.

3.      After you have the web test, and you prepare the data source csv file already, then add/create DS into your test project, you can use the DS data in your load test to let test use the file name from the DS. By this format{{}}, what you need to do is to go through each request data to check if any thing can be changed/inserted by the DS data, by this way you can create a mean full load test. Such as each user load create separate file/ rename/delete/check in /check out separate file. File named is dynamic defined from DS csv file: this will avoid load test failed by conflicts.

4.      In load test, there is some thing important, one is the “load pattern”, you need to understand “constant load ” and “step load” pattern, it will be very useful. And under the “Running Setting” , the “Run Duration” and “Test Iteration” is very important.  Iteration here mean run once the web test, when a load test start to run, each user load will run the iteration again and again, unless  the Max Test iteration reached or time duration is reached. This is basic idea of the load test works.

 

Data drive test by data source – how to create a csv file and use it as data source for your test request?

You can create a Data source into your test project by a CSV file:

username, password
user1, password1
user2, password2
user3, password3
user4, password4
user5, password5

then you can use the data by binding call, {{ UserDS.UserNameFile#csv.username}} in the request data input. Check each request data and web server XML input to make sure the data is changed upon your needs.

http://msdn.microsoft.com/en-us/library/ms404707.aspx

http://msdn.microsoft.com/en-us/library/bb385971.aspx

Data source access methods explaination

http://blogs.msdn.com/b/slumley/archive/2008/03/14/description-of-access-methods-in-data-sources.aspx

How to create different user account from a data source (csv file) to log in to the page?

You can create a csv file with user name and password inside, and use it in the web test as the Data source, to load test will auto log in with these users during the test, please note this does not means the “user load” in the test. Even you only has one user account , user load still can simulate hundreds concurrent user load for you in test.

http://social.msdn.microsoft.com/Forums/en-US/80c15dfd-5265-4e9f-becc-5e13fdf19596/how-do-i-configure-multiple-users-in-a-load-test

How to create a plugin to do each user use each row from DS?

http://social.msdn.microsoft.com/Forums/fr-FR/5853028c-d297-45fb-ba46-ae346fa1e21c/load-test-datasource-distribution

how to create a plug in

http://msdn.microsoft.com/en-us/library/ms243191%28v=vs.100%29.aspx

Difference between the concurrent users load and VS multiple account?

http://social.msdn.microsoft.com/Forums/en-US/5829e774-f552-42e9-b43d-46daaaa4e6a0/load-testing-for-concurrent-users

how to debug a web test

http://blogs.msdn.com/b/slumley/archive/2007/04/10/how-to-debug-a-web-test.aspx

 

How to install test controller and agent

If one test client is not enough, you can install the controller and agent to make several client PC to make the test.

http://msdn.microsoft.com/en-us/library/vstudio/hh546459.aspx

http://msdn.microsoft.com/library/hh546460%28v=vs.110%29.aspx

 

 

shortbut key for Jdev IDE

  1. Go to file in navigator : Alt+Home
  2. Find Usages Ctrl+Alt+U
  3. Go To Java Type Ctrl+Minus
  4. Go To File Ctrl+Alt+Minus
  5. Show Overview Ctrl+Shift+ Back Quote
  6. Extract Method Ctrl+Alt+X
  7. Introduce Variable Ctrl+Alt+V
  8. Run Project F11
  9. Debug Project Shift+F9
  10. Quick JavaDoc Ctrl+D
  11. Reformat Ctrl+Alt+L
  • Search
  • Code Highlight Ctrl+Alt+H
  • Clear Code Highlight Ctrl+Alt+K
  • Auto Code Highlight (this makes the code always highlighted)
  • View
  • Structure Ctrl+Shift+S
  • Property Inspector Ctrl+Shift+I
  • Component Palette Ctrl+Shift+R
  • Break Point Ctrl+Shift+R
  • Miscellaneous
  • Copy Path Ctrl+Shift+C
  • Go To Line Ctrl+G
  • Go To Window Ctrl+F6
  • Go To File Ctrl+Alt+Minus
  • Build
  • Make Project Ctrl+F9
  • Rebuild Project Alt+F9
  • Run
  • Resume F9
  • Step Over F8
  • Step Into F7
  • Step Out Shift+F7
  • Java Editing
  • Organize Imports Ctrl+Alt+O
  • Select in Navigator Alt+Home

QuickTest Professional

By W.ZH

i am just doc this tool here as it might be used any project for UI testing. Beside the Selenium, this is a web UI automation testing tools developed by HP but widely used in the Oracle ADF project testing.

Because it can support the add-in extension, it supplies a lot ability to test the advance web UI by JAVA and .NET. And test script can make you do the function and regression test.

http://en.wikipedia.org/wiki/HP_QuickTest_Professional#Extensibility

 

 

 

SmartCVS

By W.ZH, Aug 2011

http://www.syntevo.com/smartcvs/index.html

SmartCVS is the best CVS Client I have ever used, Comparing with others like WinCVS, TortoiseCVS, I have used for long time, SmartCVS has a lot improves:

1. It can crosss the OS, I am using linux version and it is quick fast, and easy to use .

2. It can list all the folder/projects in your CVS root, so you know what folders in remote site easily.

3. It can sort to show what the new file, what is the non-CVS files, so you can easily check what should be check in or commit , far better than wincvs.

4. It automatically creates folders for you for new added files, you do not need to manully add your new folders like in wincvs.

5. It automatically chooses txt or bin for your file, more intellegient.

java.lang.NoClassDefFoundError: org/apache/cactus/ServletTestCase

By W.ZH Dec 28 2010

 

Issue:

When I try to run my test case through servlet of ServletTestRunner from the cactus’s war file. i face this exception:

java.lang.NoClassDefFoundError: org/apache/cactus/ServletTestCase

Reason:

In fact it is very hard to find the reason fro this kind of things. We should explain how this cactus runs by class loader, then you can know what may cause this:

WEB-INF/classes CL --> WEB-INF/lib CL --> system CL

You see, the cactus WEB-INF/classes in fact should contain your test cases classes, those u write to inherit the ServletTestCase.

and all cactus related jar should be put into the WEB-INF/lib.

to make your test cases can run,you normally also has alot other jars put into the ear file top layer, bu they are outside the WEB-INF.

So there are three place u need to check:

1. WEB-INF/classes has all the test cases class.

2. WEB-INF/lib has all the test case support jar lib files.

3. Your top layer(outside the WEB-INF), do not has any test cases class. You may need to unzip all your jars to look for them.

What error I made is N0. 3!

like this :

http://mail-archives.apache.org/mod_mbox/jakarta-cactus-user/200304.mbox/%3C3EA79AD8.2080308@gmx.de%3E

Solution:

After u find the reason, I think you know how to fix this error!

Ref:

http://mail-archives.apache.org/mod_mbox/jakarta-cactus-dev/200202.mbox/%3C002901c1bb48$0332b9e0$3b22e40c@spiritedsw.com%3E