Retail:Developers Guide/How-to/How to Install, Setup and Run Retail Automated Tests
Introduction
The Retail Automated tests are are a set of JUnit test cases which use Selenium to execute actions on top of an Openbravo POS session to verify all areas of the application. These tests are executed as part of the Retail Continuous Integration as can be seen here.
Versions used in this guide: Java 11, Tomcat 8.5, PostgreSQL 10 and/or Oracle 11
Setup development environment Ubuntu
During this chapter, a detailed installation guide will be explained. If you are familiarized with software installation under Linux, you can jump directy here to have a more simplified view.
Since all the stack can run on Linux, Mac and Windows and there are several versions supported, there is not guarantee that all the following steps will work. Use it at your own risk.
![]() | Before start, check the the current recommended versions, since could happen that the versions on this guide are obsolete. |
Previous steps
Download and install Ubuntu 22.04 64-bit LTS Desktop.
You can obtain the ISO from here (64-bit PC (AMD64) desktop image).
In case there is Ubuntu 22.04.X (being X any minor revision number) instead of just 22.04, it is ok to download and install the most recent revision.
Note: in ubuntu 22.04 comes by default wayland instead xorg, and it gives problem sharing screen in many programs like skype, chrome, etc. Till is supported by these programs you can disable it in /etc/gdm/custom. conf , uncommeting the line that disables it. Or optionally left enabled and use skype insider and enable in chrome the pipewire option: chrome://flags/#enable-webrtc-pipewire-capturer
Optional: If you prefer the selected items in blue instead in orange you can change it on settings / appearance style blue. If you prefer a dock more line mac style in settings appearance uncheck "Panel mode" and select "Position on screen": bottom.
Add swap
Sometimes if many tomcats started, eclipses, chromes, developers tools, vscode, or running the npm tests usually we run out of memory and the system freezes and start killing processes. To avoid that it is possible to add a swap file to help on this cases, it will go slower but will not freeze and kill processes
# Add the swap sudo fallocate -l 16G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile # make the swap available on reboot ##### CAREFULL editing the fstab file, something wrong and the computer will not boot ### sudo cp /etc/fstab /etc/fstab.bak echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Zsh
This software is optional, but it is the recommended shell. If you do not install it, you can just ignore the ".zsh" sections in the following chapters.
- Install zsh, ohMyZsh and powerlevel10k
sudo apt install zsh sudo apt install git cd $HOME git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k
- Download these fonts:
https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf
- Open the file explorer:
- Double click on each one to open it
- Click on install
- Open a gnome terminal:
- Right click / preferences
- In profiles, on left menu, click on the '+' to add a new profile
- Name: zsh
- Click on checkbox custom font
- Select font mesloLGS NF regular
- Optional: probably you want to uncheck the terminal bell
- Optional: if you want the terminal with white background, you can go to colors tab and uncheck "use colors from system theme"
- Move to command tab
- Click to check "run a custom command instead of my shell"
- Write in "custom command": zsh
- On the left menu, in zsh profile, click in the down arrow
- Select: set as default
- Download a base p10k config:
https://drive.google.com/file/d/1-_QFX2MaX0SxQ37KkzuNIUD-qOiw2xOH/view?usp=sharing
mv Downloads/p10k.zsh .p10k.zsh # optionally, later you can do your own config running: p10k configure (in a new terminal)
- Create file $HOME/.zshrc
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. # Initialization code that may require console input (password prompts, [y/n] # confirmations, etc.) must go above this block; everything else may go below. if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi # Your PATH Exports # Path to your oh-my-zsh installation. export ZSH=$HOME/.oh-my-zsh ZSH_THEME="powerlevel10k/powerlevel10k" plugins=(git) source $ZSH/oh-my-zsh.sh # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh HISTFILE="$HOME/.zsh_history" HISTSIZE=10000000 SAVEHIST=10000000 #setopt BANG_HIST # Treat the '!' character specially during expansion. setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format. setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. #setopt SHARE_HISTORY # Share history between all sessions. #setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history. #setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again. #setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate. setopt HIST_FIND_NO_DUPS # Do not display a line previously found. setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space. setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file. #setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry. #setopt HIST_VERIFY # Don't execute immediately upon history expansion. #setopt HIST_BEEP # Beep when accessing nonexistent history.
Vim
This software is optional, but it is a useful file editor.
- To install it:
sudo apt install vim
- In order to ensure that while editing when files with vim it does not add an extra new line at the end of the edited file, create a file $HOME/.vimrc with the following content
:set nofixendofline
- Set vim basic as default terminal editor in the menu shown after executing:
sudo update-alternatives --config editor
Chrome
This is the supported browser, so its installation is mandatory
- To install it:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb sudo apt install ./google-chrome-stable_current_amd64.deb # If fails during the installation phase with missing required dependencies, run: "sudo apt install -f ..." instead to fix it.
- To clean up after installation:
rm google-chrome-stable_current_amd64.deb
Use different sessions inside chrome
To have different session in each tab of chrome is possible to use a trick: Edit your /etc/hosts , and change:
127.0.0.1 localhost
with
127.0.0.1 localhost *.localhost
With this, you can access to any *.localhost and will point to your localhost, example:
a.localhost/openbravo test.localhost/openbravo b.localhost/openbravo whatever.localhost/openbravo
a.localhost and b.localhost are taken as different hosts so the session is not shared.
PostgreSQL
This is the recommended database. Alternatively Oracle can be installed but in this chapter only PostgreSQL installation will be covered.
- To install it:
sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ '$(cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d'=' -f2)'-pgdg main' > /etc/apt/sources.list.d/pgdg.list" wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt update sudo apt install postgresql-10 sudo -u postgres psql -c "alter user postgres with password 'syspass';"
- Create file (sudo) /etc/postgresql/10/main/conf.d/01-openbravo-standard-postgres9.5.conf
# Required at least for correct import.sample.data # Config value with very bad name, this is not locks per transactions but sizes the # total number of possible locks see formula in postgresql.conf max_locks_per_transaction = 128 # Make sure timezone config is localtime so pg follows system-timezone (as it did up to <9.2 also by default) # Note: pg has auto-detect based on system timezone, but best to set fixed here to be sure it has value we want # Note: sed assumes input is UTC or localtime but that was the case in all testing so far log_timezone = 'localtime' timezone = 'localtime' # activate logging of checkpoints log_checkpoints = on # activate logging of of all waits > deadlock_timeout (1s by default) log_lock_waits = on # track runtime/calls of all pl/sql functions track_functions = all # activate logging of slow queries (>30s to balance usefulness versus log-volume) log_min_duration_statement = 30000 # set locale for number formatting to en_US.UTF-8 lc_numeric = 'en_US.UTF-8'
- Create file (sudo) /etc/postgresql/10/main/conf.d/91-local-changes.conf
# only edit this file #log_min_duration_statement = 0 #checkpoint_timeout = 1h # pg stat #shared_preload_libraries = 'pg_stat_statements' #pg_stat_statements.max = 10000 #pg_stat_statements.track = all
- Restart postgres to take config changes
sudo /etc/init.d/postgresql restart
PostgreSQL clients
- pgadmin4
Extracted from: https://www.pgadmin.org/download/pgadmin-4-apt/
curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update' sudo apt install pgadmin4
- psql
It is installed as part of postgres, if you create a workspace with dt scripts with name 'test', to access it will be:
PGPASSWORD=tad psql -d postgres -U tad -h localhost -d db_test
Java
- To install it:
sudo apt install openjdk-11-jdk
- Configure JAVA_HOME (used by ob ant commands):
sudo sh -c 'echo "JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64" >> /etc/environment'
Note: change only be effective after restart
Ant
- To install it:
sudo apt install ant
- Setup ant config:
sudo sh -c 'echo "export ANT_OPTS=\"-Xmx1024M\"" >> /etc/environment'
Tomcat
- Download tomcat 8.5 (binary, core, tar.gz) from https://tomcat.apache.org/download-80.cgi
- Install it in /opt/apache-tomcat-8.5
cd ~/Downloads tar xf apache-tomcat-8.5.*.tar.gz rm apache-tomcat-8.5.*.tar.gz sudo mv apache-tomcat-8.5.* /opt/ cd /opt sudo ln -s apache-tomcat-8.5.* apache-tomcat-8.5
- Set config for run tomcat standalone (although it will be almost always be used inside eclipse)
sudo sh -c 'echo "export CATALINA_OPTS=\"-server -Djava.awt.headless=true -Xms512M -Xmx1024M\"" >> /etc/environment' sudo sh -c 'echo "export CATALINA_HOME=/opt/apache-tomcat-8.5" >> /etc/environment' sudo sh -c 'echo "export CATALINA_BASE=/opt/apache-tomcat-8.5" >> /etc/environment'
Apache
- Install apache and mod-jk
sudo apt-get install apache2 libapache2-mod-jk
- Create file (sudo) /etc/apache2/conf-available/openbravo-jk-mount.conf
JkMount /* ajp13_worker jkMountCopy all
- Enable the openbravo config:
sudo a2enconf openbravo-jk-mount
- Allow restart of apache without ask password (needed for the offline tests)
sudo sh -c 'echo "openbravo ALL = NOPASSWD: /etc/init.d/apache2" > /etc/sudoers.d/97-ob-apache' # If you are not using openbravo user, change it in the previous command
- Setup ssl with autosigned certificate (optional)
sudo a2enmod ssl sudo a2ensite default-ssl.conf
- Restart apache
sudo /etc/init.d/apache2 restart
- If it didn't work, in some versions of ubuntu is needed to enable jk manually:
cd /etc/apache2/mods-enabled sudo ln -s ../mods-available/httpd-jk.conf .
- If it still didn't work maybe the port 8009 is not enable in eclipse, check the server.xml of tomcat:
<Connector protocol="AJP/1.3" address="127.0.0.1" port="8009" secretRequired="false" redirectPort="8443" />
- Update this in the server.xml of the workspace, and also in the server.xml of the system tomcat (probably on /opt/apache-tomcat-8.5/conf/server.xml), so next projects will have it.
Git
- To install it:
sudo apt install git
- Very important, prevent pull when there was a change in history (forced push):
git config --global pull.ff only
- Upload your ssh key to gitlab
You can follow these steps, if you don't have yet a ssh key you can follow this guide to create one.
- Set you default user:
Replace with your name and last name, and your email for work git config --global user.name "FIRST_NAME LAST_NAME" git config --global user.email "MY_NAME@example.com"
- Set the githooks:
After setup the dt scripts you can add the githooks.
Optional git config
Aliaes
- Optionally, if using zsh and oh my zsh, you can added these aliases to add the developer to the log. Edit the .zshrc and add these lines:
PRETTY_FORMAT="--pretty='format:%C(auto)%h%d %s %C(magenta dim)%an %ar'" alias galo="glo $PRETTY_FORMAT" alias galog="glog $PRETTY_FORMAT" alias galoga="gloga $PRETTY_FORMAT"
p4merge
- Use p4merge for merges:
A good UI tool for help solving merge conflicts if p4merge.
Extracted from: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration
- Download p4merge from:
https://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools
- Extract it:
tar xf p4v.tgz
- Move to opt
sudo mv p4v-* /opt/p4merge
- Create file /usr/local/bin/extMerge , with contents:
#!/bin/sh /opt/p4merge/bin/p4merge $*
- Give execution permissions:
sudo chmod +x /usr/local/bin/extMerge
- Make it default merge tool:
git config --global merge.tool extMerge git config --global mergetool.extMerge.cmd \ 'extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"' git config --global mergetool.extMerge.trustExitCode false
For solve merge conflicts a recommendation is go file by file:
- git mergetool file-with-conflicts
- gmt file-with-conflicts (with the alias)
Note: for ubuntu 22.04 using wayland it is possible that fails to start giving a problem related to wayland, to fix it: apt install qtwayland5
git open
git-open, to execute in the terminal git open and open in the browser the current repo:
sudo npm install --global git-open
gitignore
Till is fixed the delete of snapshots folder after run the tests you can add it to the user gitignore
- Create file ~/.gitignore
# snapshots after run tests web-jspack/*/__snapshots__/
- Then Execute
git config --global core.excludesfile ~/.gitignore
Node and npm
- To install it (extracted from https://github.com/nodesource/distributions/blob/master/README.md):
sudo apt-get install -y curl curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - sudo apt-get install -y nodejs
If the npm and node commands are not available, try opening a new terminal or restarting the computer
If needed to install a specific version of npm, for example 6: sudo npm install -g npm@6
Eclipse IDE
- Download Eclipse IDE (Enterprise Java Developers, Linux 64-bit) from https://www.eclipse.org/downloads/packages/
- Install it on /opt/eclipse
cd ~/Downloads tar xf eclipse-jee-*.tar.gz rm eclipse-jee-*.tar.gz mv eclipse eclipse-2020-09 # set the version that you have download sudo mv eclipse-2020-09 /opt/ cd /opt sudo ln -s eclipse-2020-09 eclipse cd /usr/local/bin sudo ln -s /opt/eclipse/eclipse eclipse
- To create a launcher from the ui, create this file $HOME/.local/share/applications/eclipse.desktop , with this content:
[Desktop Entry] Type=Application Encoding=UTF-8 Name=Eclipse Comment=Eclipse Exec=eclipse Icon=/opt/eclipse/icon.xpm Terminal=false
- Java:
- IMPORTANT: eclipse comes with its own version of java, remember to change in preferences, java, installed jre . And import the java that you have install, something similar to /usr/lib/jvm/java-11-openjdk-amd64
- Tomcat
- Add new apache web server tomcat 8.5 and select the one installed in /opt in previous steps
If you have already cloned the openbravo repos, this is the guide for the workspace setup.
Visual Code
- Download the deb from:
https://go.microsoft.com/fwlink/?LinkID=760868
- Install it:
sudo apt install./<file>.deb
- Increase watchers (Careful, /etc/sysctl.conf is an important file):
sudo sh -c "echo fs.inotify.max_user_watches=524288 >> /etc/sysctl.conf" sudo sysctl -p
- After install needed to do the configuration.
Workspace config file
Workspaces done by dt scripts will already have this file, this is ONLY needed for workspaces done manually:
- If you have the dt scripts, you can use this to create o recreate the config file, based on the latest template:
dt fix-vscode-workspace-file
- If you prefer to do it manually:
- This is the template used for new workspaces: https://gitlab.com/openbravo/ci/retail_scripts/-/blob/master/code-workspace-template.json
- Needed to add manually all the modules, and also add them to the ignore list of jest
- Note: there is a bug in jestrunner and is needed to replace:
- "jestrunner.jestPath": "${workspaceFolder:openbravo}/node_modules/jest/bin/jest.js"
- with the absolute path, for example:
- "jestrunner.jestPath": "<<path_to_workspace>>/openbravo/node_modules/jest/bin/jest.js"
Execute test file after edit it
- Install extension: wk-j.save-and-run
- Add to settings.json:
"saveAndRun": { "commands": [ { "match": ".test.", "cmd": "npm run test ${file}", "useShortcut": false, "silent": false }, ] }
dt scripts setup
- Clone the repositories
git clone git@gitlab.com:openbravo/ci/retail_scripts.git ~/Documents/retail_scripts git clone git@gitlab.com:openbravo/ci/dev_tools.git ~/Documents/dev_tools
- Add to .zshrc
# dt scripts export PATH="$PATH:/home/openbravo/Documents/retail_scripts" export PATH="$PATH:/home/openbravo/Documents/dev_tools" autoload bashcompinit # only for zsh bashcompinit # only for zsh source /home/openbravo/Documents/retail_scripts/dt-completion
- Go to Documents/retail_scripts
cp devtools.config.template devtools.config
- Open devtools.config and set this values:
PRISTINES_PATH: $HOME/Documents/hg_pristines GIT_PRISTINES_PATH: $HOME/Documents/git_pristines WORKSPACES_PATH: $HOME/Documents/workspaces
- Create the needed folders:
mkdir /home/openbravo/Documents/workspaces
- Optionally install the tqdm module of python to get better visual when installing modules
sudo apt install python3-tqdm
Githooks
- Enable the githooks
git config --global core.hooksPath /home/openbravo/Documents/retail_scripts/githooks
Setup development environment in MacOS
This guide was tested in macOs Catalina (10.15.7), macOS Big Sur (11.2.1) and macOS Monterey Version (12.6)
![]() | Before start, check the the current recommended versions, since could happen that the versions on this guide are obsolete. |
Previous steps and local vs global installation
- It is a good practice to create a different user for openbravo stack installation.
- Probably you want to use another Apple ID, for register in the apple store, since if not it will get mixed the history of navigation between this user and the other, etc. So better use another mail or not register in the apple store.
- Probably many of the application installations you want to do only for this user, without affect other users of the computer, to do this:
# Open a terminal: cd $HOME open . # In the finder opened at your home, you should have an Applications folder, you can drag to the left part of finder to have it a hand # If doesn't exist you can create mkdir #HOME/Applications (in finder will recognise it, and put an 'A' logo like the apple store)
- To install an application only for your user,:
- when downloading, instead of drag to global Applications (the default one),
- open a new finder go to your home/Applications that we have create a link before
- and drag the application to this new finder in the applications folder
- For example you can do this for applications like skype
- To install an application only for your user,:
Zsh
Zsh is already the default shell in Mac, so only needed to install ohMyZsh and powerlevel10k:
cd $HOME git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k
- Download and install these fonts (open each one and click on install):
https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf
- Create a new terminal profile
- In the terminal menu (top left), open preferences
- Go to profiles tab, select Basic, and click at the bottom in the down arrow, and select duplicate profile
- Select this new profile and change:
- Text tab: click change in font section, and select meslolgs regular 12
- (If you left the default background it will change to black and white depending on the global white or dark theme)
- Shell tab: when shell exists, close the window (optional)
- Advance tab: uncheck audible bell and visual bell(optional)
- Having selected the new profile, set as default, clicking in 'Default' button (below the profile list)
- Download a base p10k config:
https://drive.google.com/file/d/1-_QFX2MaX0SxQ37KkzuNIUD-qOiw2xOH/view?usp=sharing
mv Downloads/p10k.zsh .p10k.zsh # optionally, later you can do your own config running: p10k configure (in a new terminal)
- Create file $HOME/.zshrc
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. # Initialization code that may require console input (password prompts, [y/n] # confirmations, etc.) must go above this block; everything else may go below. if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi # Your PATH Exports # Path to your oh-my-zsh installation. export ZSH=$HOME/.oh-my-zsh ZSH_THEME="powerlevel10k/powerlevel10k" plugins=(git) source $ZSH/oh-my-zsh.sh # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh HISTFILE="$HOME/.zsh_history" HISTSIZE=10000000 SAVEHIST=10000000 #setopt BANG_HIST # Treat the '!' character specially during expansion. setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format. setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. #setopt SHARE_HISTORY # Share history between all sessions. #setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history. #setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again. #setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate. setopt HIST_FIND_NO_DUPS # Do not display a line previously found. setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space. setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file. #setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry. #setopt HIST_VERIFY # Don't execute immediately upon history expansion. #setopt HIST_BEEP # Beep when accessing nonexistent history.
- If you want to go back to the standard Mac terminal:
- rename the file .zshrc to other name like for example .zshrc.bak
- change the default profile to the one that you were using before, the default one in Mac is the basic profile
Vim
- In order to ensure that while editing files with vim it does not add an extra new line at the end of the edited file and also to have colors, create a file $HOME/.vimrc with the following content
:set nofixendofline syntax on
Chrome
- A good practices is to have installed the 3 versions of chrome: the stable, the beta and the dev versions of chrome.
- In this way we get 2 benefits:
- We test the pos in the upcoming versions of chrome
- We get different profiles, so in the case is needed to clean the cache without affect the rest o things we have open, or to have 2 different profiles to open the pos and the rep.
Use different sessions inside chrome
To have different session in each tab of chrome is possible to use a trick: Edit your /etc/hosts , and change:
127.0.0.1 localhost
with
127.0.0.1 localhost *.localhost
With this, you can access to any *.localhost and will point to your localhost, example:
a.localhost/openbravo test.localhost/openbravo b.localhost/openbravo whatever.localhost/openbravo
a.localhost and b.localhost are taken as different hosts so the session is not shared.
PostgreSQL
- Go here: https://postgresapp.com/downloads.html
- Download the one that has support for many Postgres versions
- Double click and install in the global Applications (needs to be global because of links to other libraries)
- Although is a global install, the databases and the application will only start with the current user
- Search in launchpad and open it
- Create new database 11:
- Press the box button in the bottom left, to open the list of databases
- Delete the database 13 (- button in left bottom)
- Create new database (+ button in the left bottom)
- Name: PostgreSQL 10
- Version: 10
- Data Directory: the proposed one
- Port: the one proposed, that should be 5432
- click create server
- Click on initialise
- In the menu, select preferences
- mark start "Automatically start on login"
- In server settings:
- mark "automatically start server"
PostgresSQL clients
- Postico
- Is not free, but has a free limited version that for normal use is ok
- It can be downloaded from here: https://eggerapps.at/postico/
- The good about Postico is that is build for macOS, and can be integrate with postgresapp (that we have just installed).
- In the preferences of postgresapp can be configured to open the databases with Postico, so when we do doble click on a database in postgresapp it opens in Postico.
- pgsql
- Open the application of Postgres and double click on a database icon
- Add to .zshrc , to make available pg commands like psql. Note: each time changed the db version needs to update this export:
export PATH="$PATH:/Applications/Postgres.app/Contents/Versions/10/bin"
- pgadmin4
- Go to https://www.pgadmin.org/download/pgadmin-4-macos/
- Download the latest version
- Install it on your personal Applications (no needed to go to global applications)
- To create the connection:
- In servers right click, create, server
- In General tab / Name: localhost
- In Connection tab / Host : localhost / Username: openbravo
- Press save. Note: no need to edit anything else also no needed to set a pass
Java
Guide extracted from: https://sdkman.io/install
- We are going to use SDKMAN to manage jdk versions, to install it:
curl -s "https://get.sdkman.io" | bash
- Improve security of sdkman to add to the end of the path instead of the beginning, edit file $HOME/.sdkman/src/sdkman-path-helpers.sh
PATH="$PATH:$SDKMAN_CANDIDATES_DIR/$candidate/current/bin" echo "$PATH" | grep -q "$candidate_dir" || PATH="${PATH}:${candidate_bin_dir}"
- Init and install java
source "$HOME/.sdkman/bin/sdkman-init.sh" sdk install java 11.0.2-open
- Create symlink to java, for use in eclipse
cd ~/Documents ln -s /Users/openbravo/.sdkman/candidates/java/current/ java
- Permissions, it is needed that java has access to document files:
# Check in the System Preferences / Security and privacy # Check Files and folders / java has access to Documents folder # If java don't have access it will show this error: # Buildfile: build.xml does not exist!
- If needed another version can be selected from here: https://jdk.java.net/archive/ , just take the 3 numbers of the version that you want to install, al usual rule the last minor of the mayor that you want to install.
- To change the version of java:
sdk current # to see all the current versions sdk list java # to see available versions of java sdk use java 11.0.0. # to change the used version of java
- SDKMAN guide: https://sdkman.io/usage
Ant
- Installation with SDKMAN
sdk install ant
- add to .zshrc
export ANT_OPTS="-Xmx1024M"
Tomcat
- Installation with SDKMAN
sdk list tomcat # select the last minor of 8.5 sdk install tomcat 8.5.60
- Create a link, to use in eclipse
cd ~/Documents ln -s /Users/openbravo/.sdkman/candidates/tomcat/current tomcat
- The folder for add to eclipse is Documents/tomcat
Apache
Normally is not needed to use Apache, only for execute offline tests of selenium, so you can skip this step till needed.
In case of needed: apache already comes installed in Mac. Apart of apache is needed to configure the mod_proxy.
- Create file: /private/etc/apache2/other/openbravo.conf with this content:
<IfModule !proxy_module> LoadModule proxy_module libexec/apache2/mod_proxy.so </IfModule> <IfModule !proxy_http_module> LoadModule proxy_http_module libexec/apache2/mod_proxy_http.so </IfModule> <IfModule mod_proxy.c> ProxyRequests On ProxyPreserveHost On ProxyStatus On <Location /status> SetHandler server-status Order Deny,Allow Deny from all Allow from 127.0.0.1 </Location> ProxyPass /openbravo http://localhost:8080/openbravo </IfModule>
- Create folder /etc/init.d/
sudo mkdir /etc/init.d
- Create file /etc/init.d/apache2 with this content:
#!/bin/bash case $1 in start) sudo apachectl start && echo 'Starting apache2' ;; stop) sudo apachectl stop && echo 'Stopping apache2' ;; status) [ "$(ps aux | grep httpd | grep -v grep)" != "" ] && echo 'is running' ;; esac
- Give permissions
sudo chmod +x /etc/init.d/apache2
- Create file: /etc/sudoers.d/97-ob-apache , with:
openbravo ALL = (ALL) NOPASSWD: /usr/sbin/apachectl openbravo ALL = (ALL) NOPASSWD: /etc/init.d/apache2
Git
- Git comes already installed in Mac.
- Very important, prevent pull when there was a change in history (forced push):
git config --global pull.ff only
- Upload your ssh key to gitlab
You can follow these steps, if you don't have yet a ssh key you can follow this guide to create one.
- Set you default user:
Replace with your name and last name, and your email for work git config --global user.name "FIRST_NAME LAST_NAME" git config --global user.email "MY_NAME@example.com"
- Set the githooks:
After setup the dt scripts you can add the githooks.
Optional git config
Aliases
Optionally, if using zsh and oh my zsh, you can added these aliases to add the developer to the log. Edit the .zshrc and add these lines:
PRETTY_FORMAT="--pretty='format:%C(auto)%h%d %s %C(magenta dim)%an %ar'" alias galo="glo $PRETTY_FORMAT" alias galog="glog $PRETTY_FORMAT" alias galoga="gloga $PRETTY_FORMAT"
p4merge
Use p4merge for merges:
A good UI tool for help solving merge conflicts if p4merge.
Extracted from: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration
- Download p4merge from:
https://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools
- Install p4merge in your local Applications, no need to be global (there is lot of applications in the package, only needed p4merge)
- Make it default merge tool:
git config --global merge.tool extMerge git config --global mergetool.extMerge.cmd \ '~/Applications/p4merge.app/Contents/MacOS/p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"' git config --global mergetool.extMerge.trustExitCode false
For solve merge conflicts a recommendation is go file by file:
- git mergetool file-with-conflicts
- gmt file-with-conflicts (with the alias)
git open
git-open, to execute in the terminal git open and open in the browser the current repo:
sudo npm install --global git-open
gitignore
gitignore, to ignore .DS_Store files from Mac
- Create file ~/.gitignore
# Mac .DS_Store # snapshots after run tests web-jspack/*/__snapshots__/
- Then Execute
git config --global core.excludesfile ~/.gitignore
Node and npm
- Download it from https://nodejs.org/es/download/
- Recommended version of node is 12, but since doesn't have installed you can download the 14 lts.
- It will do a global install
Eclipse
- Download it from: https://www.eclipse.org/downloads/packages/
- Choose Eclipse IDE for Enterprise Java Developers / macOS x86_64
- Install in the local Applications, no needed to do a global install
- To make available eclipse in command line, add this line to .zshrc file:
export PATH="$PATH:/Users/openbravo/Applications/Eclipse.app/Contents/MacOS"
- Java:
- IMPORTANT: eclipse in Mac comes with its own version of java, remember to change in preferences, java, installed jre
- And import the java link created in documents
- Tomcat
- When setting the workspace of openbravo remember that in the guide we have create a symlink in documents to the current tomcat
Chromedriver
- Download chrome driver the Mac version from https://chromedriver.chromium.org
mkdir ~/Documents/chromedrivers/ cd Downloads mv ~/Downloads/chromedriver ~/Documents/chromedrivers/chromedriver-88.0.4324.96 cd ~/Documents/chromedrivers/ ln -s chromedriver-88.0.4324.96 chromedriver-default
- In OpenbravoERPProperties in mobile-test, add this 2 variables:
If using dt scripts to build the environment, this will be already added
chromedriverPath=/Users/openbravo/Documents/chromedrivers/chromedriver-default forceUrl=http://localhost/
VSCode
- Download from https://code.visualstudio.com/download
- Copy the downloaded executable to local Applications (no installation, just copy)
- Make vscode available in the path for command line: https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line
- After install needed to do the configuration.
Other Mac Specific
Fix home and end shortcut
- Terminal:
Edit the profile, go to keyboard, - press +, key home, modifier none, action send text, command: \001 - press +, key end, modifier none, action send text, command: \005
- Eclipse
Go to preferences, filter by keys - search: line start, edit binding, press home - search: line end, edit binding, press end Also fix the conflicts, to go to start and end of page - search: text start, press control home - search: text end, press control end Click on apply and close
- Other global, like safari
mkdir ~/Library/KeyBindings
Create file ~/Library/KeyBindings/DefaultKeyBinding.dict , with :
{ "\UF729" = moveToBeginningOfParagraph:; // home "\UF72B" = moveToEndOfParagraph:; // end "^\UF729" = moveToBeginningOfDocument:; // ctrl-home "^\UF72B" = moveToEndOfDocument:; // ctrl-end }
Note: it will apply after reboot
- Other programs like vim, visual code, skype or google docs have already set the home/end to go to start/end of the line
dt scripts setup
- Clone the repositories
git clone git@gitlab.com:openbravo/ci/retail_scripts.git ~/Documents/retail_scripts git clone git@gitlab.com:openbravo/ci/dev_tools.git ~/Documents/dev_tools
- Add to .zshrc
# dt scripts export DT_SCRIPTS_FOLDER="/Users/openbravo/Documents/retail_scripts" export PATH="$PATH:/Users/openbravo/Documents/retail_scripts" export PATH="$PATH:/Users/openbravo/Documents/dev_tools" autoload bashcompinit bashcompinit source /Users/openbravo/Documents/retail_scripts/dt-completion
- Go to Documents/retail_scripts
cp devtools.config.template devtools.config
- Open devtools.config and set this values:
PRISTINES_PATH: $HOME/Documents/hg_pristines GIT_PRISTINES_PATH: $HOME/Documents/git_pristines WORKSPACES_PATH: $HOME/Documents/workspaces
- Create the needed folders:
mkdir /Users/openbravo/Documents/workspaces
- Optionally install the tqdm module of python to get better visual when installing modules
sudo -H pip3 install tqdm
Githooks
- Enable the githooks
git config --global core.hooksPath /Users/openbravo/Documents/retail_scripts/githooks
VisualCode configuration
VSCode Extensions
- Eslint : dbaeumer.vscode-eslint
- Prettier : esbenp.prettier-vscode
- Copy edited files from modules to webcontent and viceversa : emeraldwalk.runonsave
- For only execute one test, you can install this extension: firsttris.vscode-jest-runner
- Git lens [optional] (git history improved) : eamodio.gitlens
Important : eslint first time a project is opened ask if you trust, and you have to click to trust to execute eslint.
Recommended shortcuts
- Go back , go forward: Default shortcut for this is quite complex, so a good idea is to use the eclipse ones (alt + leftarrow/rightarrow)
- ctrl+k y luego ctrl+s -> to open the shortcuts menu
- search: "go back", click edit, press 'alt' + 'leftarrow'
- search: "go forward", click edit, press 'alt' + 'rigtharrow'
Example settings.json
Go to File > preferences > Settings, and in the top right there is a button to change the view from form to json file, click on it, and set this content:
{ // js format on save "[javascript]": { "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[javascriptreact]": { "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[css]": { "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[scss]": { "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode" }, "prettier.requireConfig": true, // Copy edited files from modules to webContent and from webContent to modules "emeraldwalk.runonsave": { "commands": [ { "match": "WebContent/web/(?!org.openbravo.userinterface.smartclient|org.openbravo.userinterface.smartclient.dev|userinterface.skin.250to300Comp)", "cmd": "dir=$( echo ${file} | sed -r 's#.*WebContent/web/([^/]+)/.*#\\1#') && file_mod=$(echo ${file} | sed -r 's#WebContent/web/'$dir'/#modules/'$dir'/web/'$dir'/#' ) && cp ${file} $file_mod" }, { "match": "modules/(?!org.openbravo.userinterface.smartclient|org.openbravo.userinterface.smartclient.dev|userinterface.skin.250to300Comp)", "cmd": "dir=$( echo ${file} | sed -r 's#.*modules/([^/]+)/.*#\\1#') && file_mod=$(echo ${file} | sed -r 's#modules/'$dir'/web/'$dir'/#WebContent/web/'$dir'/#' ) && cp ${file} $file_mod" } ] }, // exclude in search window the generated js files (i.e. ab7bbbd81f40d14b3b44c3241ec26a7b.js) "files.exclude": { "**/WebContent": true, "**/WebContent/web/js/gen": true } // ignore gitignore for allow search in external modules // better to add the needed repo to the folder workspace // "search.useIgnoreFiles": false, }
Note: eslint don't need any especial config and should work directly, only needed to do a npm install in the openbravo source path (this is already done by dt setup workspace scripts
Dev-scripts
Setup
git hook
- Recommend to add the dt scripts hook instead the normal ones, since add more checks in top on the mandatory ones, like for example the licence year check.
- To install the dt scripts hook, follow the dt setup guides of linux or Mac in this document
- This githook will add to the standard checks (they cancel the commit on error):
- jslint
- js formatter
- these extra checks checks (will not block the commit):
- the license year
- the author of mobile-test tests
- Optionally, you can enable to execute the jest tests on commit (will not block the commit):
- editing your devtools.config file in your local clone of retail_scripts, and add:
- export EXECUTE_TESTS_ON_COMMIT=true
- editing your devtools.config file in your local clone of retail_scripts, and add:
Make eclipse available in the path
The dt scripts after build a workspace opens eclipse and also use it to run a clean command in the workspace copied, so it is very recommended to make eclipse available in the path.
To make this, follow the eclipse installation guide that you can found in this doc for linux or Mac.
Create workspaces with dt scripts
Create eclipse workspace with the retail pack
dt pack-setup-workspace name: i33000 #i33000 is the name you want for this particular workspace
Note: first run will guide you to how to create the template of eclipse that will be used in next workspaces
Note2: always when creating a new eclipse workspace with the script needs to delete the trl, wad and core projects and re-import them again.
Workspace with the retail pack and the external modules
dt modules-setup-workspace name: i41000_with_modules
Workspace of modules linked to a pack workspace
dt pack-setup-workspace name: i2300 dt modules-setup-workspace link-to-pack: i2300 # same name used for the pack
This creates a normal pack workspace, and in the modules workspace create links for:
- retail pack modules
- mobile-test
The name of the modules workspace in this example will be i2300-modules.
So changes done in the pack in any of the workspaces is directly done in the other.
Useful for:
- Start fixing a problem with the pack and also fail in modules
- the changes done in the pack are directly available for the modules, including not commited things
- the commits done in the pack in the moduels workspaces , can be pushed to try-retail in the pack workspace that has the correct sampledata module
- avoid the problem of lost changes done in pack or modules if working in both in pararell
Known issue:
- the mobile-test point to the db , and since the pi-mobile is the same in both, each time you change form one repo to the other the db pointed by pi-mobile needs to be changed accordily.
Workspace of backports
dt pack-setup-workspace name: 20q3 --context-definition: retail/try-retail-20Q3
If needed also modules:
dt modules-setup-workspace name: 20q3 --context-definition: retail/try-retail-20Q3
Or if you want linked to the pack workspace:
dt modules-setup-workspace link-to-pack: 20q3 --context-definition: retail/try-retail-20Q3
context_definitions
- Ways to specify the json:
- In the oficial repo: --context-definition: retail/try-retail
- By url: --context-definition-from-url: https://url/file.json
- By file: --context-definition-from-file: /home/openbravo/file.json
- Official repo: https://gitlab.com/openbravo/ci/context_definitions
- The clone for workspace setup support the json inheritance, example:
- The name of the json for projects should be temp-whatever.json.
Workspace of pos2
Add these aliases to .zshrc or .bashrc:
alias c2start="(cd modules/org.openbravo.core2/web-jspack/org.openbravo.core2 && npm start)" alias c2story="(cd modules/org.openbravo.core2/web-jspack/org.openbravo.core2 && npm run storybook)" alias c2build="(cd modules/org.openbravo.core2/ && ant build)" alias c2gen="(cd modules/org.openbravo.core2/ && ant generate.app)" alias c2bs="c2build && c2start" alias c2cy="(cd modules/org.openbravo.core2/web-jspack/org.openbravo.core2/src-test && ../node_modules/.bin/cypress open)" alias c2messages="(cd modules/org.openbravo.core2/ && ant generate.module.info)"
Pack:
dt modules-setup-workspace name: pos2 --context-definition: retail/pos2 # NOTE: needed modules-setup-workspace instead pack-setup-workspace, if not there is a problem with the sampledatas and will not build
With restaurant and other modules:
dt modules-setup-workspace name: pos2modules --context-definition: retail/pos2-modules
After create the workspace execute (in openbravo folder):
c2bs # Also needed to execute after any change in old pos (mobile.core, posterminal, etc) # It will build old pos part and start npm to be accessible in port 3000
Url:
- To access through npm, development mode: http://localhost:3000/?terminal=VBS-2
- To access through tomcat, production mode: http://localhost/web/pos/?terminal=VBS-2
The port in which is started npm and the url of the backend can be edited, creating a file modules/org.openbravo.core2/web-jspack/org.openbravo.core2/.env :
PORT=3000 REACT_APP_SERVER_URL=http://localhost/openbravo
For more information about core2 builds: https://gitlab.com/openbravo/product/pmods/org.openbravo.core2/-/blob/master/README.md
Workspace of clients
dt modules-setup-workspace name: customer_env --context-definition-from-codesnapshot-file: /home/openbravo/snapshots/mycustomersnapshot --dump: /home/openbravo/dumps/mycustomerdump.dmp --sql-script-after-restore: /home/openbravo/disable-customer-webservices.sql
gitr, gitp and gitb
gitp and gitr are equal than hgp and hgr.
bitb is to execute the same git command in all the git repos that is using the branch specified.
For example:
gitb projectA status
It will execute git status in all git repos of the workspace that the current branch is projectA.
If you want to list the last commits of all the repos that you are using in your branch:
gitb projectA --no-pager log -1 --oneline # or with author and antiquity gitb projectA --no-pager log -1 --pretty='format:%C(auto)%h%d %s %C(magenta dim)%an %ar'
Work with devel branches
After created an environment with dt scripts all repos point to product repos (if not specified otherwise in the context definition used).
The usual way of work is point origin to devel and upstream to product, so for do this change you can use this command:
dt use-personal-fork user: openbravo/devel/pmods branch: fix/00111001-testIssue NOTE: this is for pmods repos, if not needed to adapt the path, also the branch you have to use the one created for you project
What the script does is:
- set as upstream the current origin
- git remote add upstream git@gitlab.com:openbravo/product/pmods/repo-name.git
- then the origin is set maintaining the module name, but replacing the path with what is specified in the user parameter
- git remote set-url origin git@gitlab.com:openbravo/devel/pmods/repo-name.git
- then do a fetch all
- git fetch --all --prune
- and tries to move to the specified branch in the origin (devel) and if not exists it creates it in local
- git checkout -b branch-name
- git branch --set-upstream-to=origin/branch-name branch-name
To revert the changes done exists this command:
dt stop-using-personal-fork
The commands executed in the revert:
- git remote set-url origin current-upstream
- git remote remove upstream
- git fetch --all --prune
- git checkout master
Add new modules to the workspace
dt add-new-modules-to-workspace Note: can be used with the option --context-definition to fix origins and branches
Push to try-retail
Setup: Needed to have configured the dev_tools and have them added in the path.
In openbravo folder:
run-try.py --retail --desc push-description
For info about the options:
run-try.py --help
Personal forks
Important: To send from a personal forks to try-retail you need to give 'reporter' access to @OBBuildsReadOnly user to your personal fork.
Redistribute suites
When the time that takes each job of try-retail is unbalanced there is script that redistribute the suites along the jobs:
- go to https://builds.openbravo.com/job/try-ret-init , and choose the last nightly_default, or the one that you want to use as a base
- download the retail.html in your home folder.
- go to an updated mobile-test repo
- Very important: check that you don't have changes or any extra file: git status, since after the scripts runs it will left hundred of changes and will be needed a 'git add . ' and we don't want to accidentally add any other file or change.
- in the mobile-test repo execute
dt redistribute-suites retail-html-path: /home/openbravo/retail.html
- Then add all changes: git add .
- And commit: git commit -m "Suites redistribution"
- Send to try-retail, could fail many tests because are not correctly created and are not atomic and depends that another test is executed before
Update eclipse template
The scripts has a template of eclipse configuration in the folder of the scripts.
This template includes the java formater, the projects imported, the tomcat servers, the opened files, etc.
If over time needs to be updated, for example a change in the formater or tomcat, follow these steps:
- Open a workspace of eclipse
- Do all the changes
- Close the eclipse of that workspace
- Go to the workspace folder. For example: $HOME/workspaces/test
- Compress all the config:
tar czf eclipse.tgz Servers/ RemoteSystemsTempFiles/ .metadata/
- Move to the folder of dev-scripts
mv eclipse.tgz $(which dt | sed 's/dt$//')
Migration from Mercurial to GIT
- Repos:
Remember: the repos in product can be used when you don't plan to do changes on it, they have automatic sync from mercurial repos, but you will never push to these repos.
The repos in project/retail can be used when you want to create development branches, they don't have autosync from mercurial repos.
- Zsh
It is very recommended to use zsh with some customizations to work with git, it adds many useful information in the prompt line.
To install zsh follow the zsh install guide.
- Configure the git hooks for commits
- To prevent unnoticed merges when pulling from repos with modified history, execute:
git config --global pull.ff only
- Fix visual code workspace to support git repos, json template
- try-retail: the new script for push to try-retail is run-try.py ( https://gitlab.com/openbravo/ci/dev_tools.git ) and the executions can been seen in builds.openbravo.com
Eclipse workspace setup
1.- Import -> existing projects into workspace - Choose folder of the workspace - Mark search for nested projects - Choose openbravo, mobile-test and openbravoCore, (unmark the rest)
2.- Import preferences: - Import, general, preferences - openbravo/config/eclipse/openbravo-eclipse-prefs.epf - finish
3.- Create new server - Check serve modules without publishing - Check modules auto reload by default - Timeout increase to 120 both - Double click on the server, general information, open launch configuration, arguments, vm arguments, add: -Djava.awt.headless=true -Xms512M -Xmx1024M - go to modules - add web module, select openbravo - click edit, disable reload
Known issues in some eclipse workspaces
1. In strange cases it gives an error: "CountAction cannot be resolved", to fix it go to CountAction.java and in line 16 change to public the enum, save, then remove the public (left as it was) and save again.
If you don't have the CountAction.java file go to CountEnum.java and in line 29 change to public the Optional<CountAction> , save, then remove the public (left as it was) and save again.
Optional workspace setup
- For better clarity in projects presentation you can try:
- in the left tab (project explorer), in the top right there is a down arrow, click on it
- select project presentation: hierarchical (this will include obCore inside openbravo project, except if it is imported from another workspace, it is a good indicator that you have correctly imported it)
- select package presentation: hierarchical
Manual guide
1. Create a new directory in your computer
2. Navigate to that directory
3. Download Eclipse IDE (https://eclipse.org/downloads/) and copy it into that directory
4. Download Tomcat (http://tomcat.apache.org/) and copy it into that directory
5. Clone pi-mobile
FIXME: hg clone https://code.openbravo.com/tools/automation/pi-mobile
6. Clone the ERP
FIXME: hg clone https://code.openbravo.com/erp/devel/pi openbravo
7. Clone the retail repositories in the Navigate to the openbravo/modules directory. (from the ret-test-* repository list that can be found below):
cd openbravo/modules FIXME: hg clone https://code.openbravo.com/erp/pmods/org.openbravo.mobile.core FIXME: hg clone https://code.openbravo.com/erp/pmods/org.openbravo.retail.config FIXME: hg clone https://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts FIXME: hg clone https://code.openbravo.com/erp/pmods/org.openbravo.retail.pack FIXME: hg clone https://code.openbravo.com/erp/pmods/org.openbravo.retail.poshwmanager FIXME: hg clone https://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal FIXME: hg clone https://code.openbravo.com/erp/pmods/org.openbravo.retail.returns FIXME: hg clone https://code.openbravo.com/erp/pmods/org.openbravo.retail.sampledata
8. Execute ant.setup and configure the ERP
cd openbravo ant setup
9. Execute setup.py to configure pi-mobile
cd pi-mobile python3 setup.py ../openbravo
10. Run install.source
cd openbravo ant install.source
11. Start the Eclipse that you downloaded in the directory
- add the ERP projects. add the downloaded tomcat as its server
- add the pi-mobile project
12. Start the ERP/tomcat. Verify that you can navigate to a terminal
13. Start selenium from the command line. Open a terminal and execute:
cd pi-mobile/seleniumTools sh standalone.sh
14. Run a test
- In, eclipse, in the pi-mobile project select a test, e.g: VerifySimpleSale.java
- Right click on the test and execute Run as » JUnit test
Repositories and continuous integration jobs
Currently there are 2 test repositories :
- https://code.openbravo.com/tools/automation/pi-mobile
- https://code.openbravo.com/tools/automation/pi-mobile-sandbox
The pi-mobile repository is used as the main repository for the tests and is used for the main jobs, the ones included in the continuous integration process for Retail. These jobs include:
The same jobs can be found in the try server:
The pi-mobile-sandbox repository, on the other hand, is used for the ret-sandbox-* jobs. The sandbox repository works as a test repository for the tests' modifications, meaning that it is possible to push changes to the tests without affecting the continuous integration cycle. For developers, pi-mobile-sandbox also works as a time-saving strategy to execute the tests after pushing changes to retail modules, that is, sandbox jobs can be executed before the code passes continuous integration.
![]() | ret-test-* and ret-modules-* will not reflect code changes until previous integration steps have finished successfully. |
Repositories used in the continuous integration servers
ret-test-*
- [1]
- https://code.openbravo.com/erp/devel/pi
- https://code.openbravo.com/erp/mods/org.openbravo.agingbalance
- https://code.openbravo.com/erp/mods/org.openbravo.financial.cashflowforecast
- https://code.openbravo.com/erp/mods/org.openbravo.utility.multiplebpselector
- https://code.openbravo.com/erp/pmods/org.openbravo.mobile.core
- https://code.openbravo.com/erp/pmods/org.openbravo.retail.config
- https://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts
- https://code.openbravo.com/erp/pmods/org.openbravo.retail.pack
- https://code.openbravo.com/erp/pmods/org.openbravo.retail.poshwmanager
- https://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal
- https://code.openbravo.com/erp/pmods/org.openbravo.retail.returns
- https://code.openbravo.com/erp/pmods/org.openbravo.retail.sampledata
- [2]
ret-modules-*
- [3]
- RR14Q1: https://code.openbravo.com/erp/devel/pi
- RR14Q1: https://code.openbravo.com/erp/pmods-branches/org.openbravo.test.mobile.sampledata
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.client.analytics
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.financial.multitaxcategory
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.mobile.core
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.mobile.procurement
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.mobile.warehouse
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.mobile.warehouse.physicalinventory
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.mobile.warehouse.picking
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.multiupc
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.activediscountspopup
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.analytics
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.bestsellers
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.complementary
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.config
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.copybestsellers
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.copystore
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.discount.twofamiliescombo
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.bestdeal
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.bypaymentmethod
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.bytotal
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.category
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.combo
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.coupons
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.giftcards
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.multiupc
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.pack
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.poshwmanager
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.postest
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.pricecriteria
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.printlast
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.returns
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.sessions
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.showprodsk
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.stockcriteria
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.stockvalidation
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.taxexempt
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.testsampledata
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.trainingmode
- RR14Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.unittest
- RR15Q2: https://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.cost
- RR15Q2: https://code.openbravo.com/erp/pmods/org.openbravo.retail.marginindicator
- RR15Q2: https://code.openbravo.com/erp/pmods/org.openbravo.retail.productcost
- RR16Q1: https://code.openbravo.com/erp/pmods/org.openbravo.pricing.levelpricing
- RR16Q1: https://code.openbravo.com/erp/pmods/org.openbravo.pricing.scalablelevelpricing
- RR16Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.scaledprice
- RR16Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.levelpricing
- RR16Q1: https://code.openbravo.com/erp/pmods/org.openbravo.warehouse.pickinglist
- RR16Q1: https://code.openbravo.com/erp/pmods/org.openbravo.warehouse.structure
- RR16Q2: https://code.openbravo.com/erp/pmods/org.openbravo.retail.servicesequence
- RR17Q3: https://code.openbravo.com/erp/pmods/org.openbravo.externaldata.integration
- RR17Q3: https://code.openbravo.com/erp/pmods/org.openbravo.retail.productonthefly
- RR17Q4: https://code.openbravo.com/erp/pmods/org.openbravo.retail.digitalcoupons
- RR17Q4: https://code.openbravo.com/erp/pmods/org.openbravo.retail.scanreceipt
- RR18Q1:https://code.openbravo.com/erp/pmods/org.openbravo.retail.selfcheckout
- RR18Q1:https://code.openbravo.com/erp/pmods/org.openbravo.retail.selfcheckout.bestdeal
- RR18Q1:https://code.openbravo.com/erp/pmods/org.openbravo.retail.verystar
- RR18Q1:https://code.openbravo.com/erp/pmods/org.openbravo.retail.selfcheckout.verystar
- RR18Q1:https://code.openbravo.com/erp/mods/org.openbravo.module.languagelocalname
- RR18Q2:https://code.openbravo.com/erp/pmods/org.openbravo.retail.fastbrowse
- RR18Q2:https://code.openbravo.com/erp/pmods/org.openbravo.certification.france.testing
- RR18Q2:https://code.openbravo.com/erp/pmods/org.openbravo.certification.france.dev (Cloned folder should be like the javapackage: org.openbravo.certification.france)
- RR18Q2:https://code.openbravo.com/erp/pmods/org.openbravo.retail.contactinfoforproduct
- RR18Q3: https://code.openbravo.com/erp/pmods/org.openbravo.warehouse.advancedwarehouseoperations
- RR18Q3: https://code.openbravo.com/erp/pmods/org.openbravo.warehouse.advancedwarehouseoperations.printing.bartender
- RR18Q3: https://code.openbravo.com/erp/pmods/org.openbravo.warehouse.advancedwarehouseoperations.template
- RR18Q3: https://code.openbravo.com/erp/mods/org.openbravo.distributionorder
- RR18Q3: https://code.openbravo.com/erp/pmods/org.openbravo.warehouse.advancedwarehouseoperations.distributionorders
- RR18Q3: https://code.openbravo.com/erp/pmods/org.openbravo.warehouse.advancedwarehouseoperations.retailconnector
- RR18Q3: https://code.openbravo.com/erp/pmods/org.openbravo.retail.multitaxcategory
- RR18Q3: https://code.openbravo.com/erp/pmods/org.openbravo.retail.sumupprovider
- RR18Q3: https://code.openbravo.com/erp/pmods/org.openbravo.retail.chasepaymentech
- RR18Q4: https://code.openbravo.com/erp/pmods/org.openbravo.retail.emailphoneicons
- RR18Q4: https://code.openbravo.com/erp/pmods/org.openbravo.retail.forgotpassword
- RR18Q4: https://code.openbravo.com/erp/pmods/org.openbravo.retail.autobom
- RR19Q1: https://code.openbravo.com/erp/pmods/org.openbravo.warehouse.advancedwarehouseoperations.sampledata
- RR19Q1: https://code.openbravo.com/erp/mods/org.openbravo.utility.opencsv
- RR19Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.services.autoprice/
- RR19Q1: https://code.openbravo.com/erp/pmods/org.openbravo.retail.deliverymodes
- Merged into posterminal in RR19Q3
- RR19Q1: https://code.openbravo.com/erp/pmods/org.openbravo.service.external.integration
- RR19Q2: https://code.openbravo.com/erp/pmods/org.openbravo.loyalty.programs
- RR19Q2: https://code.openbravo.com/erp/pmods/org.openbravo.retail.loyalty.programs
- RR19Q2: https://code.openbravo.com/erp/pmods/org.openbravo.retail.orderpreparation
- RR19Q2: https://code.openbravo.com/erp/pmods/org.openbravo.retail.chequecadeau
- RR19Q2: https://code.openbravo.com/erp/pmods/org.openbravo.retail.selfcheckout.chasepaymentech
- RR19Q3: https://code.openbravo.com/erp/pmods/org.openbravo.module.resources
- RR19Q3: https://code.openbravo.com/erp/mods/org.openbravo.module.productbomversion
- RR19Q3: https://code.openbravo.com/erp/mods/org.openbravo.module.productbomversion.template
- RR19Q3: https://code.openbravo.com/erp/pmods/org.openbravo.portal.member.roles
- RR19Q3: https://code.openbravo.com/erp/pmods/org.openbravo.retail.restaurantmanagement
- RR19Q3: https://code.openbravo.com/erp/pmods/org.openbravo.loyalty.earn.buyxearny
- RR19Q3: https://code.openbravo.com/erp/pmods/org.openbravo.loyalty.burn.expired
- RR19Q3: https://code.openbravo.com/erp/pmods/org.openbravo.loyalty.burn.giftcertificate
- RR19Q4: https://code.openbravo.com/erp/pmods/org.openbravo.loyalty.burn.coupon
- RR19Q4: https://code.openbravo.com/erp/pmods/org.openbravo.retail.loyalty.burn.coupon
- RR19Q4: https://code.openbravo.com/erp/pmods/org.openbravo.retail.discounts.tests
- RR19Q4: https://code.openbravo.com/erp/mods/org.openbravo.api.ticket
- RR19Q4: https://code.openbravo.com/erp/pmods/org.openbravo.service.jsexecutor
- RR19Q4: https://code.openbravo.com/erp/pmods/org.openbravo.discounts
- RR19Q4: https://code.openbravo.com/erp/pmods/org.openbravo.retail.adyenprovider
- RR19Q4: https://code.openbravo.com/erp/pmods/org.openbravo.retail.ingenicotsiprovider
- RR20Q3: https://code.openbravo.com/erp/pmods/org.openbravo.retail.asyncpayprovider
- RR20Q3: https://code.openbravo.com/erp/pmods/org.openbravo.retail.selfcheckout.asyncpayprovider
- RR20Q3: https://code.openbravo.com/erp/pmods/org.openbravo.retail.axisc3
- RR20Q3: https://code.openbravo.com/erp/pmods/org.openbravo.retail.nexoprovider
- RR20Q3: https://code.openbravo.com/erp/pmods/org.openbravo.retail.selfcheckout.nexoprovider
Planned:
About the sampledata used:
The Retail Sampledata repository varies from the test jobs to the modules jobs. Ret-*-test-* jobs use the standard retail sampledata repository (https://code.openbravo.com/erp/pmods/org.openbravo.retail.sampledata) while ret-*-modules-* jobs use a different branch of the repo (https://code.openbravo.com/erp/pmods-branches/org.openbravo.test.mobile.sampledata) together with (https://code.openbravo.com/erp/pmods/org.openbravo.retail.testsampledata).
![]() | org.openbravo.retail.sampledata and org.openbravo.test.mobile.sampledata are branches of the same module (they have the same AD_MODULE_ID) so they MUST NOT be used together. |
Setting Up the Automated Test Environment
Assuming we will be working with the pi-mobile repository to execute the tests, the following steps must be followed:
Clone these repositories in your projects directory https://gitlab.com/openbravo/ci/mobile-test Do not place it inside an openbravo directory. The automation makes use of a running ERP, not its sources.
From this point there are 2 ways of configuring the automation context. The script is still not working for Oracle, so you should execute it and then manually fix the database references
1a. The scripted way: - Navigate to the root of the local pi-mobile - Execute the setup.py file pointing to the openbravo directory of the context that will be tested
e.g:
[openbravo@ManjaroPC pi-mobile]$ python3 setup.py /home/openbravo/clones/tip/openbravo *** tool to configure Retail automation context v0.3 *** copying .classpath.template » .classpath copying config/OpenbravoERPTest.properties.template » config/OpenbravoERPTest.properties copying config/log4j.properties.template » config/log4j.properties database = obtip new tomcat log path: /tmp/tip/tomcat.log last results path: /tmp/tip/ *** end ***
1b. The Manual way:
- Rename/copy the .classpath.template file to .classpath
- Rename/copy config/OpenbravoERPTest.properties.template to config/OpenbravoERPTest.properties
- Rename/copy config/log4j.properties.template to config/log4j.properties
- verify that the config/OpenbravoERPTest.properties has the correct database credentials (bbdd.sid, ...). These credentials must match the values of the openbravo server database.
- In order to run the tests on a Java 7 machine:
Open the .classpath file and find the following line:
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
Replace the line with:
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
2. Add autodiscovering of the hamcrest imports. This will add intellisense entries when adding assertThat code
-. Add these favorite imports in Window » Preferences » Java » Editor » Content Assist » Favorites
- org.hamcrest.CoreMatchers
- org.hamcrest.Matchers
- org.hamcrest.MatcherAssert</nowiki>
Running Selenium
There are several ways of starting a Selenium server. It can be used locally (within the same machine as the Openbravo server) or on a different computer (remotely).
Local execution of Selenium.
Selenium can be run locally in two different ways. The easiest way is to change to the seleniumTools/ directory and run one of the standalone scripts. If the server is running but an exception is thrown every time a test is run, check if the exception mentions a missing chromedriver. If that’s the case, open the lib/test/ folder, copy the name of one of the chromedrivers there, edit the script used to start selenium and set the correct webdriver.chrome.driver parameter.
A second option to start Selenium locally is to run ant selenium.start from the test repo root. The chromedriver and seleniumdriver versions used will be taken from the OpenbravoERPTest.properties file.
![]() | In a modules environment it is required to remove the following file
modules/org.openbravo.certification.france/src/org/openbravo/certification/france/ticket/TicketInitialValidation.java |
Remote execution of Selenium
![]() | We need 2 test repos for this execution tipe; one on the openbravo server (for the test files) and one on the remote computer (for the selenium files). |
In order to execute Selenium in a different computer, we need to use the hub.sh and nodes.sh scripts.
On the remote computer (the one holding Selenium), open the nodes.json configuration file and change the host and hubHost values to 127.0.0.1.
Launch hub.js
Launch nodes.js
Write down the IP of the selenium-holding computer to configure the test repo.
On the local computer (the one with the openbravo server), open the OpenbravoERPTest.properties file and change the selenium.server property to the IP of the remote computer.
Open the ConfigurationProperties.java file, find the following line:
return openbravoBaseURLTemp.replace(localhostReferenceToChange, ip.getHostAddress());
And change it to
return openbravoBaseURLTemp.replace(localhostReferenceToChange, "local_ip_as_seen_on_the_lan");
local_ip_as_seen_on_the_lan is the IP of the computer with the openbravo server.
Now when a test is executed the browser will run on the remote machine. In order to run a test, simply right click on it and select Debug As > JUnit Test.
After finishing the tests, remember to terminate the Selenium server (either Ctrl+C the process, or run ant selenium.stop if ant was used to start the server).
Local Offline Execution
Setup offline execution
First of all, you need to install and configure different components. You will need to install Apache:
sudo apt-get install apache2 libapache2-mod-jk
Then you have to edit or create /etc/apache2/conf-available/openbravo-jk-mount.conf adding this content:
JkMount /* ajp13_worker jkMountCopy all
This will redirect all petitions from Apache to Tomcat, to enable this configuration:
sudo a2enconf openbravo-jk-mount.conf
Finally, to be able to start/stop Apache from the tests, you need to execute these instructions without typing the root’s password. To make it possible, you have to edit sudoers file in order to grant the access. It can be done by using:
sudo su - echo "openbravo ALL = NOPASSWD: /etc/init.d/apache2" > /etc/sudoers.d/97-ob-apache #Note: this command works for openbravo user, if you have a different user, replace it in previous line.
Now you can start/stop Apache manually through:
sudo /etc/init.d/apache2 {start | stop}
Note: It should not ask for password.
Configuration and how to use offline
Note: If using the scripts no needed to do this part
After completing all these steps, you only have to edit the OpenbravoERPTest.properties and remove the port from openbravo.url:
# Openbravo server properties openbravo.url=http://localhost/
All the test using offline features need to be included in the class AllowedErrorsHelper inside the method getTestsAllowedToHaveJavascriptErrors and the method getTestsAllowedToHaveTomcatErrors.
In the tests you can use these methods to go online and offline:
goOffline(); goOnline();
Note: this methods are defined in WebPOSTerminalHelper so should be available in all terminals.
Trick to test quick updates
Prerequisite to have configured the offline execution with apache.
To move quickly between two workspaces, for example when testing the update from one version to the other.
A trick could be create a script to change the port that uses mod-jk to connect apache to tomcat, for these needed to do these steps:
- Configure the second workspace tomcat to use other ports like : 8180, 8105 and 8109
- Add these alias to .bashrc:
alias s1='sudo sed -i /etc/libapache2-mod-jk/workers.properties -e '\s/8109/8009/'\ && sudo /etc/init.d/apache2 restart' alias s2='sudo sed -i /etc/libapache2-mod-jk/workers.properties -e '\s/8009/8109/'\ && sudo /etc/init.d/apache2 restart'
With this you can switch to workspace using these commands:
s1 // configure apache to use the first tomcat s2 // configure apache to use the second tomcat
The application will be allways available at http://localhost/openbravo (no need to specify port, it will use default one :80 in which apache is listening)
Test Folder Structure
The tests are divided into two main subgroups. Those tests belonging to the package org.openbravo.test.mobile.retail.pack (“pack” tests) are the tests being run on the ret-*-test-* jobs, while the tests belonging to the org.openbravo.test.mobile.retail.extmodules package are the ones executed on ret-*-modules-* jobs.
Adding new tests to the “pack” tests
In order to add a new test to the pack tests, pick the most fitting area (returns, cashup, sales,...) and create a new java file there. Find a test of the same area and copy&paste it for a quick start. As long as the new test is inside an existing category, there is a mechanism that will automatically add that test to the respective suite when the suite is executed.
Adding a new test to the "modules" tests
The modules test are organized by module. Each module has its own suite. Unlike the pack tests, there isn’t a mechanism to add all the tests of a module into the suite; this process needs to be done manually. So for every new test added, it must be added to the corresponding suite manually.
Creating a new test
As already explained, the basic flow to create a test is copy&paste an existing similar test, and, using that as a base, add our test actions. This is done to ensure that the correct test class is extended: pack tests extend WebPOSTerminalHelper, while modules tests extend WebPOSExtModulesTerminalHelper (if they are POS tests) or other different terminals (procurement, mobile warehouse).
The TestId.java holds a mapping between the POS elements (buttons, labels, popups, messages, ...) and a unique name to be used within the tests. Each POS element is identified by a unique idtest[*]. This idtest is obtained on the browser console, using the TestRegistry javascript object. If we open the browser console and execute TestRegistry.appendIdTestToDOM() each element currently existing on the POS will be assigned an idtest property (if applicable). This idtest can be used on the TestId java class to identify the element.
[*]Note that due to some TestRegistry limitations, some elements can’t be assigned a unique idtest and therefore cannot be directly used from the tests.
Using a POS element in our test
Firstly we go to the POS, open the browser console and recover the idtest property of the element we want to use.
Then we go to the TestId class and look for our idtest. If it exists, we can al ready use the TestId.OUR_ELEMENT_NAME. If not, we create it.
Always try to create new TestIds near related TestIds. The syntax to create new TestId elements is: OUR_ELEMENT_NAME(“idtest”, [EnyoKind]).
EnyoKind is a helper class used to identify special elements (buttons, product rows,...). Go to the EnyoKind class to check all the available options.
Fixing an Unstable test
There are some tests that fails randomly and they are marked as "unstable" in the Test Status sheet(Google Spreadsheet). Follow these steps to fix an unstable test:
- Create an issue setting these fields at least:
- Category: Tests Stabilization
- Summary: Test name
- Description: The whole error of the test
- Upload file: Test Screenshot
- Proposed Solution: Explain the cause of the error and how it will be fixed
- Set the column issue in the Google Spreadsheet for the row of the test you are fixing
- Fix the issue and push it. Do not forget to fill Proposed Solution field and to put a full description in the commit. If you changed the java class of the test, it will be promoted to quarantine automatically, if not, you need to set its column "status" to quarantine in the Google Spreadsheet.
- You need to check the e-mail sent automatically where failed tests are listed to check if your test is still unstable or not.
For any suggestion/help go directly to retail team.
Actions that can be performed on TestId elements
Currently tap, write, verify and get operations are supported.
- Tap is used to simulate a mouse click on an element.
- Write is used to write/set content on labels or input fields.
- Verify is used to compare the content of an element with a given text.
- Get is used to recover the String content of an element.
Finally, the TestRegistry can also be used to get the enyoObject of an element on the browser console: TestRegistry.registry(‘idtest’).enyoObject
High volume automated test
Starting from RR15Q4, to support high volumes of products, customers and tickets, Openbravo Commerce allows you to work remotely with master data from the WebPOS client. The high volume master data is then not loaded into the WebPOS client database but accesses when needed on a server. The server can be a locally in-store server or a server available in the cloud.
To run a test in remote or high volume mode it is necessary to add the following annotation in the java class test:
public class HighVolumeTest extends WebPOSTerminalHelper { @TestClassAnnotations(isHighVolumeCompatible = true)
When a test is running in high volume mode there is a method called "verifyHgvolTime" which checks that a specific action takes no more than some specific time, and the test fails if it takes too long. "verifyHgvolTime" function is called inside each "tap" action.
Hybrid remote automated test
Starting from RR18Q4, tests can activate some of high volumes preference to automate some scenarios which are not exactly a "pure" high volumes test.
To run a test with hybrid remote configuration it is necessary to implement in each java test class:
- Test class annotation to indicate the test is remote model compatible:
- @TestClassAnnotations(isRemoteModelsCompatible = true)
- Override function activateRemoteModels and return an array of string with remote models to enable. The possible values are:
- "REMOTEORDER"
- "REMOTEDISCOUNTBP"
- "REMOTEPRODUCT"
- "REMOTECUSTOMER"
The preference defined for the test are set after the first login and are unset after the end of the test. If the testClassAnnotation is present but the activateRemoteModels method is not overrided or the array of remote model is null or is an empty array, the test will fail and will not be executed.
Other important topics to consider
The Constants.java file defines several values used all around the test project, such as timeouts or retry values.
Sometimes a test will fail because certain element hasn’t reached the required state. In this cases, increasing the WAIT_DEFAULT_RETRIES might work. Other interesting values to tweak might be:
- WAIT_FORDATABASESYNCHRONIZATION: Defines, in milliseconds, how much will we wait before querying the server database.
- WAIT_AFTERLOGOUT: Defines, in milliseconds, how much we will wait after logging out to check if we are on the login screen. Too low values will cause the logout to get stuck in a (tap menu > tap logout > logout) cycle and the test might eventually fail.
- TEST_TIMEOUT: This is the global timeout for the test, in seconds.
- JAVASCRIPT_POLLING_INTERVAL: In milliseconds, the delay before sending each javascript command to the browser. increasing it will slow down the tests considerably.
- WAIT_POLLING_INTERVAL: In milliseconds, pause between each “check” to verify if an element exists.
Although the tests are prepared to be run with the application in development status (there is a test verifying that) they can be executed with the application in production (no modules in development).
If the tests fail because a javascript error regarding the Synchronization Helper and the dropTables process, it means that the dropTables process is taking more than 8 seconds, which is not necessarily wrong. Open the ob-synchronization.js file (in the org.openbravo.mobile.core module), find the following lines:
OB.UTIL.Debug.execute(function () { // the timeout is forced active while in development to catch unbalanced calls and/or adjust the timeoutThreshold timeoutThreshold = 8000; isTimeoutThresholdActivated = true; });
and increase the timeoutThreshold value. Increasing this value will reduce the amount of “false failures” and will only slow the application in case of a real error (which should never happen anyway).
Authentication Managers and the tests
The authentication manager feature is not compatible with the tests. Firstly, it might try to login with wrong credentials (e.g. wrong POS organization). Besides, the first step of the tests is to automate the login, so they will fail if the login has already been done.
Throttle and the tests
After throttle changes random tests fail in try-retail, not able to fix all of them, we opted to disable the throttle in all ci servers.
This is just a workaround and plan is to enable again as soon as possible.
For the moment, to make a try-retail run with the throttle enabled is needed to use an extra param ACTIVATE_THROTTLE=true in the push a try-retail.
For more details this is the issue: https://issues.openbravo.com/view.php?id=37416
Howto add a new module to the Retail Integration
First: create a new json copy of the try-retail one, plus your new module and push to try-retail.
After test it, for put in production it is needed to update 3 jsons:
- old try-retail : https://code.openbravo.com/erp/devel/try-mods/config/file/tip/temp-try-retail.json
- new try-retail : https://gitlab.com/openbravo/ci/context_definitions/-/blob/master/retail/try-retail.json
- mod-retail : https://gitlab.com/openbravo/ci/context_definitions/-/blob/master/retail/retail.json
Ensure that each json format is correct after edit, passing a json formater.
IMPORTANT
- If this is a contribution of some functionality which will be maintained from now on by a different team (like the product team), it's very important to send an email to the Release Management team so that the ownership of the module is updated.
- Update the list of modules which is present in this wiki page
How to add a new junit to retail
If it is a junit for the pack can be executed in try-retail, but if it needs the external modules, for the moment can not be executed in try-retail and can be only executed in mod-retail.
To add a junit suite to mod-retail:
- It needs to be added to this file: https://code.openbravo.com/erp/devel/try-mods/config/file/default/retail_junit.sh
Check list of actions on release package
- NOTE: these steps are for when publishing a new normal release, not an emergency one (so only do these steps in 18q1, but no in 18q1.1 or 18q1.2)
- RM will send an email with the list of modules to publish
- Publish the modules
- Create the json of the release (in erp/devel/try-mods/config)
- Copy it from the previous release ( Example: when creating 18q1 copy from 17q4)
- Update the json with the modules of the RM mail, maybe needed to add the module or just update the version
- Save in the json the current versions of the external modules sampledatas:
- org.openbravo.test.mobile.sampledata
- org.openbravo.retail.testsampledata
- Save in the json the current version of all the modules set as dependency
- "deps" in the json
Add new tables to sample data
When a new feature is developed, a common requirement while developing a set of automatic tests is to create new sample data for tables added by the new feature.
Here you can find the steps required to add new tables to the sample data.
Logged as system administrator:
- Open "Module" window and mark module "Core" as "In development"
- Open Dataset Window and search the dataset by "Client definition"
- Open it in form view and change the value of the property "Data Access Level" from "System Only" to "Client/organization"
- Having "Client definition" selected move to the tab "Table"
- Add new registry with the new table
- Remember to set the value of the "Module" property with the module which is owner of that table
- Property "HQL/SQL Where clause" should have the following value "client.id=:ClientID"
- In general, all the columns of the table will be added to the sample data so we will check the property "Include All Columns". In the strange case that you don't want to include all the columns in the sample data then this check will be unmarked and columns should be specified in "Column" child tab
- Repeat step 5 until you have added all of your tables.
- Return to the header "Client definition" and revert the change done in step 3
- Return to "Modules" window and revert the change done in step 1
- Stop tomcat
- Finally, Execute
ant export.database
Once executed, check changes in your module's file "src-db/database/sourcedata/AD_DATASET_TABLE.xml" and push your changes
Now you can create new data in the new tables and then execute "export" commands which are explained below.
Export retail sampledata
- Pack
ant export.sample.data -Dclient="The White Valley Group" -Dmodule=org.openbravo.retail.sampledata
- Modules
ant export.sample.data -Dclient="The White Valley Group" -Dmodule=org.openbravo.test.mobile.sampledata ant export.sample.data -Dclient="Retail Test" -Dmodule=org.openbravo.retail.testsampledata
- Pos2
# Download: # dbsourcemanager.jar # sampleDataExtension.diff cd ~/Documents/workspaces/<name_of_workspace>/openbravo cp ~/Downloads/dbsourcemanager.jar src-db/database/lib/dbsourcemanager.jar patch -p1 < ~/Downloads/sampleDataExtension.diff ant export.sample.data.extension -DdataSetName="POS2 SampleData" -Dclient="The White Valley Group" -Dmodule=org.openbravo.pos2.sampledata
Setup SSL
For retail is mandatory to use always ssl, only exception is localhost (or 127.*.*.*)
For testing is posible to use the self signed certificate created by apache on install, to do that:
first step, do the apache setup sudo a2enmod ssl sudo a2ensite default-ssl.conf sudo /etc/init.d/apache2 restart
The URL for access with ssl: https://ip/... (note that is not needed to specify a port)
Setup axisc3 for development
axisc3 guide: http://wiki.openbravo.com/wiki/Retail:AXISC3_Payment_Provider
- Clone modules:
- dt fix-classpath
- ant update.database compile.complete.deploy
- Clone also the plugin of hwmanager, outside of modules:
- go to the repo, ant plugin
- copy the jar generated to the libext of hardwaremanager
- cp openbravohw-axisc3/plugin/* openbravo/modules/org.openbravo.retail.poshwmanager/bin/libext/
- start the hardwaremanager
- configure the touchpoint:
- url of hw: http://localhost:8090/printer
- axisc3:
- interface: simulator
- host: localhost
- port: any with the sim doesn't matter (9518 for example)
- terminal id: any of 8 digits, with the sim doesn't matter (12345678 for example)
- In the touchpoint type,
- go to payments , and in card,
- go to payment provider and create a new one
- provider: AXISC3 Card Provider
- name: whatever, for example axisc3
- go back to card payment provider
- select the new payment provider just created
- payment method: the one you want to capture, if choose undefined will capture all
- go to payment provider and create a new one
- go to payments , and in card,
Changing the API - Procedure
When you change the name of a column, the java property name of a column or the method name of a public method in our system you are effectively changing the public api. Our ci-build will catch this change and report a failure.
The following page describes the procedure to follow when changing the api and adapt the ci-build api check for the changed api.
Simulate scanner
With API
OB.App.BarcodeScanner.scanCode("1234")
With external app
To install it:
sudo apt install autokey-gtk
We will create a new phrase in My Phrases by clicking the top New button. This will prompt us for a name, it is not important, as it will only be used for the final filename. On the right, there’s a text area where we can input some test, we will use it to input the code we want to be simulated as a scan event. For example, in the above screenshot we see “140200 3479255 25” as an example scan code, and we will set the dropdown “Paste using” as Keyboard.
Finally, we should assign a Hotkey on the keyboard to run this macro for us on press. To do that, click on Set on the row where it says Hotkey, bottom right part of the UI.
If you want to learn more about autokey-gdk, take a look at their github documentation: https://github.com/autokey/autokey
Simulate incremental refresh
- pos1:
- https://issues.openbravo.com/view.php?id=41027
- OB.UTIL.loadModelsIncFunc()
- OB.UTIL.checkRefreshMasterData():
- Pos2:
- https://gitlab.com/openbravo/product/pmods/org.openbravo.core2/-/merge_requests/294
- await OB.App.MasterdataController.incrementalRefreshTimer()
- await OB.App.MasterdataController.forceTimer()
Query to detect repetitive messages in terminal log
-- Show also processes (slower query) select count(1) as times, loglevel, CASE WHEN strpos(msg, 'http') <> 0 THEN SUBSTRING(msg, 0, position('http' in msg)) ELSE SUBSTRING(msg, 0, position(' - ' in msg)) END as msgStr from obmobc_logclient where -- Be careful with the tstamp interval as there are lots of records and query might not finish tstamp::numeric < (extract(epoch FROM '2022-07-02 23:00:00'::timestamp) * 1000)::numeric and tstamp::numeric > (extract(epoch FROM '2022-07-02 05:00:00'::timestamp) * 1000)::numeric -- Possible filter by deviceid that will use the index -- and upper(deviceid) = upper('XXXX') group by msgStr, loglevel order by times desc --setting a limit to avoid bringing lots of data limit 500 ;
Hardware Manager Config
In ERP, in channel-touchpoint window, set Hardware URL to : http://localhost:8090/printer
In modules/org.openbravo.retail.poshwmanager/bin:
./start.sh
If needed a pdf printer
Edit in the bin folder the openbravohw.properties
Uncomment the
machine.printer.2 = printer\:(Default),standard
In ubuntu also needed to install a printer to pdf
sudo apt install printer-driver-cups-pdf
Also it is needed to set this printer as default