Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
target/*
target/*
.direnv
.envrc
.vscode
node_modules
package-lock.json
package.json
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ remote-token=eyJraWQiOiIyYzVkMTJmNC02NmQzLTQxMzYtODJiZC00YWFkN2JiY2Q3YjkiLCJhbGc
all: build run

build:
mvn clean install
mvn clean package

run:
docker compose up
Expand Down
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
# Template Micro Integrator for Visual Studio Code
This is a sample project for the WSO2 Micro Integrator

Build with Maven:
### Build

mvn clean install
- Build car with Maven: `mvn clean package`
- Run on Docker: `docker-compose up`
- Call the Demo API: `curl -k https://localhost:8243/health`

Run on Docker:
### Test

docker-compose up
HttpYac is used to test the Micro Integrator and the tests are automatically run with `docker compose up`. However you can also manually run the tests with:

Call the Demo API
```bash
docker run -it --rm -v $(pwd)/src/test/httpyac:/app/httpyac httpyac:5.8.2 \
"httpyac" -a -o short -e docker
```

curl http://localhost:8280/health
See the
[Test with HttpYac](https://integon.gitlab.io/docs/wiki/wso2/1.0.0/test-with-httpyac.html)
for more details on how this works.


### Makefile

# Makefile
## Build

make build
Expand Down
22 changes: 21 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
version: '3.3'
services:
mi-template:
image: "wso2/wso2mi:4.1.0"
image: "docker.io/wso2/wso2mi:4.1.0-multiarch"
#image: "docker.wso2.com/wso2mi:latest"
ports:
- "8280:8280"
- "8243:8243"
- "9191:9191"
- "9154:9154"
healthcheck:
test : [ "CMD", "curl", "-f", "http://localhost:9191/healthz" ]
interval : 1s
timeout : 2s
retries : 3
start_period: 5s

volumes:
- ./target/capp:/home/wso2carbon/wso2mi-4.1.0/repository/deployment/server/carbonapps
- ./mi-home/conf/deployment.toml:/home/wso2carbon/wso2mi-4.1.0/conf/deployment.toml

test:
build:
context: .
dockerfile: docker/test/Dockerfile
volumes:
- ./src/test/httpyac:/app/httpyac
command: ["httpyac", "-a", "-o", "short", "-e", "docker-compose" ]
depends_on:
mi-template:
condition: service_healthy


File renamed without changes.
6 changes: 6 additions & 0 deletions docker/test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:16-alpine
USER node
ENV NODE_ENV=production
WORKDIR /app
RUN npm install httpyac@5.8.2 chai@4.3.7
ENTRYPOINT [ "npx", "httpyac" ]
42 changes: 42 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
description = "mi-template-dev-shell";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachSystem
[
"x86_64-darwin"
"aarch64-darwin"
"x86_64-linux"
]
(system:
let pkgs = import nixpkgs { inherit system; };
in
{
devShell = pkgs.mkShell
{
buildInputs = with pkgs;
[
openjdk11
nodejs
kustomize
docker
docker-compose
colima
(maven.override { jdk = openjdk11; })
];
};
}
);
}
1 change: 1 addition & 0 deletions src/test/httpyac/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
request_rejectUnauthorized=false
1 change: 1 addition & 0 deletions src/test/httpyac/env/docker-compose.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MI_HOST=mi-template
1 change: 1 addition & 0 deletions src/test/httpyac/env/docker.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MI_HOST=host.docker.internal
1 change: 1 addition & 0 deletions src/test/httpyac/env/local.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MI_HOST=127.0.0.1
45 changes: 45 additions & 0 deletions src/test/httpyac/health.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@host=https://{{MI_HOST}}:8243

/*
Simple health test without any dependencies
*/
GET /health
{{
test.status(200);
test.hasResponseBody();
}}

###

/*
Health test with header checking without any dependencies
*/
GET /health
{{
test.status(200);
test.hasResponseBody();
test.header("Content-Type", "application/json; charset=UTF-8");
}}

###

/*
Health test with chai dependency for more complex tests. This test does not
work inside the httpYac VSCode extension unless you have chai installed with npm.
In the Docker image, however, chai is already installed and the test will work.
*/
GET /health
{{
// standard test without dependencies
test.status(200);
test.hasResponseBody();
test.header("Content-Type", "application/json; charset=UTF-8");

// additional javascript specific test using the specialized chai library
const expect = require('chai').expect;
test('Status should be "UP"', () => {
expect(response.parsedBody.Status).to.equal('UP');
});
}}