-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added makerfile to make local e2e test a breeze
added makerfile to make local e2e test a breeze: working improved maker file structure with output logs for debug purpose
- Loading branch information
Showing
5 changed files
with
1,155 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,7 @@ lerna-debug.log* | |
!.vscode/extensions.json | ||
|
||
# misc | ||
/.silent-pay-indexer | ||
/.silent-pay-indexer | ||
|
||
#e2e | ||
/e2e/.logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Variables | ||
DOCKER_COMPOSE_FILE = helpers/docker/docker-compose.yml | ||
NESTJS_SERVICE_PORT = 3000 | ||
INDEXER_TEST_CMD = npm run test:e2e | ||
MAX_RETRIES = 10 # Number of retries to check if the inddexer service is up | ||
RETRY_INTERVAL = 5 # Seconds between retries | ||
PM2_CMD = npx pm2 | ||
NPM_CMD = npm | ||
APP_NAME = silent-indexer | ||
LOG_DIR = .logs | ||
INDEXER_OUTPUT_LOG = $(LOG_DIR)/$(APP_NAME)-out.log | ||
INDEXER_ERROR_LOG = $(LOG_DIR)/$(APP_NAME)-error.log | ||
|
||
# Targets | ||
.PHONY: all start-bitcoind start-indexer setup test clean | ||
|
||
# Default target | ||
all: setup test | ||
@$(MAKE) clean | ||
|
||
# Start Docker Compose services | ||
start-bitcoind: | ||
@echo "Starting Docker Compose services..." | ||
docker compose -f $(DOCKER_COMPOSE_FILE) up -d | ||
|
||
# Start the Indexer service | ||
start-indexer: | ||
@echo "Starting the Indexer service with PM2..." | ||
$(PM2_CMD) start $(NPM_CMD) --name $(APP_NAME) --output $(INDEXER_OUTPUT_LOG) --error $(INDEXER_ERROR_LOG) -- run start:e2e | ||
|
||
# Wait for the Indexer service to be available before running tests | ||
setup: start-bitcoind start-indexer | ||
@echo "Waiting for Indexer service to be ready on port $(NESTJS_SERVICE_PORT)..." | ||
@count=0; \ | ||
while ! nc -z localhost $(NESTJS_SERVICE_PORT) && [ $$count -lt $(MAX_RETRIES) ]; do \ | ||
count=$$((count + 1)); \ | ||
echo "Waiting for service... ($$count/$(MAX_RETRIES))"; \ | ||
sleep $(RETRY_INTERVAL); \ | ||
done; \ | ||
if ! nc -z localhost $(NESTJS_SERVICE_PORT); then \ | ||
echo "Error: Service not available after $(MAX_RETRIES) retries, exiting."; \ | ||
exit 1; \ | ||
fi | ||
|
||
# Run the end-to-end tests | ||
test: | ||
@echo "Running end-to-end tests..." | ||
$(INDEXER_TEST_CMD) || echo "Warning: E2E tests failed, but continuing..." | ||
|
||
# Stop all services and delete all files | ||
clean: | ||
@echo "Stopping and removing Docker Compose services..." | ||
docker compose -f $(DOCKER_COMPOSE_FILE) down -v | ||
$(PM2_CMD) delete $(APP_NAME) || echo "Warning: PM2 delete command failed, but continuing..." | ||
@echo "Clean up completed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# End-to-End Testing Setup | ||
|
||
This guide explains how to run end-to-end (E2E) tests for our Silent Indexer application using a `Makefile`. The steps include installing `make`, setting up PM2, and executing the tests. | ||
|
||
## Prerequisites | ||
|
||
- Node.js and npm must be installed on your machine. You can download them from [Node.js official website](https://nodejs.org/). | ||
|
||
## Step 1: Install `make` | ||
|
||
### On Linux | ||
|
||
Most Linux distributions come with `make` pre-installed. If not, you can install it using your package manager. | ||
|
||
For **Debian/Ubuntu**: | ||
|
||
```bash | ||
sudo apt-get update | ||
sudo apt-get install make | ||
``` | ||
|
||
## Step 2: Install Dependencies | ||
|
||
1. Run the following command to install the npm dependencies specified in package.json: | ||
|
||
```bash | ||
npm install | ||
``` | ||
This command will download all the packages listed in dependencies and devDependencies from the npm registry. | ||
|
||
|
||
## Step 3: Run e2e | ||
Ensure you are in __e2e__ directory and that port 3000 is free. | ||
|
||
1. **Run the following command** to run e2e test using make: | ||
|
||
```bash | ||
make | ||
``` |
Oops, something went wrong.