Running maven integration test inside docker container

I am using the dockerfile-maven plugin to move my jar file inside the docker container before running integration testing. But the mvn verification team builds the images and runs the integration test, as a result of which the test fails. Can someone help me launch docker images before running the integration test. So that I can ping to serve the work inside the docker container from my test integration file.

Below is my test integration file.

import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import java.sql.SQLException; import java.sql.ResultSet; import java.io.IOException; import java.io.File; import java.util.Scanner; import static org.hamcrest.MatcherAssert.*; import static org.junit.matchers.JUnitMatchers.*; import org.junit.Assert.*; import com.facebook.presto.jdbc.PrestoDriver; import io.airlift.log.Logger; import org.testng.annotations.Test; class IntegrationTestIT { @Test public void checkForQueryInFile() { System.out.println("This test method should be run"); String url = "jdbc:presto://localhost:8889/jmx/default"; Statement stmt = null; try { Connection connection = DriverManager.getConnection(url, "jumbo", null); stmt = connection.createStatement(); String file_path = ""; String sql_string = "show schemas"; ResultSet rs = stmt.executeQuery(sql_string); File folder = new File("//jars"); // Move this to constant class File[] files = folder.listFiles(); for (File file:files) { if (file.isFile()) { file_path = file.getAbsolutePath(); } } File log_file = new File(file_path); final String scanner = new Scanner(log_file).useDelimiter("\\Z").next();; assertThat(scanner, containsString(sql_string)); rs.close(); stmt.close(); connection.close(); } catch (IOException exception) { exception.printStackTrace(); } catch(SQLException sqlException) { sqlException.printStackTrace(); } } } 

Test report:

 [INFO] Successfully built rohitbarnwal7/presto_log_updated:0.0.1 [INFO] maven-failsafe-plugin:2.5:integration-test (default) @plugin [INFO] Failsafe report directory: /Users/rohit/workspace/presto plugins/target/failsafe-reports ------------------------------------------------------- TESTS ------------------------------------------------------- Running TestSuite Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.833 sec <<< FAILURE! Results : Failed tests: checkForQueryInFile(IntegrationTestIT) Tests run: 1, Failures: 1, Errors: 0, Skipped: 0 

The result of the integration test from TestSuite.txt

 Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.559 sec <<< FAILURE! checkForQueryInFile(IntegrationTestIT) Time elapsed: 0.015 sec <<< FAILURE! java.lang.IllegalAccessException: Class org.testng.internal.MethodInvocationHelper can not access a member of class IntegrationTestIT with modifiers "public" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102) at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296) at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288) at java.lang.reflect.Method.invoke(Method.java:491) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85) at org.testng.internal.Invoker.invokeMethod(Invoker.java:639) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108) at org.testng.TestRunner.privateRun(TestRunner.java:774) at org.testng.TestRunner.run(TestRunner.java:624) at org.testng.SuiteRunner.runTest(SuiteRunner.java:359) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312) at org.testng.SuiteRunner.run(SuiteRunner.java:261) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1191) at org.testng.TestNG.runSuitesLocally(TestNG.java:1116) at org.testng.TestNG.run(TestNG.java:1024) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141) at org.apache.maven.surefire.Surefire.run(Surefire.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021) 
0
source share
1 answer

Availability error message:

java.lang.IllegalAccessException: class org.testng.internal.MethodInvocationHelper cannot access a member of the IntegrationTestIT class with "public" modifiers

You must make your class open to run tests:

 public class IntegrationTestIT { ... 

Sequencing Problem:

If your integration tests work in the integration-test phase, you can force the docker plugin to be executed during the pre-integration-test phase:

 <execution> ... <phase>pre-integration-test</phase> </execution> 
0
source

All Articles