msp2 v1.1.30
MSP
Folder Structure
A top-level directory layout
.
├── apps # Related sub-applications / microservices
│ ├── user # User (end-user)/Reader related apps
│ └── publisher # Publisher/Our client related apps
│ ├── api #
│ └── ... #
│ ├── src # Source files
│ └── test # Automated tests
│ └── ... # Same folder structure as the top-level layout in `/apps`
│ ├── consumers # Consumers from kafka topics
├── lib # Tools, utilities and 3rd party connections
├── infra # Configurations and scripts for infrastructure environment
│ └── ... # Same folder structure as the top-level layout in `/apps`
└── README.md
Getting Started
Before you start
To ensure you have file permissions in order to perform actions, and to have proper integration for git commands
Make sure you clone this project from GitHub using SSH (and not using git clone with user/password, or downloading a zip file manually). More information about GitHub SSH integration
For a first time installation, make sure to run every command you can as the regular user, and without elevated privileges (sudo root user).
Yarn
MSP project is using yarn as its package manager tool.
Make sure yarn is installed on your development environment npm install -g yarn
.
Then verify that yarn was installed correctly by running the following command yarn -v
expect version 2.3.2
.
First time installation
To install all project dependencies and create a complete local environment (steps 1-7):
- Install Pulsar C++ client libraries Pulsar C++ client
sudo apt install ./infra/extra/apache-pulsar-client*.deb
- Install the following packages (Prerequisite installations before running)
- docker container manager
- helm charts package manager
- kubectl k8s command-line tool
- MiniKube a local k8s cluster
Navigate to /infra/charts folder
NOTE: When running Minikube on Ubuntu a docker driver must be specified:
minikube config set driver docker
sudo usermod -aG docker $USER && newgrp docker
Run the 2 commands specified in the start.sh
script file, one after the other:
minikube start...
followed byhelm...
Run the following commands to validate everything is up and running:
minikube status
- will print minikube current statusminikube dashboard
- will open k8s dashboard for MSP development server (it is recommended to wait for all resources to turn 'green' (ready) before moving on to the next step)
- Navigate to /apps folder
- Run the following command
yarn install
- Test
- To run all tests in MSP project simply run
yarn test:all
from root folder.
Build MSP packages
yarn install
on /apps folder will install all project dependencies.
To install specific package (aka workspace) navigate to the package folder and run yarn workspaces focus
.
You can also install a package from the root folder using yarn workspace <workspaceName> install
(e.g. yarn workspace @msp/user-api install
).
After restart
- After restarting the computer you must run
minikube start
under the /infra/charts folder - Make sure to give everything some time to load and run. You can use the minikube dashboard, and some database client to make sure everything is ready
Run tests
MSP unit tests are working with a local storage installations (such as PostgresDB, Redis and Apache Pulsar). There a quickstart setup to deploy all required storage component using a k18s cluster.
Prerequisite installations before running unit tests:
- docker container manager
- helm charts package manager
- kubectl k8s command-line tool
- MiniKube a local k8s cluster
NOTE: When running Minikube on Ubuntu a docker driver must be specified:
minikube config set driver docker
sudo usermod -aG docker $USER && newgrp docker
Start minikube
- navigate to 'apps' folder
- run the following commands:
yarn minikube:start
will install MSP development server dependencies (On the first time all dependencies will be installed)yarn minikube:status
will print minikube current statusyarn minikube:stop
will stop MSP development serveryarn minikube:delete
will clean and delete local k8s serveryarn minikube:dashboard
will open k8s dashboard for MSP development serveryarn minikube:pause
will pause MSP development serveryarn minikube:unpause
will cancel pause (unpause) MSP development server
To run all tests in MSP project simply run yarn test:all
from root folder.
In order to run specific package tests run yarn workspace <workspaceName> test
(e.g. yarn workspace @msp/user-api test
).
Add dependencies
To add a package dependency to a package (aka workspace), navigate to the package directory and run yarn add <dependencyPackageName --cached
.
e.g. yarn add -D mocha --cached
will add mocha
package as a devDependency while checking the highest available mocha version in the entire MSP project.
More details about yarn add command can be found here.
Remove dependencies
To remove a package dependency from a package (aka workspace), navigate to the package directory and run yarn remove <dependencyPackageName>
.
e.g. yarn remove 'jeeng-redis'
will remove jeeng-redis
package.
More details about yarn remove command can be found here.
Add a new application
To add a new application into msp, navigate to apps/package.json and add to the 'workspaces' section the name of your application. e.g. "admin/*" NOTE - make sure you don't have extra spaces at the name of the application (it will raise an error of yarn issue).
Common issues
Problem: Unexpected reserved word in 'msp/apps/.yarn/releases/yarn-2.3.2.cjs'
Solution: run
nvm use v12
Read application specific information
Publisher:
User