From 4a2146b941d02f9f4f5dac7bcb67a48ec0dfe4c5 Mon Sep 17 00:00:00 2001 From: aayushRedHat Date: Mon, 15 Jan 2024 22:27:04 +0530 Subject: [PATCH 1/3] Update testing --- test/test-project/docker-compose.yml | 2 ++ test/test-project/package.json | 9 ++--- test/test-project/test-registry.test.js | 4 +-- test/test-project/test.sh | 47 +++++++------------------ 4 files changed, 18 insertions(+), 44 deletions(-) diff --git a/test/test-project/docker-compose.yml b/test/test-project/docker-compose.yml index c537ae8f0..a73f2e9a6 100644 --- a/test/test-project/docker-compose.yml +++ b/test/test-project/docker-compose.yml @@ -14,6 +14,8 @@ services: test-project: privileged: true image: "node:${NODE_IMAGE_TAG}" + extra_hosts: + - "host.docker.internal:host-gateway" environment: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true volumes: diff --git a/test/test-project/package.json b/test/test-project/package.json index 8ffae277f..5b1252017 100644 --- a/test/test-project/package.json +++ b/test/test-project/package.json @@ -9,17 +9,12 @@ }, "dependencies": { "@asyncapi/generator": "file:../..", - "@asyncapi/html-template": "0.16.0" - + "@asyncapi/html-template": "^0.16.0" }, "devDependencies": { "fs-extra": "9.1.0", "jest": "25.5.0", - "rimraf": "3.0.2", - "autoprefixer": "^10.2.1", - "postcss-cli": "^8.3.1", - "puppeteer": "^5.3.1", - "tailwindcss": "^2.0.2" + "rimraf": "3.0.2" }, "jest": { "moduleNameMapper": { diff --git a/test/test-project/test-registry.test.js b/test/test-project/test-registry.test.js index 80af37ce9..eb2f8ea5e 100644 --- a/test/test-project/test-registry.test.js +++ b/test/test-project/test-registry.test.js @@ -16,7 +16,7 @@ describe('Integration testing generateFromFile() to make sure the template can b return path.resolve(mainTestResultPath, crypto.randomBytes(4).toString('hex')); }; - jest.setTimeout(600000); + jest.setTimeout(6000000); it('generated using private registory', async () => { const outputDir = generateFolderName(); @@ -29,7 +29,7 @@ describe('Integration testing generateFromFile() to make sure the template can b singleFile: true }, registry: { - url: 'http://127.0.0.1:4873', + url: 'http://host.docker.internal:4873', // Replace the host.docker.internal to localhost for testing without docker auth: 'YWRtaW46bmltZGE=' // base64 encoded username and password represented as admin:nimda } diff --git a/test/test-project/test.sh b/test/test-project/test.sh index 4b8a47d59..bbd289ea6 100644 --- a/test/test-project/test.sh +++ b/test/test-project/test.sh @@ -1,40 +1,17 @@ #!/bin/bash -# Function to install and test a specific project -function test_project { - - npm run test:project - # Installing html template globally before global tests - PUPPETEER_SKIP_DOWNLOAD=true npm install -g @asyncapi/html-template@0.16.0 - # Remove previously installed html template to make sure it is not picked up in the test - rm -rf node_modules/@asyncapi/html-template - rm -rf ../../node_modules/@asyncapi/html-template - npm run test:global -} - -# Function to test the registry -function test_registry { - npm run test:registry -} - -# Required by GitHub Actions +#required by GitHub Actions sudo chown -R 1001:121 "/root/.npm" - -# Always run these steps cd app -PUPPETEER_SKIP_DOWNLOAD=true npm install +npm install cd test/test-project -PUPPETEER_SKIP_DOWNLOAD=true npm install - - -# Run the functions based on the provided arguments -case "$1" in - "test-project") - test_project - test_registry - ;; - *) - echo "Invalid argument. Supported arguments: test-project" - exit 1 - ;; -esac \ No newline at end of file +PUPPETEER_SKIP_DOWNLOAD=true npm install @asyncapi/html-template@0.16.0 +npm install +npm run test:project +#installing html template globally before global tests +PUPPETEER_SKIP_DOWNLOAD=true npm install -g @asyncapi/html-template@0.16.0 +#remove previously installed html template to make sure it is not picked up in the test +rm -rf node_modules/@asyncapi/html-template +rm -rf ../../node_modules/@asyncapi/html-template +npm run test:global +npm run test:registry \ No newline at end of file From 652754e65ecfd01c216dbfd2dbb67461d993d82c Mon Sep 17 00:00:00 2001 From: aayushRedHat Date: Wed, 17 Jan 2024 15:19:49 +0530 Subject: [PATCH 2/3] Update testing --- test/test-project/docker-compose.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test-project/docker-compose.yml b/test/test-project/docker-compose.yml index a73f2e9a6..852cd320d 100644 --- a/test/test-project/docker-compose.yml +++ b/test/test-project/docker-compose.yml @@ -20,8 +20,7 @@ services: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true volumes: - ../../:/app - command: bash /app/test/test-project/test.sh test-project | bash /app/test/test-project/test.sh test-registry - + command: bash /app/test/test-project/test.sh networks: mynetwork: From 0d2e51fc6c0db1eedac1382b0945c718ea69fcb6 Mon Sep 17 00:00:00 2001 From: aayushRedHat Date: Wed, 17 Jan 2024 15:23:42 +0530 Subject: [PATCH 3/3] changed testing --- test/test-project/Dockerfile | 10 ++++++++++ test/test-project/docker-compose.yml | 18 ++++++++++++------ test/test-project/test.sh | 1 - .../verdaccio/{ => conf}/config.yaml | 4 ++-- .../test-project/verdaccio/{ => conf}/htpasswd | 0 5 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 test/test-project/Dockerfile rename test/test-project/verdaccio/{ => conf}/config.yaml (70%) rename test/test-project/verdaccio/{ => conf}/htpasswd (100%) diff --git a/test/test-project/Dockerfile b/test/test-project/Dockerfile new file mode 100644 index 000000000..61ad23bb9 --- /dev/null +++ b/test/test-project/Dockerfile @@ -0,0 +1,10 @@ +FROM verdaccio/verdaccio:5 + +# Copy your Verdaccio configuration file to the container +ADD ./verdaccio/conf /verdaccio/conf:z + +# Change ownership of the directory without using sudo +USER root +RUN chown -R 100:101 /opt/verdaccio +RUN chmod -R 777 /verdaccio +USER $VERDACCIO_USER_UID diff --git a/test/test-project/docker-compose.yml b/test/test-project/docker-compose.yml index 852cd320d..6e87f3a65 100644 --- a/test/test-project/docker-compose.yml +++ b/test/test-project/docker-compose.yml @@ -2,26 +2,32 @@ version: '3' services: verdaccio: - image: verdaccio/verdaccio:5 + build: . container_name: 'verdaccio' + extra_hosts: + - "host.docker.internal:host-gateway" ports: - '4873:4873' volumes: - - './verdaccio:/verdaccio/conf' + - './verdaccio/conf:/verdaccio/conf:z' + - './verdaccio/storage:/verdaccio/storage:z' networks: - mynetwork + test-project: privileged: true - image: "node:${NODE_IMAGE_TAG}" + image: "node:16" extra_hosts: - "host.docker.internal:host-gateway" environment: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true volumes: - ../../:/app - command: bash /app/test/test-project/test.sh - + command: bash /app/test/test-project/test.sh test-project + networks: + - mynetwork + networks: mynetwork: - driver: bridge \ No newline at end of file + driver: bridge diff --git a/test/test-project/test.sh b/test/test-project/test.sh index bbd289ea6..997932310 100644 --- a/test/test-project/test.sh +++ b/test/test-project/test.sh @@ -7,7 +7,6 @@ npm install cd test/test-project PUPPETEER_SKIP_DOWNLOAD=true npm install @asyncapi/html-template@0.16.0 npm install -npm run test:project #installing html template globally before global tests PUPPETEER_SKIP_DOWNLOAD=true npm install -g @asyncapi/html-template@0.16.0 #remove previously installed html template to make sure it is not picked up in the test diff --git a/test/test-project/verdaccio/config.yaml b/test/test-project/verdaccio/conf/config.yaml similarity index 70% rename from test/test-project/verdaccio/config.yaml rename to test/test-project/verdaccio/conf/config.yaml index 1be0f5f12..7860ab94a 100755 --- a/test/test-project/verdaccio/config.yaml +++ b/test/test-project/verdaccio/conf/config.yaml @@ -1,4 +1,4 @@ -storage: ./storage +storage: ../storage auth: htpasswd: file: ./htpasswd @@ -10,4 +10,4 @@ packages: "**": access: admin proxy: npmjs -log: { type: stdout, format: pretty, level: debug } \ No newline at end of file +log: { type: stdout, format: pretty, level: debug } diff --git a/test/test-project/verdaccio/htpasswd b/test/test-project/verdaccio/conf/htpasswd similarity index 100% rename from test/test-project/verdaccio/htpasswd rename to test/test-project/verdaccio/conf/htpasswd