Skip to content

How to set up development environment for zm mailbox repository

Greg Solovyev edited this page Aug 3, 2017 · 8 revisions

Table of Contents

Deploying and testing Java code changes

Initial set up

  1. Install latest version of ZCS - at the moment this would be 8.8.1 release
  2. Create /home/zimbra and make zimbra user the owner
  3. Install git, ant, ant-contrib
  4. Edit /opt/zimbra/.bash_profile
    • comment out export LANG=C and export LC_ALL=C
    • add export LANG=en_US.UTF-8
    • add export ANT_OPTS="-Ddev.home=/home/zimbra -Dzimbra.buildinfo.version=8.7.6_GA"
    • load environment changes source /opt/zimbra/.bash_profile
  5. Change permissions on files and folders that you will be updating. E.g. as root:
    chmod -R o+w /opt/zimbra/lib/ /opt/zimbra/jetty/
    (Note: if you run zmfixperms, these permission changes will get overwritten)
  6. Create folders for dependencies
            mkdir /home/zimbra/.zcs-deps/
            mkdir -p /home/zimbra/.ivy2/cache
    

Building and deploying Java code

  • Clone zm-mailbox repository:
            mkdir /home/zimbra/git        
            cd /home/zimbra/git
            git clone https://github.com/Zimbra/zimbra-package-stub.git
    
  • Build and run unit tests (this may take 3-5 minutes):
            cd zm-mailbox
            ant test-all
    
  • Build without running unit tests (this will just create jar files for zm-common, zm-store, zm-native, zm-soap and zm-client libraries):
            ant all
    
  • Build and publish jar files to local Ivy repository (this will build jar files and make changes in zm-common, zm-store, zm-native, zm-soap and zm-client libraries visible to other repositories):
            ant publish-local-all
    
  • Deploy changes in zm-common, zm-store, zm-native, zm-soap and zm-client libraries:
            ant -f store/build.xml deploy-foss
    
  • You can also deploy changes in just one of the libraries by running deploy ANT target from the library's build.xml. E.g. to deploy only zm-common:
            ant -f common/build.xml deploy
    
    Note: deploy and deploy-all targets restart mailboxd

Getting email delivery to work on a VM without a DNS server

If you are using a local VM such as VMWare Fusion or VirtualBox, you may need to make some additional configuration changes to get MTA to work on your network.

  • set up a DNS server on your host machine or another VM and configure zimbraDNSMasterIP to point to it. To do so, run zmprov ms command as zimbra user. E.g.:
    zmprov ms ubuntu2.local zimbraDNSMasterIP 172.16.150.1
  • If you do not have a DNS server set up on your network, you need to disable Zimbra DNS lookups zmprov mcf zimbraMtaSmtpDnsSupportLevel disabled
  • If you see this error "No SMTP hosts available for domain" when trying to send an email, you need to manually configure zimbraSmtpHostname for your domain(s). To do so, run zmprov md command as zimbra user. E.g.:
    zmprov md ubuntu2.local zimbraSmtpHostname ubuntu2.local
  • If you see errors like this in /var/log/zimbra.log postfix/lmtp ... deferred ... connection refused This is nearly always caused by a host that is configured on private IP Space (or using NAT) and that does not have an interface for the public IP address the server resides on. This can be easily fixed by simply using native IP address lookups for lmtp rather than DNS.
    zmprov mcf zimbraMtaLmtpHostLookup native
    zmmtactl restart
    

Running SOAP tests

SOAP tests are not unit tests. These tests interact with Zimbra services such as LDAP, mailboxd, zmproxy, IMAPd, MariaDB, etc. These tests create and delete domains, accounts, inject data, send messages, update configuration, etc. Some tests require that email delivery works on your server. See previous section on how to get email delivery to work in a development environment. Note: Do not run SOAP tests on a production server :)

  1. First, you need to copy JUnit jar to /opt/zimbra/jetty/webapps/service/WEB-INF/lib and restart the mailbox:
            cp /home/zimbra/.ivy2/cache/junit/junit/jars/junit-4.8.2.jar /opt/zimbra/jetty/webapps/service/WEB-INF/lib/
            zmmailboxdctl restart
    
  2. To run a single test suite (TestZClient in this example):
            zmsoap -z RunUnitTestsRequest test=TestZClient
    
  3. To run a single test from a test suite (TestZClient::testFeatures in this example):
            zmsoap -z RunUnitTestsRequest test=TestZClient#testFeatures
    
  4. To run all tests under com.zimbra.qa.unittest (Note: this may take a while):
            zmsoap -z RunUnitTestsRequest