Opened 3 years ago

Closed 20 months ago

#665 closed defect (fixed)

Fix existing Petascope JUnit tests

Reported by: pcampalani Owned by: bphamhuu
Priority: minor Milestone: 9.2
Component: petascope Version: development
Keywords: junit tests Cc: dmisev
Complexity: Medium

Description

Among the few JUnit tests currently available for Petascope, some of them is not working (anymore): the code needs to be updated.

Change History (7)

comment:1 Changed 3 years ago by pcampalani

  • Status changed from new to accepted

comment:2 Changed 3 years ago by pcampalani

Concurrence test code fixed in changeset:62c05ff.
Variable @confdir@ is however not replaced by the configured path in Petascope so it needs a manual intervent by the tester.
When the folder is properly configured to point to petascope.properties, the tests here anyway fail with already 2 parallel requests ('cannot get free rasdaman server').

comment:3 Changed 3 years ago by dmisev

It might be interesting to look at http://jwebunit.sourceforge.net/

comment:4 Changed 3 years ago by pcampalani

  • Owner changed from pcampalani to uadhikari
  • Priority changed from major to minor
  • Status changed from accepted to assigned

comment:5 Changed 22 months ago by dmisev

  • Milestone changed from 9.0.x to 9.1.x
  • Owner changed from uadhikari to bphamhuu

comment:6 Changed 21 months ago by bphamhuu

  • Cc dmisev added
  • Milestone changed from 9.1.x to 9.2

The problem with confDir in concurrentRasdamanRequests() is annoying but the only way to solve is when "make install" then make a copy of web.xml to "WEB-INT/classes/web.xml" and can parse the "confDir" param from non-servlet class (without context) by

 // InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("web.xml");
        
 // String confDir = StringUtilTest.getStringFromInputStream(inputStream);

However, as this is use only for tester then I've throws an exception that if tester not change the default configuration (@confDir@) it will not run the test.

The other problem is "threads are racing" with the old code (using a boolean variable and check thread.isDone() as a sign) to start to check the result from all threads.

However, this is not "safe" and the result is "Could not get free server" when run file TestSystemOverloaded?.java.

Solution is using thread join in a array of thread

  
        Thread threadList[] = new Thread[queries.length];

        for (int i = 0; i < queries.length; i++) {

            queries[i] = new RasdamanQuery();
            threadList[i] = new Thread();
            threadList[i].start();
        }

        // Wait all threads are finished
        for (int i = 0; i < queries.length; i++) {
            threadList[i].join();
        }

A small problem is "Test Packages" can not run first time, due to a configuration in NetBeans? Project, the default support from NetBeans? is "GlassFish? Server". So a manually fix way is right click "Test Packages" -> "Properties" -> Run (Server: GlassFish? Server). This will be added to patch also.

I will submit a patch soon (tomorrow)

comment:7 Changed 20 months ago by bphamhuu

  • Resolution set to fixed
  • Status changed from assigned to closed

close as patch has been accepted.

Note: See TracTickets for help on using tickets.