cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

acceptance: need to refactor the Java acceptance tests

Open knz opened this issue 10 years ago • 9 comments

Suggestions collected over #4578:

  • Java code should be in separate .java files (eases editing)
  • there should be no preprocessing (different files are best)
  • the different Java tests should be executed one after another by test logic written in Java
  • the filesystem in the test docker instance should not be polluted by generated files

knz avatar Feb 23 '16 12:02 knz

@knz, you mean we should write separate .java files instead of java_test.go

a6802739 avatar Jul 18 '16 12:07 a6802739

@a6802739 yes that is correct.

knz avatar Jul 18 '16 15:07 knz

@knz , thanks, another question, where is the code to control all the execute logic in acceptance. is it run.sh?

a6802739 avatar Jul 19 '16 03:07 a6802739

Yes, acceptance/run.sh calls go test which in turn runs all the Go tests defined in the directory.

You can also run make acceptance from the top-level directory, which will do the same thing.

knz avatar Jul 19 '16 12:07 knz

@knz , if I change java_test.go to separate .java files. I should also change run.sh and makefile, right?

a6802739 avatar Jul 20 '16 02:07 a6802739

Yes you can approach it this way.

Meanwhile to align with our other tests I could also suggest 1 Go acceptance test function which:

  1. starts the test DB server
  2. invokes the Java compiler to compile the Javatest code (and checks there are no compile errors)
  3. with a loop runs each test Java program, giving it the DB connection string as argument each time
  4. when all Java tests have run, stops the test DB server

Of course if you have a better idea please go forward with it.

knz avatar Jul 20 '16 13:07 knz

@knz, thanks for you advice.

a6802739 avatar Jul 21 '16 06:07 a6802739

@knz, I would like work on this issue. I have on question though. How are we supposed to copy the .java files from our host to the docker container after it is started? Presently, we are creating these .java files on the container by executing a bash script on the container itself. Right?

rohangulati avatar Nov 07 '16 21:11 rohangulati

Hi @rohangulati! Thanks for offering to help!

When a docker test starts the full CockroachDB source directory is "mounted" inside the docker image in location /go/src/github.com/cockroachdb/cockroach. If you place the .java files somewhere in acceptance/ (e.g. acceptance/java/) you can then access them inside the docker image from /go/src/github.com/cockroachdb/cockroach/acceptance/java. Let me know if you have more questions.

knz avatar Nov 07 '16 22:11 knz