SDN 4.1 - Multithreading Neo4j TestServer for parallel execution of test cases - neo4j

I'm using org.neo4j.ogm.testutil.TestServer and the http driver for integration testing instead of the Embedded driver because I like how the TestServer provides a browser based interface to see what is happening with each test.
However - my tests take ages! The build is getting up to around 30 minutes on a reasonably quick machine.
What I'd like to do is use the maven surefire plugin to execute my test cases in parallel.
To do this I imagine I'll need to be able to startup several neo4j TestServer instances, each on a different port.
Where is the best place to do this using neo4j 4.1? I assume #Before and #After (for shutdown) methods of my test cases? (possibly extracted into a super class?)
Also, how would I get the current port for the current test context into each unit test?
Any suggestions of how to go about this would be greatly appreciated :)

Have a look at org.neo4j.ogm.testutil.MultiDriverTestClass which sets up the Driver using the TestServer.
The TestServer should pick an available port anyway which should solve your problem of setting these up in parallel. In fact, you can just have your test class extend org.neo4j.ogm.testutil.MultiDriverTestClass (most of the tests in org.neo4j.ogm.persistence.examples do this) and provide an ogm.properties file that specifies that the driver to be used is the HTTP Driver
driver=org.neo4j.ogm.drivers.http.driver.HttpDriver

Related

Progress ABL How to Test for WEBSPEED in the PRE-PROCESSOR

I want to conditionally compile some blocks of code depending on type of client i'm running in. this is fine for batch and tty as i can use the {&BATCH-MODE} but how to test for when the code is being compiled in webspeed agent? eg. {&IF} not {&SOMETHING} EQ "YES" {&THEN}
{&ANALYSE-SUSPEND}
foo
bar
{&ANALYSE-RESUME}
{&ENDIF}
it would be helpful if this did not rely on defines auto generated by the architect in .w's etc but that would be a nice to have not essential.
Compile time isn't run time. If the program can be run different ways (as a part of a of webpage using webspeed, as a part of a batch and as a part of some other kind of client etc) you're most likely better of evaluating this in run time instead.
You can identify in what environment you're running:
SESSION:CLIENT-TYPE
This will identify your type of client.
DISPLAY SESSION:CLIENT-TYPE.
Type of client Attribute value
-------------------------------- -----------------------
ProVision standard ABL client 4GLCLIENT
WebClient WEBCLIENT
AppServer agent APPSERVER
WebSpeed agent WEBSPEED
Pacific Application Server agent MULTI-SESSION-AGENT
Other special-purpose clients Unknown value (?)
Documentation
Using VST
If you have at least one database connected
_Connect-ClientType tells you what kind of client this particular connection is:
Value Client
-------- ---------------------
ABL ABL client
SQLC SQL client
WTA Webspeed agent
APSV AppServer agent
SQFC SQL Federated client
Example:
FIND FIRST _myconnection NO-LOCK.
FIND FIRST _connect NO-LOCK WHERE _connect._connect-usr = _myconnection._MyConn-userid.
DISPLAY _connect._Connect-ClientType.
Based on OS
Perhaps you run different OS:es?
DISPLAY OPSYS.
Other ways
There's a number of other ways of doing this, including perhaps looking at PROPATH, Working directory etc.
Try to stick with a solution that won't change over the course of time because of Progress upgrades, new OS:es, new directory structures etc.
IMHO there is no such preprocessor variable out of the box.
But you could create your own include file and include that in the code that's relevant. You need two versions of that file, one says
&GLOBAL-DEFINE WebSpeed WebSpeed
and the other
&GLOBAL-DEFINE NoWebSpeed NoWebSpeed
And then configure your compile sessions so that they find exactly one of the files in propath.
But as you will agree, this is probably dangerous as the result will heavily rely on the proper PROPATH used during compilation. I'd rather attempt to use a runtime condition instead.
What are you trying to achieve in detail?
finally figured it out this morning {&webstream} and {&out} are not defined in in normal sessions so i can just test for that. runtime is not an issue in my case i just want to compile the code in all cases. in this shop dont ask me why but every single piece of code is session compiled. poor cpu but there u go. i could be defensive and add some logic with session:Client-type for bells and whistles you're right. if not can-do then boogie :)

Sling Testing Tools Selector configuration

AEM 5.6.1
I am trying to run some server side testing using the sling testing tools. I have deployed the junit.core bundle and I can navigate to the JUnitServlet at /system/sling/junit/
When I hit this url there are tests visible from multiple bundles, I don't want to run the adobe ones but I can't figure out how to filter package names past the period using the url.
e.g
Available tests:
com.adobe.stuff
com.my.stuff
I tried:
/system/sling/junit/com/ <--works but isn't detailed enough
/system/sling/junit/com.my <-- breaks unsurprisingly
/system/sling/junit/com%2Emy <-- also breaks with 501
Is there an expected way of doing this? I couldn't find any documentation about this and the javadoc didn't really help either.
/system/sling/junit/com.my.html should work - you are right that the /system/sling/junit servlet should make this more explicit. There are examples of running such tests from proxy JUnit tests in the Sling codebase, see SlingServerSideTest for example.

Running Geb + spock tests headless

I have a number of geb functional tests for a grails application.
The tests are working as expected when executed from terminal or IDE.
Although the tests need to be executed by hudson, so they are run in headless mode using Xvfb.
The problem is that the tests keep failing, or behaving unexpectedly, returning errors like RequiredPageContentNotPresent and Stale Element Reference Exception in places that doesn't make sense.
For example:
(at LicencePage is verified above, and page isn't changed)
when:
addDocument(Data.Test_Doc_name,Data.Test_Doc_file)
sometimes throws
Failure: Add Actual Licence (HomePageSpec)
| geb.error.RequiredPageContentNotPresent: The required page content 'addDocument - SimplePageContent (owner: LicencePage, args: [Functional Test Doc, /var/lib/hudson/jobs/KB-Functional_Tests/workspace/app/../manual_test_data/so_v3/os_test_1], value: null)' is not present
at geb.content.TemplateDerivedPageContent.require(TemplateDerivedPageContent.groovy:61)
at geb.content.PageContentTemplate.create_closure1(PageContentTemplate.groovy:63)
at geb.content.PageContentTemplate.create(PageContentTemplate.groovy:82)
at geb.content.PageContentTemplate.get(PageContentTemplate.groovy:54)
at geb.content.NavigableSupport.getContent(NavigableSupport.groovy:45)
at geb.content.NavigableSupport.methodMissing(NavigableSupport.groovy:121)
at geb.Browser.methodMissing(Browser.groovy:194)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
at HomePageSpec.Add Actual Licence (HomePageSpec.groovy:228)
The method addDocument() is defined on an 'abstract' page, which LicencePage is extending. In most cases like this, if I copy the method code directly into my Spec, it is going to work, although its ruining all the structure I have on my test pages.
Anyone has experience running geb tests with Xvfb? Have you faced these issues?
All tests are passing when executed locally, and this not a data issue as the DB is always cleared
Also, without making any changes, the tests are behaving non-deterministic (on hudson) so the above exception is not always thrown. Without any changes at all, tests are sometimes successful and sometimes fail.
The description you gave seems to be the symptom of a flackey test-suite. we were facing this problem as well some time ago. A good starting point for this is this presentation (around min. 35) and the documentation about the wait stuff in geb.
If you think, it could have something to do with xvfb (where i have no experiences with), you could try to use phantomjs as the test-runner and check if it works correctly.

Running grails test-app command from grails web console plugin

I have installed the grails web plugin. I can now browse to :
localhost:8080/myappname/console
And I can see the console displayed over there. I have bunch of test-cases written for application. I wish I can test my app from this web console.
Is it possible to do so? I'm very new to grails.
Thanks in advance.
Short answer no. The grails console is meant to write groovy code that interacts with your running application. Your running application does not include your test cases or the grails command line by default.
Long answer sort of. Provided you have all of your projects source code available somewhere in the file system where your application is running, you could call an external process to run test-app and return the result to the user. Here are some docs on running external processes in groovy: http://groovy.codehaus.org/Executing+External+Processes+From+Groovy. I suppose you could also package you application somehow to make this work, but I think doing that would be fairly complex.
I am not sure this is a good use case for the console plugin over all. Hope this helps

How to create unit tests for EJB 3.0 based code to be deployed in jboss 5.1?

Greetings,
I am interested in adding test coverage for an existing application. The technologies involved include EJB 3.0, jboss 5.1, Hibernate and MySQL. This project is built using Ant. The goal is to provide test coverage to this application to allow further features to be added with confidence.
Initial searches give several ideas, but I have yet to find an tutorial or a start to finish set up steps to create an initial unit test.
I found EJB3Unit to be promising.
http://ejb3unit.sourceforge.net/Installation.html
However, the examples to setup are for maven and we are using Ant.
If anyone could help with how to setup a simple example test with EJB3Unit and Ant it would be very helpful.
Thanks for your time,
Conor
You will have to ask yourself "What exactly am I trying to test?" first.
If you want to test your EJB3 in isolation, remember that an EJB3 is just a POJO. You can call the class directly from a jUnit test method.
If you want to test your EJB, the Application server, the Container, AND your network (if #Remote annotation is used) then you can write an integration test class that looks up the #Remote or #Local EJB in the JNDI tree of your container like so:
#Test
public void callEjb() throws Exception {
Context context = new InitialContext();
YOUR_EJB_CLASS myEjb = (YOUR_EJB_CLASS) context
.lookup(JNDI_PATH_FOR_YOUR_EJB);
myEjb.myMethod();
}
If you want to test your EJB as an EJB and separate from an EJB Container, then EJB3 could be what you are looking for instead.
P.S. Don't let Maven scare you. I haven't used it yet, but it seems that it is gaining in mind-share over ant.

Resources