Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-38543 - synced release branch with develop branch #1054

Open
wants to merge 3 commits into
base: release-1.3.x
Choose a base branch
from
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 15 additions & 15 deletions .github/workflows/push-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ jobs:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

build-maven-apitest-pms:
uses: mosip/kattu/.github/workflows/maven-build.yml@master
uses: mosip/kattu/.github/workflows/maven-build.yml@master-java21
with:
SERVICE_LOCATION: ./apitest
SERVICE_LOCATION: ./api-test
BUILD_ARTIFACT: apitest-pms
secrets:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
Expand All @@ -103,9 +103,9 @@ jobs:
publish_to_nexus_apitest_pms:
if: "${{ !contains(github.ref, 'master') && github.event_name != 'pull_request' && github.event_name != 'release' && github.event_name != 'prerelease' && github.event_name != 'publish' }}"
needs: build-maven-apitest-pms
uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master
uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master-java21
with:
SERVICE_LOCATION: ./apitest
SERVICE_LOCATION: ./api-test
secrets:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }}
Expand All @@ -120,15 +120,15 @@ jobs:
env:
NAMESPACE: ${{ secrets.dev_namespace_docker_hub }}
SERVICE_NAME: apitest-pms
SERVICE_LOCATION: apitest
SERVICE_LOCATION: api-test
BUILD_ARTIFACT: apitest-pms-local
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
ref: ${{ github.ref }}
java-version: 11
distribution: 'temurin'
java-version: 21
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Setup the settings file for ossrh server
Expand Down Expand Up @@ -165,13 +165,13 @@ jobs:
strategy:
matrix:
include:
- SERVICE_LOCATION: 'apitest'
- SERVICE_LOCATION: 'api-test'
SERVICE_NAME: 'apitest-pms'
BUILD_ARTIFACT: 'apitest-pms-local'
ONLY_DOCKER: true
fail-fast: false
name: ${{ matrix.SERVICE_NAME }}
uses: mosip/kattu/.github/workflows/docker-build.yml@master
uses: mosip/kattu/.github/workflows/docker-build.yml@master-java21
with:
SERVICE_LOCATION: ${{ matrix.SERVICE_LOCATION }}
SERVICE_NAME: ${{ matrix.SERVICE_NAME }}
Expand All @@ -186,14 +186,14 @@ jobs:
sonar_analysis_apitest_pms:
needs: build-maven-apitest-pms
if: "${{ github.event_name != 'pull_request' }}"
uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master
uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master-java21
with:
SERVICE_LOCATION: ./apitest
SERVICE_LOCATION: ./api-test
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
ORG_KEY: ${{ secrets.ORG_KEY }}
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
GPG_SECRET: ${{ secrets.GPG_SECRET }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
File renamed without changes.
21 changes: 10 additions & 11 deletions apitest/Dockerfile → api-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:11
FROM mosipid/openjdk-21-jre:21.0.4

ARG SOURCE
ARG COMMIT_HASH
Expand Down Expand Up @@ -28,22 +28,21 @@ WORKDIR /home/${container_user}

ENV work_dir=/home/${container_user}

ADD ./apitest/target/ $work_dir

ADD entrypoint.sh $work_dir/entrypoint.sh
# Combine all necessary files into a single COPY command
COPY ./api-test/target $work_dir/
COPY entrypoint.sh $work_dir

# install packages and create user
RUN apt-get -y update \
&& apt-get install -y unzip jq \
&& apt-get install -y unzip jq curl \
&& groupadd -g ${container_user_gid} ${container_user_group} \
&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \
&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/bash -m ${container_user} \
&& curl -LO "https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" \
&& mkdir -p /home/${container_user} \
&& chmod +x kubectl $work_dir/entrypoint.sh \
&& chown -R ${container_user}:${container_user} /home/${container_user} /usr/local/openjdk-11/lib/security/cacerts \
&& chmod 644 /usr/local/openjdk-11/lib/security/cacerts \
&& mv kubectl /usr/local/bin/

#ADD ./testNgXmlFiles/ $work_dir/testNgXmlFiles/
&& mv kubectl /usr/local/bin/ \
&& chown -R ${container_user}:${container_user} /home/${container_user} /etc/ssl/certs/java/cacerts \
&& chmod 644 /etc/ssl/certs/java/cacerts

# select container user for all tasks
USER ${container_user_uid}:${container_user_gid}
Expand Down
169 changes: 169 additions & 0 deletions api-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Partner Management Services API Test Rig

## Overview

The **Partner Management Services API Test Rig** is designed for the execution of module-wise automation API tests for the partner management services. This test rig utilizes **Java REST Assured** and **TestNG** frameworks to automate testing of the partner management API functionalities. The key focus is to validate the policy creation, partner creation and related functionalities provided by the partner management module.

---

## Test Categories

- **Smoke**: Contains only positive test scenarios for quick verification.
- **Regression**: Includes all test scenarios, covering both positive and negative cases.

---

## Coverage

This test rig covers only **external API endpoints** exposed by the partner management services module.

---

## Pre-requisites

Before running the automation tests, ensure the following software is installed on the machine:

- **Java 21** (or a compatible version)
- **Maven 3.9.6** (or higher)
- **Lombok** (Refer to [Lombok Project](https://projectlombok.org/))
- **setting.xml** ([download here](https://github.com/mosip/mosip-functional-tests/blob/master/settings.xml))
- **apitest-commons** library should be cloned and the JAR should be built. Refer to ([README](https://github.com/mosip/mosip-functional-tests/blob/release-1.3.0/apitest-commons/README.md))

### For Windows

- **Git Bash 2.18.0** or higher
- Ensure the `settings.xml` file is present in the `.m2` folder.

### For Linux

- The `settings.xml` file should be present in two places:
- In the regular Maven configuration folder (`/conf`)
- Under `/usr/local/maven/conf/`

---

## Access Test Automation Code

You can access the test automation code using either of the following methods:

### From Browser

1. Clone or download the repository as a zip file from [GitHub](https://github.com/mosip/partner-management-services).
2. Unzip the contents to your local machine.
3. Open a terminal (Linux) or command prompt (Windows) and continue with the following steps.

### From Git Bash

1. Copy the Git repository URL: `https://github.com/mosip/partner-management-services`
2. Open **Git Bash** on your local machine.
3. Run the following command to clone the repository:
```sh
git clone https://github.com/mosip/partner-management-services
```

---

## Build Test Automation Code

Once the repository is cloned or downloaded, follow these steps to build and install the test automation code:

1. Navigate to the project directory:
```sh
cd api-test
```

2. Build the project using Maven:
```sh
mvn clean install -Dgpg.skip=true -Dmaven.gitcommitid.skip=true
```

This will download the required dependencies and prepare the test suite for execution.

---

## Execute Test Automation Suite

You can execute the test automation code using either of the following methods:

### Using Jar

To execute the tests using Jar, use the following steps:

1. Navigate to the `target` directory where the JAR file is generated:
```sh
cd target/
```

2. Run the automation test suite JAR file:
```
java -jar -Dmodules=partner -Denv.user=api-internal.<env_name> -Denv.endpoint=<base_env> -Denv.testLevel=smokeAndRegression -jar apitest-partner-1.3.0-SNAPSHOT-jar-with-dependencies.jar
```

# Using Eclipse IDE

To execute the tests using Eclipse IDE, use the following steps:

## 1. **Install Eclipse (Latest Version)**
- Download and install the latest version of Eclipse IDE from the [Eclipse Downloads](https://www.eclipse.org/downloads/).

## 2. **Import the Maven Project**

After Eclipse is installed, follow these steps to import the Maven project:

- Open Eclipse IDE.
- Go to `File` > `Import`.
- In the **Import** wizard, select `Maven` > `Existing Maven Projects`, then click **Next**.
- Browse to the location where the `api-test` folder is saved (either from the cloned Git repository or downloaded zip).
- Select the folder, and Eclipse will automatically detect the Maven project. Click **Finish** to import the project.

## 3. **Build the Project**

- Right-click on the project in the **Project Explorer** and select `Maven` > `Update Project`.
- This will download the required dependencies as defined in the `pom.xml` and ensure everything is correctly set up.

## 4. **Run the Tests**

To execute the test automation suite, you need to configure the run parameters in Eclipse:

- Go to `Run` > `Run Configurations`.
- In the **Run Configurations** window, create a new configuration for your tests:
- Right-click on **Java Application** and select **New**.
- In the **Main** tab, select the project by browsing the location where the `api-test` folder is saved, and select the **Main class** as `io.mosip.testrig.apirig.partner.testrunner.MosipTestRunner`.
- In the **Arguments** tab, add the necessary **VM arguments**:
- **VM Arguments**:
```
-Dmodules=partner -Denv.user=api-internal.<env_name> -Denv.endpoint=<base_env> -Denv.testLevel=smokeAndRegression```

## 5. **Run the Configuration**

- Once the configuration is set up, click **Run** to execute the test suite.
- The tests will run, and the results will be shown in the **Console** tab of Eclipse.

**Note**: You can also run in **Debug Mode** to troubleshoot issues by setting breakpoints in your code and choosing `Debug` instead of `Run`.

## 6. **View Test Results**

- After the tests are executed, you can view the detailed results in the `api-test\testng-report` directory.

---

## Details of Arguments Used

- **env.user**: Replace `<env_name>` with the appropriate environment name (e.g., `dev`, `qa`, etc.).
- **env.endpoint**: The environment where the application under test is deployed. Replace `<base_env>` with the correct base URL for the environment (e.g., `https://api-internal.<env_name>.mosip.net`).
- **env.testLevel**: Set this to `smoke` to run only smoke test cases, or `smokeAndRegression` to run both smoke and regression tests.
- **jar**: Specify the name of the JAR file to execute. The version will change according to the development code version. For example, the current version may look like `apitest-partner-1.3.0-SNAPSHOT-jar-with-dependencies.jar`.

### Build and Run Info

To run the tests for both **Smoke** and **Regression**:

1. Ensure the correct environment and test level parameters are set.
2. Execute the tests as shown in the command above to validate partner management services API functionalities.

---

## License

This project is licensed under the terms of the [Mozilla Public License 2.0](https://github.com/mosip/mosip-platform/blob/master/LICENSE)

File renamed without changes.
Loading
Loading