Failed Test when building OpenMRS 2.1.0

Hello, I’m trying to run the command mvn clean package as described on the README from the repo of https://github.com/openmrs/openmrs-core; I have Java and Maven installed as the pre-requisites, but I’m getting some tests failed.

These are some of the outpus I got:

  1. saveOrder_shouldThrowAmbiguousOrderExceptionIfDisconnectingMultipleActiveOrdersForTheGivenConcepts(org.openmrs.api.OrderServiceTest) Time elapsed: 0.055 sec <<< FAILURE! java.lang.AssertionError: Expected exception: org.openmrs.api.AmbiguousOrderException

  2. ERROR - ModuleFactory.getModuleFromFile(542) |2017-09-01 15:28:20,723| Error getting module object from file test2-1.0-SNAPSHOT.omod org.openmrs.module.ModuleException: Unable to get jar file Module: test2-1.0-SNAPSHOT.omod

  3. loadModules_shouldNotStartTheLoadedModules(org.openmrs.module.ModuleFactoryTest) Time elapsed: 0.03 sec <<< FAILURE! java.lang.AssertionError: expected:<3> but was:<0>

The Maven and Java info from mvn -v is: Maven home: /usr/local/Cellar/maven/3.5.0/libexec Java version: 1.8.0_131, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"

Can someone guide me if I’m doing something wrong or missing a step before?

cc. @sommardahl @ronald721hn

@eliyas

FYI there is no need for you to build openmrs-core 2.1.0 – all of our releases are published to artifactory (which you can reach at http://mavenrepo.openmrs.org). You can also download the WAR manually from sourceforge (get there via http://openmrs.org/download). We’d typically expect you to use a prebuilt released binary (unless you’re writing code in openmrs-core).

Looking at ci.openmrs.org, the latest build of the 2.1.x branch is building fine. However I just checked out the 2.1.0 tag and I also get the first error you run into:

OrderServiceTest.saveOrder_shouldThrowAmbiguousOrderExceptionIfDisconnectingMultipleActiveOrdersForTheGivenConcepts Expected exception: org.openmrs.api.AmbiguousOrderException

I don’t know why that is, and the release wouldn’t have worked if the tests weren’t passing at the time, so I would just ignore this and use one of the pre-built binaries.

1 Like

I ran onto the same issue on two different branches of Core before I realised that @dkayiwa backported down to 1.10.x a commit that solves this. On 2.1.x it would be this commit.

Hi @darius, thank you for responding.

We are not writing code right now, but we are trying to implement Bahmni in a public hospital in our country; in the future we will need to add some code in order to fit the needs and contribute with the project as well. So that’s why I would like to build the 2.1.0 which is the one used on Bahmni 0.89.

Hi @eliyas,

Do you know already for sure that the changes you might need to make will happen in OpenMRS Core? There are quite a few layers being used in Bahmni. The main ones (given in an approximate front-end to back-end order) would be:

If you know already that you will need to bring changes to the Core, you will anyway eventually need to provide a pull request on the master branch. So why not clone and build that one rather than the tag 2.1.0 (I’m assuming that you did checkout tag 2.1.0 and bumped onto the issue that Darius described.)

Hi @mksd, we are focusing on the module of MRS for Bahmni. And according to the 0.89 version of Bahmni, the 2.1.0 is the version used of OpenMRS, and also we are trying to set up the repos according to our process which implies a CI for automated builds and deployments.

I have a question right now, Is it possible to build the OpenMRS repo without setting up the Intellij IDE? I’m not sure but, some of my teammates have set up the Intellij before to build the openmrs-core in the 2.1.0 branch/version, and they don’t have my problem. Even I cleaned it up my laptop and reinstalled everything from zero but I get the same errors. So I’m thinking it could be a step that I’m missing from this guide https://wiki.openmrs.org/display/docs/Developer+How-To+Setup+And+Use+IntelliJ#DeveloperHow-ToSetupAndUseIntelliJ-InitialSetup

“OpenMRS Core 2.1.0” is already released, and it will never change, so you do not need to build it in CI. You only need to build the things you’re integrating together that are changing.

If you end up finding a bug in openmrs-core 2.1.0, that will require a maintenance release (e.g. 2.1.1) so in this case you’d want to be building the 2.1.x branch, not a specific release tag. Personally I would not add a build for openmrs-core to your CI pipeline unless/until you’re expecting to actually be changing the version included in your distribution.

PS- to answer your actual question, you can build openmrs-core by merely doing

mvn clean package

at the command line (assuming you have maven installed, of course). But I would expect this to fail on the 2.1.0 tag, and pass on the 2.1.x branch. (That’s what happened for me when I tried.)

I think Darius is right. Your CI should just be fetching artifacts, not necessarily building them. However you should be able to tell your CI to fetch artifacts that you have built when it comes to it.

Of course if you know already that you want to modify OpenMRS Core, you will need to automate building it somewhere in your CI pipeline (in order to fetch its artifacts that you have built). And that’s going to be with Maven, as Darius said:

mvn clean package