Skip to content

Commit

Permalink
Coverage report for conformance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Maduranga Siriwardena committed Sep 11, 2024
1 parent 7c67bf6 commit eac1ec3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
30 changes: 26 additions & 4 deletions .github/workflows/oidc-conformance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,23 @@ jobs:
- name: Adding extra hosts to docker-compose-dev.yml
run: sed -i '/^ volumes.*/i \ \ \ \ extra_hosts:\n \ \ \ \ - "localhost:\$IP\"' ./conformance-suite/docker-compose-dev.yml


- name: Download Jacoco Agent
id: download_jacoco
run: |
echo "Current directory : $(pwd)"
curl -vLJO -H 'Accept: application/octet-stream' https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.8.12/org.jacoco.agent-0.8.12.jar
- name: Run IS
id: run_is
run: |
PRODUCT_IS_ZIP=$(find ./ -name wso2is* -type f -printf "%f\n")
JACOCO_AGENT=$(find ./ -name org.jacoco.agent* -type f -printf "%f\n")
echo "Current directory : $(pwd)"
ROOT_DIR=$(pwd)
touch jacoco.exec
cd ./product-is/oidc-conformance-tests
python3 ./configure_is.py ../../$PRODUCT_IS_ZIP
python3 ./configure_is.py ../../$PRODUCT_IS_ZIP $ROOT_DIR/org.jacoco.agent-0.8.12.jar $ROOT_DIR/jacoco.exec
- name: Set up JDK 17
uses: actions/setup-java@v2
Expand All @@ -121,7 +132,7 @@ jobs:
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r .tag_name)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Run Conformance Suite
run: |
DOCKER_COMPOSE_FILE=./docker-compose-dev.yml
Expand Down Expand Up @@ -155,7 +166,18 @@ jobs:
echo "============================================="
exit 1
fi
- name: Print Jacoco exec path
run: |
echo "steps.run_is.outputs.REPO_NAME: ${{steps.run_is.outputs.REPO_NAME}}/jacoco.exec"
- name: Archive Jacoco results
uses: actions/upload-artifact@v2
if: always()
with:
name: jacoco-exec
path: ${{steps.run_is.outputs.REPO_NAME}}/jacoco.exec

- name: Archive test results
uses: actions/upload-artifact@v2
if: always()
Expand Down
20 changes: 20 additions & 0 deletions oidc-conformance-tests/configure_is.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
}
# path to product is zip file
path_to_is_zip = str(sys.argv[1])
path_to_jacoco_agent = str(sys.argv[2])
path_to_jacoco_exec = str(sys.argv[3])


# use dcr to register a client
Expand Down Expand Up @@ -339,6 +341,10 @@ def unpack_and_run(zip_file_name):
dir_name = line
break

agent_line = "-javaagent:" + path_to_jacoco_agent + "=destfile=" + path_to_jacoco_exec + ",append=true,includes=org.wso2.carbon.idp.mgt*:org.wso2.carbon.sts*:org.wso2.carbon.user.core*:org.wso2.carbon.user.mgt*:org.wso2.carbon.claim.mgt*:org.wso2.carbon.identity.*:org.wso2.carbon.xkms.mgt* \\"
print("Argline: " + agent_line)
print("dir_name:" + dir_name)
add_jacoco_agent("./" + dir_name + "/bin/wso2server.sh", "-Dwso2.server.standalone=true \\", agent_line)
os.chmod("./" + dir_name + "/bin/wso2server.sh", 0o777)
append_toml_config("./config/oidc_deployment_config.toml", "./" + dir_name + "/repository/conf/deployment.toml")
process = subprocess.Popen("./" + dir_name + "/bin/wso2server.sh", stdout=subprocess.PIPE)
Expand All @@ -355,6 +361,20 @@ def unpack_and_run(zip_file_name):
print()
raise

def add_jacoco_agent(file, line_to_check, line_to_replace):
try:
with open(file, 'rb') as src, open(file + ".back", 'wb') as dst: dst.write(src.read())
# Read the content from the source TOML file
with open(file + ".back") as fin, open(file, 'w') as fout:
for line in fin:
lineout = line
if line.strip() == line_to_check:
lineout = f"{line_to_check}\n{line_to_replace}\n"
fout.write(lineout)
except FileNotFoundError as e:
print(f"The file does not exist: {e}")
except IOError as e:
print(f"An error occurred: {e}")

# Append additional toml configs to the existing deployment toml file.
def append_toml_config(source_file, destination_file):
Expand Down

0 comments on commit eac1ec3

Please sign in to comment.