Skip to content

Instantly share code, notes, and snippets.

@DaGeRe
Last active November 12, 2024 21:42
Show Gist options
  • Select an option

  • Save DaGeRe/4c9a22b8e5593d88bea350d480597921 to your computer and use it in GitHub Desktop.

Select an option

Save DaGeRe/4c9a22b8e5593d88bea350d480597921 to your computer and use it in GitHub Desktop.
Run the t2 project locally

Running t2 Project Locally

The following describes the steps that are needed to run the t2 store locally. Before you start, please install the following things:

  • A recent JDK (17 or above)
  • Developer tools like git, wget, etc.
  • Apache JMeter (wget https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.6.3.tgz && tar -xvf apache-jmeter-5.6.3.tgz, now you can start JMeter using java -jar apache-jmeter-5.6.3/bin/ApacheJMeter.jar)
  • Please download the project using git clone --recurse-submodules -j8 https://github.com/t2-project/t2-project.git and please replace the modulith submodule be its fork: cd t2-project/modulith/ && git remote add fork https://github.com/DaGeRe/t2-modulith.git && git pull fork with-mysql && git checkout with-mysql

Start MongoDB

  • If you have a system that is capable of running docker: docker run --name mongodb -d -p 27017:27017 mongo
  • Otherwise, start the tarball locally:
    • Download the appropriate version (https://www.mongodb.com/try/download/community-edition/releases), for example on Ubuntu 20.04: wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-8.0.1.tgz
    • Unzip and open (tar -xvf mongodb-linux-x86_64-ubuntu2004-8.0.1.tgz && cd mongodb-linux-x86_64-ubuntu2004-8.0.1)
    • Create a data folder (e.g., mkdir data/db -p)
    • Start MongoDB using this folder: ./bin/mongod --dbpath ./data/db

Start MariaDB

  • If you have a system that is capable of running docker
    • Start the database:: docker run --name mariadb-container -e MARIADB_ROOT_PASSWORD=my-secret-pw -p 3306:3306 -d mariadb:11.4.3
    • Create the user mysql -P 3306 -uroot -pmy-secret-pw --execute="CREATE USER 't2project'@'%' IDENTIFIED BY 't2project';"
    • Create the database: mysql -P 3306 -uroot -pmy-secret-pw --execute="CREATE DATABASE t2db;"
    • Give the user the rights: mysql -P 3306 -uroot -pmy-secret-pw --execute="GRANT ALL PRIVILEGES ON t2db.* TO 't2project'@'%';"
  • Otherwise, start the tarball locally:
    • Download the appropriate version (e.g., wget https://ftp.agdsn.de/pub/mirrors/mariadb/mariadb-11.4.3/bintar-linux-systemd-x86_64/mariadb-11.4.3-linux-systemd-x86_64.tar.gz)
    • Unzip and open (tar -xvf mariadb-11.4.3-linux-systemd-x86_64.tar.gz && cd mariadb-11.4.3-linux-systemd-x86_64)
    • Initialize the folder: ./scripts/mysql_install_db --user=$(whoami) --datadir=$(pwd)/data
    • Start the server: bin/mysqld --user=$(whoami) --datadir=$(pwd)/data --socket=/home/$(whoami)/mariadb.sock
    • Create the user bin/mysql -S /home/$(whoami)/mariadb.sock --execute="CREATE USER 't2project'@'localhost' IDENTIFIED BY 't2project';"
    • Create the database: bin/mysql -S /home/$(whoami)/mariadb.sock --execute="CREATE DATABASE t2db;"
    • Give the user the rights: bin/mysql -S /home/$(whoami)/mariadb.sock --execute="GRANT ALL PRIVILEGES ON t2db.* TO 't2project'@'localhost';"

Start the creditinstitute

To start the creditinstitute backend:

  • Change to its folder and build it: cd microservices/creditinstitute/ && ../mvnw clean package
  • Start it using the following one-liner: export T2_JAEGER_ENABLED="FALSE"; export T2_JAEGER_HOST="localhost"; java -jar target/creditinstitute-1.3.1-SNAPSHOT.jar --server.port=8087

Start the Modulith (Main Application)

  • cd t2-project/modulith/ && ./mvnw clean package -DskipTests
  • Export the necessary variables:
export MONGO_HOST="localhost"
export T2_CART_TTL="0"
export T2_CART_TASKRATE="0"
export T2_INVENTORY_SIZE="25"
export T2_INVENTORY_TASKRATE="0"
export T2_INVENTORY_TTL="0"
export T2_INVENTORY_SET_UNITS_TO_MAX="FALSE"
export T2_PAYMENT_PROVIDER_DUMMY_URL="http://localhost:8087/pay"
export T2_PAYMENT_PROVIDER_TIMEOUT=5
export T2_PAYMENT_PROVIDER_ENABLED=true
export T2_COMPUTATION_SIMULATOR_ENABLED="false"
export T2_COMPUTATION_SIMULATOR_PI_TOTAL_POINTS=100000000
export SPRING_DATASOURCE_DRIVER_CLASS_NAME="org.mariadb.jdbc.Driver"
export SPRING_DATASOURCE_USERNAME="t2project"
export SPRING_DATASOURCE_PASSWORD="t2project"
export SPRING_DATASOURCE_URL="jdbc:mariadb://localhost:3306/t2db"
export SPRING_PROFILES_ACTIVE="prod"
  • Start the jar: java -jar target/t2-modulith.war
  • Check the availability of the UI in http://localhost:8080/ui

Start the Load Test

To start the load test, make sure JMeter is downloaded and extracted to JMETER_HOME.

Afterwards, call $JMETER_HOME/bin/jmeter.sh -Jhostname=localhost -Jport=8080 -JnumExecutions=100 -n -t t2-project-flexible.jmx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment