Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

run jira with testkit backdoor enabled

Tomasz Stec
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 1, 2016

Hi, i am trying to figure out how to start JIRA (by atlas-run) so that it will have testkit rest modules enabled. I want JIRA to be exactly as it is during atlas-integration-test, so i can run my tests from IDE using JUnit/JWebUnit as it's shown in this tutorial: https://developer.atlassian.com/jiradev/jira-platform/guides/other/tutorial-writing-integration-tests-for-your-jira-plugin#Tutorial-WritingintegrationtestsforyourJIRAplugin-integration-tests

Edited:

Maybe my first question wasn't accurate enough... i have the pom configuration as Petar Petrov showed below and when i start JIRA the Testkit Plugin is installed and enabled. The problem is that i want to run my tests (using FuncTestCase) from Eclipse. I have tried to run this simple test:

public class SlaInformationPanelTest extends FuncTestCase {
        @Before
        public void setUpTest() {
        }
        @Test
        public void testCreateSLAPriorityCustomFieldFuncTest() {
            Backdoor backdoor = new Backdoor(new TestKitLocalEnvironmentData());
            backdoor.project().addProject("TEST", "TEST", "tstec");
		}
}

and it failed.

I debug it and figure out that backdoor object wants to invoke request to:
http://localhost:5437/jira/rest/testkit-test/1.0?os_authType=basic&os_username=admin&os_password=admin

and there is no such rest resource so it throws an exception:
com.sun.jersey.api.client.UniformInterfaceException: Client response status: 401

 

I thought this rest resource is exposed by TestKit Plugin but apparently it is not.

So to be accurate: How do i need to configure my pom to start JIRA and respond to my tests run from Eclipse ?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Petar Petrov (Appfire)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 1, 2016

401 means that the server has not authenticated you, not that the resource is not present - check if the user and password are correct. You can go to the Manage Add-ons page and check if the testkit plugin with all its modules is enabled.

Tomasz Stec
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 1, 2016

Thanks Petar! that was the problem... i started JIRA with external data source so i had to setup JIRA data on my own from scratch (using wizard) and i created main admin account as "tstec". I didn't know TestKit plugin wants account "admin" to authenticate. Not it works as a charm smile

Tomasz Stec
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2016

hi, i have another problem, i cannot launch remotely tests that inlude JIRA instance data restoration. Any of this works...

administration.restoreBlankInstance();
//neither
administration.restoreData("data.zip");
//nor
administration.restoreBlankInstanceWithLicense(LicenseKeys.V2_DEVELOPER_LIMITED);

how can i perform JIRA data restoration by remote run ? (JIRA instance on server and my test code localy run from Eclipse)

 

Petar Petrov (Appfire)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2016

We use:

backdoor.restoreBlankInstance(TimeBombLicence.LICENCE_FOR_TESTING);

Where backdoor is an instance of com.atlassian.jira.testkit.client.Backdoor.

Tomasz Stec
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 4, 2016

unfortunatelly it does not work too... here's a stacktrace:

java.lang.RuntimeException: Unable to setup the TestCase itself
    at com.atlassian.jira.functest.framework.FuncTestCase.setUp(FuncTestCase.java:214)
    at junit.framework.TestCase.runBare(TestCase.java:132)
    at com.atlassian.jira.functest.framework.FuncTestCase.runBare(FuncTestCase.java:362)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:232)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:91)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: com.sun.jersey.api.client.UniformInterfaceException: Client response status: 500
    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:676)
    at com.sun.jersey.api.client.WebResource.post(WebResource.java:251)
    at com.atlassian.jira.testkit.client.DataImportControl.restoreDataFromResource(DataImportControl.java:266)
    at com.atlassian.jira.testkit.client.DataImportControl.restoreBlankInstance(DataImportControl.java:152)
    at com.atlassian.jira.testkit.client.Backdoor.restoreBlankInstance(Backdoor.java:300)
    at it.com.comarch.jira.sla.view.SlaInformationPanelTest.setUpTest(SlaInformationPanelTest.java:18)
    at com.atlassian.jira.functest.framework.FuncTestCase.setUp(FuncTestCase.java:209)
    ... 15 more

and the test i wanted to run:

@Before
    public void setUpTest() {
        TestKitLocalEnvironmentData tkled = new TestKitLocalEnvironmentData();
        Backdoor backdoor = new Backdoor(tkled);
        backdoor.restoreBlankInstance(TimeBombLicence.LICENCE_FOR_TESTING);
        if (!administration.usersAndGroups().userExists("tstec")) {
            administration.usersAndGroups().addUser("tstec", "tstec", "Tomasz Stec", "tomasz.stec@comarch.pl", false);
            administration.usersAndGroups().addUserToGroup("tstec", "jira-developers");
            administration.usersAndGroups().addUserToGroup("tstec", "jira-administrators");
        }

    }

    
    public void testLogin() {
        navigation.logout();
        navigation.login("tstec", "tstec");
        navigation.logout();
    }
Petar Petrov (Appfire)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 5, 2016

Check for error in the JIRA log, or the console output if your run with atlas-run - something is failing on the server.

0 votes
Petar Petrov (Appfire)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 1, 2016

You need to add the following section in you pom.xml in the plugins section:

<plugin>
				<groupId>com.atlassian.maven.plugins</groupId>
				<artifactId>maven-jira-plugin</artifactId>
				<version>${amps.version}</version>
				<extensions>true</extensions>
				<configuration>
					<compressResources>false</compressResources>
					<extractDependencies>false</extractDependencies>
					<productVersion>${jira.version}</productVersion>
					<productDataVersion>${jira.version}</productDataVersion>
					<enableFastdev>false</enableFastdev>
					<allowGoogleTracking>false</allowGoogleTracking>
					<pluginArtifacts>
						<pluginArtifact>
							<groupId>com.atlassian.jira.tests</groupId>
							<artifactId>jira-testkit-plugin</artifactId>
							<version>${testkit.version}</version>
						</pluginArtifact>
					</pluginArtifacts>
				</configuration>
			</plugin>

The pluginArtifacts bit instructs maven to start JIRA with the JIRA testkit plugin. If you already have the maven-jira-plugin configuration in you pom just add the pluginArtifacts bit.

The property testkit.version holds the version of the testkit plugin - use the appropriate version which is compatible with your jira.version. Pay attention to the property names - may be different in your pom.

Tomasz Stec
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 1, 2016

Thanks, for your answe, but unfortunetelly my question wasn't clear enough, so i edited it. Do you have experience with such case?

TAGS
AUG Leaders

Atlassian Community Events