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

Coverage report for conformance tests #21092

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 21 additions & 1 deletion .github/workflows/oidc-conformance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,19 @@ jobs:
"${asset_url}"
fi
- name: Download Jacoco Agent
id: download_jacoco
run: |
curl -vLJO -H 'Accept: application/octet-stream' https://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/0.8.12/jacoco-0.8.12.zip
- name: Run IS
run: |
PRODUCT_IS_ZIP=$(find ./ -name wso2is* -type f -printf "%f\n")
ROOT_DIR=$(pwd)
touch jacoco.exec
echo "PRODUCT_IS_DIR=${PRODUCT_IS_ZIP%.zip}" >> $GITHUB_ENV
cd ./product-is/oidc-conformance-tests
python3 ./configure_is.py ../../$PRODUCT_IS_ZIP
python3 ./configure_is.py ../../$PRODUCT_IS_ZIP $ROOT_DIR $ROOT_DIR/jacoco.exec
- name: Set up JDK 17
uses: actions/setup-java@v3
Expand All @@ -158,6 +166,11 @@ jobs:
- name: Run Tests
run: bash ./product-is/oidc-conformance-tests/test_runner.sh

- name: Stop IS
id: stop_is
run: |
sh ./product-is/oidc-conformance-tests/${{ env.PRODUCT_IS_DIR }}/bin/wso2server.sh stop
- name: Test Results
run: |
Expand Down Expand Up @@ -192,6 +205,13 @@ jobs:
with:
name: test-logs
path: ./*log.txt

- name: Archive Jacoco results
uses: actions/upload-artifact@v4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we be using v3?

if: always()
with:
name: jacoco-exec
path: ./jacoco.exec

- name: Send Email
if: always()
Expand Down
22 changes: 22 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 @@ -328,6 +330,10 @@ def unpack_and_run(zip_file_name):
print("Extracting " + zip_file_name)
zip_file.extractall()

with ZipFile(path_to_jacoco_agent + "/jacoco-0.8.12.zip", 'r') as jacoco_agent_zip:
print("Extracting " + path_to_jacoco_agent)
jacoco_agent_zip.extractall(path_to_jacoco_agent + "/jacoco-0.8.12")

dir_name = ''
# start identity server
print("\nStarting Server")
Expand All @@ -339,6 +345,8 @@ def unpack_and_run(zip_file_name):
dir_name = line
break

agent_line = "-javaagent:" + path_to_jacoco_agent + "/jacoco-0.8.12/lib/jacocoagent.jar" + "=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* \\"
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 +363,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