macOS and IntelliJ Ultimate Edition


Pre-Requisites

  • OS: macOS / Linux
  • IDE: IntelliJ IDE Editor - Ultimate Edition

Pre-Requisite Software and Service Installation

  • Open JDK 11
  • npm and nodejs (>= 12)
  • Apache httpd
  • mysql5.7

Java JDK

  • Download the Java JDK 11 from the following link,

  • Once it is installed, you can type the java -version in the terminal to confirm if the Java installation is successful.
  • Set env path in zshrc profile.

    • Open the terminal and type vi ~/.zshrc
    • Enter the below to set the path and save it.
    • Export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home

Node js

  • Down the node from the following link:

  • Once it is installed, you can type node -v in the terminal to confirm if the node installation is successful.

Apache httpd

  • Install apache httpd via Homebrew.
  • Make sure Xcode is installed on your mac (install it via AppStore or https://developer.apple.com/downloads)
  • To Install brew, open your terminal and type in:

    /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
  • Next, to install apache httpd, type in:

    brew install httpd
  • To start the httpd service, type in:

    sudo brew services start httpd 

MySQL

  • Install MySQL via Homebrew as well.
  • To install:

    brew install mysql@5.7
  • After installation, set the path in the bash profile.

    • In the terminal type, vi ~/.zshrc
    • Paste export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"
  • Start the mysql server using:

    brew services start mysql@5.7
  • The default username and password for the MySQL connection is “root”. You can connect to MySQL using:

    mysql -u root -p
  • A prompt to enter the password will be shown. You can type in “root” again.

Setup

  • Download the source from GitHub: git clone https://github.com/Testsigmahq/testsigma and place it on your system. The downloaded source will have the below folders.

    • agent
    • agent-launcher
    • automator
    • deploy
    • server
    • ui
  • Now, open IntelliJ IDE and create a new JAVA project.
  • The next step is to import the automator, agent, agent launcher, server, and ui as individual modules in the project created.
  • How to import modules in IntelliJ IDE:

    • Go to File → Project structure
    • In the Project structure window, you can see modules under the project settings section.
    • Click on the modules tab and click the + icon and select import module. Import Module
    • Now select each folder i.e. automator, agent, agent-launcher, server, ui, and import them.
    • While importing modules (automator, agent, agent-launcher, server), select the option Import module from external module and then choose Maven and click on create. Maven
    • Only while importing ui as a module, choose the option Create module from existing sources and click on Next.

      • The framework will be detected as angular
      • Click on Create Framework
  • Build each module using the command mentioned, in the following order:

    • automator: mvn clean install
    • agent: mvn clean install
    • agent-launcher: mvn clean install
    • server: mvn clean install
    • ui: npm install
  • Downloading required tools:

    • Create a folder testsigma_os in the home directory. This can be done by running the below command from the terminal:

      mkdir $HOME/.testsigma_o
    • Download the Android, Appium, JRE, and iOS tools from this URL and store them in the above folder created. Make sure you extract the zip and place the contents in the folder created. For mac Os you need to give explicit permission to remove the quarantine attribute. You can do this by running,

      sudo xattr -d -r com.apple.quarantine $HOME/.testsigma_os/
    • Also, if you have already downloaded the Testsigma Agent, you can copy Android, Appium, drivers, and iOS and put the same on testsigma_os.
  • HTTPD Config Changes:

    • From the finder window on Mac, press command+shift+g and mention the path opt/homebrew/etc/httpd
    • Create a new file called testsigma-os.conf. Enter the below contents in it and save the file.

      RewriteEngine On
      RewriteCond %{HTTP_HOST} "devos.testsigma.com"
      RewriteCond %{REQUEST_URI} "^/ui/"
      RewriteRule .* http://localhost:4202%{REQUEST_URI} [P]
      #ProxyPassReverse .* "http://devos.testsigma.com/ui"
      RewriteCond %{HTTP_HOST} "devos.testsigma.com"
      RewriteCond %{REQUEST_URI} "^/assets/"
      RewriteRule .* http://localhost:4202%{REQUEST_URI} [P]
      #ProxyPassReverse .* "http://devos.testsigma.com/assets"
      RewriteCond %{HTTP_HOST} "devos.testsigma.com"
      RewriteRule .* http://localhost:9090%{REQUEST_URI} [P]
      #ProxyPassReverse .* "http://devos.testsigma.com/"
      RewriteCond %{HTTP_HOST} "devos.testsigma.com"
      RewriteCond %{REQUEST_URI} "^/ui"
      RewriteRule .* http://localhost:4202%{REQUEST_URI} [P]
      #ProxyPassReverse .* "http://devos.testsigma.com/ui"
  • Open httpd.conf present in the same path and add the below content at the bottom of the file and save it.

    • Include /opt/homebrew/etc/httpd/testsigma-os.conf
  • Restart the httpd services using the following command from the terminal

    • brew services restart httpd

Setting up UI, Server, and Agent component as a service

Once the above configuration is done, we need to add UI, Server, and Agent as a service so that the entire application runs.

  • Setting up server component as a service:

    • Go to Run → Edit Configurations.
    • Select + Icon in the Run/Debug Configurations window.
    • Select Sprint Boot as the configuration type.
    • Enter the name as server.
    • Select Java 11 as the JDK version and testsigma-agent as the classpath.
    • Enter com.testsigma.agent.TestsigmaWebApplication as the class to be compiled.
    • If the Environment Variables field is not visible, Click the Modify option and select Environment Variables.

      • Enter the below values for Environment Variables.

        TESTSIGMA_SERVER_URL=http://devos.testsigma.com;TS_DATA_DIR=/Users/{USERHOMEDIR}/Documents/server-os-data
      • TS_DATA_DIR is a temp folder to store data. so, you can create one and mention the path of the folder above.

        NOTE:

        Replace {USERHOMEDIR} with your home directory name.

    • Click Ok
    • The server module is added as a service now.
    • Reference: Reference
  • Setting up agent component as a service:

    • Go to Run → Edit Configurations.
    • Select + Icon in the Run/Debug Configurations window.
    • Select Sprint Boot as the configuration type.
    • Enter the name as agent.
    • Select Java 11 as the JDK version and testsigma-agent as the classpath.
    • Enter com.testsigma.agent.TestsigmaAgent as the class to be compiled.
    • Add VM options from Modify options if it's not visible and add the Virtual Machine agents in the below format.

      -DTS_DATA_DIR="/Users/{USERHOMEDIR}/Library/Application Support/Testsigma/Agent"
      -DTS_ROOT_DIR="/Users/{USERHOMEDIR}/.testsigma_mac"
      -DCLOUD_URL="http://devos.testsigma.com/"
      NOTE:

      Replace {USERHOMEDIR} with your home directory name

    • Click Ok
    • The agent module is added as a service now.
    • Reference: Rerun/Debug
  • Setting ui agent component as a service:

    • Go to Run → Edit Configurations.
    • Select + Icon in the Run/Debug Configurations window.
    • Select npm as the configuration type.
    • Enter the name as ui.
    • For package.json: select the package.json file present in the ui folder from the downloaded source.
    • Select run for command and start for Scripts. UI
    • Click Ok
    • ui is added as a service now.
  • Running the application as a service:

    • You can now start the services one by one from the services tab in IntelliJ.

      • ui
      • server
      • agent Services
  • Mapping localhost to devos.testsigma.com:

    • From the finder window on Mac, press command+shift+g and mention the path private/etc/hosts
    • Open the hosts file and add an entry as below:

      127.0.0.1       devos.testsigma.com
  • You can now access the server at http://devos.testsigma.com/ui/ Access Testsigma