View source | Discuss this page | Page history | Printable version   

Retail:Developers Guide/How-to/How to Install, Setup and Run Retail Automated Tests

Contents

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.

Bulbgraph.png   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.

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
  1. Right click / preferences
  2. In profiles, on left menu, click on the '+' to add a new profile
  3. Name: zsh
  4. Optional: probably you want to uncheck the terminal bell
  5. Optional: if you want the terminal with white background, you can go to colors tab and uncheck "use colors from system theme"
  6. Move to command tab
  7. Click to check "run a custom command instead of my shell"
  8. Write in "custom command": zsh
  9. Go to scrolling tab, set scroll limit to 1000000
  10. On the left menu, in zsh profile, click in the down arrow
  11. Select: set as default

https://drive.google.com/file/d/1_ciU8TZlXSd45xmLowQfh92lyhrOy7Ny/view?usp=sharing

mv Downloads/p10k.zsh .p10k.zsh
# optionally, later you can do your own config running: p10k configure (in a new terminal)
# 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.

sudo apt install vim
:set nofixendofline
sudo update-alternatives --config editor

Chrome

This is the supported browser, so its installation is mandatory

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.
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.

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 postgresql-12
sudo -u postgres psql -c "alter user postgres with password 'syspass';"
sudo -u postgres psql --port 5433 -c "alter user postgres with password 'syspass';"
# 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'

# 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
sudo cp /etc/postgresql/10/main/conf.d/01-openbravo-standard-postgres9.5.conf /etc/postgresql/10/main/conf.d/91-local-changes.conf /etc/postgresql/12/main/conf.d/
sudo /etc/init.d/postgresql restart

PostgreSQL clients

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

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

sudo apt install openjdk-11-jdk
sudo sh -c 'echo "JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64" >> /etc/environment'

Note: change only be effective after restart

Ant

sudo apt install ant
sudo sh -c 'echo "export ANT_OPTS=\"-Xmx1024M\"" >> /etc/environment'


Tomcat

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
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

sudo apt-get install apache2 libapache2-mod-jk
JkMount /* ajp13_worker
jkMountCopy all
sudo a2enconf openbravo-jk-mount
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
sudo a2enmod ssl
sudo a2ensite default-ssl.conf
sudo /etc/init.d/apache2 restart
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/httpd-jk.conf .
  <Connector protocol="AJP/1.3"
              address="127.0.0.1"
              port="8009"
              secretRequired="false"
              redirectPort="8443" />

Git

sudo apt install git
git config --global pull.ff only

You can follow these steps, if you don't have yet a ssh key you can follow this guide to create one.

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"

After setup the dt scripts you can add the githooks.

Optional git config

Aliaes
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

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:

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

# snapshots after run tests
web-jspack/*/__snapshots__/
git config --global core.excludesfile ~/.gitignore

Node and npm

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

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
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse
Exec=eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false


If you have already cloned the openbravo repos, this is the guide for the workspace setup.

Visual Code

https://go.microsoft.com/fwlink/?LinkID=760868
sudo apt install./<file>.deb
sudo sh -c "echo fs.inotify.max_user_watches=524288 >> /etc/sysctl.conf"
sudo sysctl -p


Workspace config file

Workspaces done by dt scripts will already have this file, this is ONLY needed for workspaces done manually:

dt fix-vscode-workspace-file

Execute test file after edit it

  "saveAndRun": {
       "commands": [
           {
               "match": ".test.",
               "cmd": "npm run test ${file}",
               "useShortcut": false,
               "silent": false
           },
       ]
   }

dt scripts setup

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
# 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
cp devtools.config.template devtools.config
mkdir /home/openbravo/Documents/workspaces
sudo apt install python3-tqdm

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)

Bulbgraph.png   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

# 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)

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
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

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)
# 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

:set nofixendofline
syntax on

Chrome

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

PostgresSQL clients

export PATH="$PATH:/Applications/Postgres.app/Contents/Versions/10/bin"

Java

Guide extracted from: https://sdkman.io/install

curl -s "https://get.sdkman.io" | bash
PATH="$PATH:$SDKMAN_CANDIDATES_DIR/$candidate/current/bin"
echo "$PATH" | grep -q "$candidate_dir" || PATH="${PATH}:${candidate_bin_dir}"
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 11.0.2-open
cd ~/Documents
ln -s /Users/openbravo/.sdkman/candidates/java/current/ java
# 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!
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

Ant

sdk install ant
export ANT_OPTS="-Xmx1024M"

Tomcat

sdk list tomcat  # select the last minor of 8.5
sdk install tomcat 8.5.60
cd ~/Documents
ln -s /Users/openbravo/.sdkman/candidates/tomcat/current 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.

<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>
sudo mkdir /etc/init.d
#!/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
sudo chmod +x /etc/init.d/apache2
openbravo ALL = (ALL)  NOPASSWD: /usr/sbin/apachectl
openbravo ALL = (ALL)  NOPASSWD: /etc/init.d/apache2

Git

git config --global pull.ff only

You can follow these steps, if you don't have yet a ssh key you can follow this guide to create one.

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"

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

https://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools
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 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

# Mac
.DS_Store

# snapshots after run tests
web-jspack/*/__snapshots__/
git config --global core.excludesfile ~/.gitignore

Node and npm

Eclipse

export PATH="$PATH:/Users/openbravo/Applications/Eclipse.app/Contents/MacOS"

Chromedriver

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

If using dt scripts to build the environment, this will be already added

chromedriverPath=/Users/openbravo/Documents/chromedrivers/chromedriver-default
forceUrl=http://localhost/

VSCode

Other Mac Specific

Fix home and end shortcut

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
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
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

dt scripts setup

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
# 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
cp devtools.config.template devtools.config
mkdir /Users/openbravo/Documents/workspaces
sudo -H pip3 install tqdm

Githooks

git config --global core.hooksPath /Users/openbravo/Documents/retail_scripts/githooks

VisualCode configuration

VSCode Extensions

Important : eslint first time a project is opened ask if you trust, and you have to click to trust to execute eslint.


###
 NEVER install Java VSCode extension 
It will ask the first time that you open a java file to install it,
but if you do, it will figth with the autocompile of eclipse and will break the workspace,
till the point that the easy fix is to delete the workspace and create again.
###

Recommended shortcuts


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

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 setup-workspace --type-enyopos --name <name_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 setup-workspace --type-enyopos-modules --name <name_workspace>

Workspace of modules linked to a pack workspace

 dt setup-workspace --type-enyopos --name <name_pack_workspace>
 dt setup-workspace --type-enyopos-modules --link-to-pack <name_pack_workspace>

This creates a normal pack workspace, and in the modules workspace create links for:

So changes done in the pack in any of the workspaces is directly done in the other.

Useful for:

Known issue:

Workspace of backports

Pos2 pack:

dt setup-workspace --type-pos2 --name 23Q2
gitr checkout relese/23Q2

Pos2 modules:

dt setup-workspace --context-definition retail/pos-modules-23Q2 --name 23Q2

EnyoPos pack:

dt setup-workspace --type-enyopos --name 20Q3 --context-definition retail/try-retail-20Q3

EnyoPos modules:

dt setup-workspace --context-definition retail/try-retail-20Q3 --name 20Q3 

EnyoPos modules linked:

dt setup-workspace --context-definition retail/try-retail-20Q3 --link-to-pack 20Q3

context_definitions

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 setup-workspace --type-pos2 --name <workspace_name>

With restaurant and other modules:

dt setup-workspace --type-pos2-modules --name <workspace_name>

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:

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 setup-workspace
   --context-definition-from-snapshot /home/openbravo/snapshots/mycustomersnapshot
   --name <workspace_name>
   --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'

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

Push to try-pos2

run-try.py --pos2 --desc push-description

Personal forks

In general you should never use personal forks, only branches in devel repos!!

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:

dt redistribute-suites retail-html-path: /home/openbravo/retail.html

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:

tar czf eclipse.tgz Servers/ RemoteSystemsTempFiles/ .metadata/
mv eclipse.tgz $(which dt | sed 's/dt$//')

Compare commits between two executions of ci

  1. Obtain the json used to build the job, depending of the job:
  1. Once obtained the json of the green build, save in a file, ex: buidl1.json
  2. Next get the json of the execution that has fail and save in another file, ex: build2.json
  3. The in the terminal execute:
dt compare-ci-jsons --json1-path buidl1.json --json2-path build2.json
  1. you will get a link per repo that has changes, to see in gitlab the commits introduced between both executions

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


Devel branches

The idea in openbravo that for each development it is created a devel branch.

For example to do a fix in pos2, we have in the local workspace a clone of org.openbravo.pos2 repo, with this remotes:

grv
origin	git@gitlab.com:openbravo/product/pmods/org.openbravo.pos2 (fetch)
origin	git@gitlab.com:openbravo/product/pmods/org.openbravo.pos2 (push)

We should add the devel remote:

dt add-dev
# manually it should be: git add remote dev git@gitlab.com:openbravo/devel/pmods/org.openbravo.pos2
grv
dev	git@gitlab.com:openbravo/devel/pmods/org.openbravo.pos2 (fetch)
dev	git@gitlab.com:openbravo/devel/pmods/org.openbravo.pos2 (push)
origin	git@gitlab.com:openbravo/product/pmods/org.openbravo.pos2 (fetch)
origin	git@gitlab.com:openbravo/product/pmods/org.openbravo.pos2 (push)


And we should create a branch for the development, if an issue fix/XXXXX-desc if it is a new feature request fr/XXXX-desc (with the XXXX the number of the issue in mantis):

dt add-dev --branch fr/XXXX-desc
# it is equal to command: gco -b fr/XXXX-desc
git branch -vv
* fr/XXXX-desc                 7dc3efd6a [] Fixed ISSUE-52526: Prevent cancel an order that is fully delivered
  master                       7dc3efd6a [origin/master] Fixed ISSUE-52526: Prevent cancel an order that is fully delivered


After create the branch and before create commits it is a good practice to set the upstream and create the MR

git push -u dev
# In the message of the push it will show the URL to create the MR
git branch -vv
* fr/XXXX-desc                 7dc3efd6a [dev/fr/XXXX-desc] Fixed ISSUE-52526: Prevent cancel an order that is fully delivered
  master                       7dc3efd6a [origin/master] Fixed ISSUE-52526: Prevent cancel an order that is fully delivered

In this way the git push and git pull of this branch will track the remote one without need to specify the dev branch:

Developers cheatsheet

dt setup-workspace --type-pos2 --name test
dt add-new-modules-to-workspace --type-pos2
gitr pull
cd module_to_develop
dt add-dev --branch MR1
git push -u dev
# In the push message there is a link to create the MR
gfa
git rebase orgin/master
git push --force-with-lease
# The rest of repos can be updated with a gitr pull
run-try.py --retail --desc push-description
run-try.py --pos2 --desc push-description
gfa
git rebase orgin/master
git push --force-with-lease
gco master
git pull
git merge --no-ff mr_name
# git push, but before review that all is ok
# delete the branch in the gitlab interface
# In general for small issues not needed to create the new commit of merge, and usually it is better to merge in the gitlab interface and use the squash commits option

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:


Ensure that each json format is correct after edit, passing a json formater.


IMPORTANT

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:

Check list of actions on release package

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:

  1. Open "Module" window and mark module "Core" as "In development"
  2. Open Dataset Window and search the dataset by "Client definition"
  3. Open it in form view and change the value of the property "Data Access Level" from "System Only" to "Client/organization"
  4. Having "Client definition" selected move to the tab "Table"
  5. Add new registry with the new table
    1. Remember to set the value of the "Module" property with the module which is owner of that table
    2. Property "HQL/SQL Where clause" should have the following value "client.id=:ClientID"
    3. 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
  6. Repeat step 5 until you have added all of your tables.
  7. Return to the header "Client definition" and revert the change done in step 3
  8. Return to "Modules" window and revert the change done in step 1
  9. Stop tomcat
  10. 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

ant export.sample.data -Dclient="The White Valley Group" -Dmodule=org.openbravo.retail.sampledata
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
# 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

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

Masterdata Refresh

Simulate incremental refresh

Force full refresh

OB.UTIL.localStorage.setItem('MasterdataLastTotalRefresh', 0)

Then f5 or logout/login.


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

Eclipse variables too big

Open DebugShell and execute this: new org.openbravo.utils.FileUtility("/tmp", "varaible.json").StringToFile(variableWithAJson.toString())

Old topics

http://wiki.openbravo.com/wiki/Retail:Developers_Guide/How-to/How_to_Install,_Setup_and_Run_Retail_Automated_Tests_OBSOLETE

Retrieved from "http://wiki.openbravo.com/wiki/Retail:Developers_Guide/How-to/How_to_Install,_Setup_and_Run_Retail_Automated_Tests"

This page has been accessed 29,446 times. This page was last modified on 11 September 2023, at 12:54. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.