Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Use the Delft-FEWS Workflow Test Runner to run workflows.
  • Use the python pytest tooling to run test cases and generate local test reports.
  • Use Azure DevOps to create a build pipeline that can run the python tests on configuration changes.
  • Use Azure DevOps Release Pipelines to automatically deploy a new configuration and validate the live system status.

...

When completed, files that have been generated with the configured Delft-FEWS workflow, will be compared with a well-known result file. In case of any differences, the test will fail and reported in a test report file.
These tests can be run locally with python installed which is needed to setup or extend the test cases.

Azure DevOps build pipeline

...

The build pipeline will be triggered if a change to the Delft-FEWS configuration is committed.

  • The data conversion workflow test runner tests will be run with this new configuration.
  • On any failures, the failed tests will be reported, and the pipeline stops.
  • If all tests are successful, the build pipeline will provide the test configuration to the release pipeline.

...

Code Block
languageyml
titleAzure Devops Build Pipeline
#
# Python 3 is required.
#
# python3 workflowtests/scripts/workflowtestrunner.py
#
# The following python packages are required.
#
# pip install junitparser
# pip install junit2html
# pip install requests

# -*- coding: utf-8 -*-
import sys
import os
import shutil
import requests, zipfile, io
from datetime import datetime
from junitparser import JUnitXml

# Make sure the basebuild is available.
def download_base_build():
    r = requests.get(
        "https://delftfewsbasebuildspublic.bloburl.core.windows.net/delft-fews-base-builds/fews-development-202201-109669-binwith.basebuild.zip")
    z = zipfile.ZipFile(io.BytesIO(r.content))
    z.extractall("bin")


def absolute_file_paths(directory):
    path = os.path.abspath(directory)
    return [entry.path for entry in os.scandir(path) if entry.is_file()]


def merge_xml_reports(reportDir):
    junit_report_dir = f"{reportDir}/junit"
    report = ""
    junit_files = absolute_file_paths(junit_report_dir)

    for file in junit_files:
        if file.endswith(".xml"):
            xml = JUnitXml.fromfile(file)
            if report == "":
                report = xml
            else:
                report = report + xml

    report_xml_file = f"{reportDir}/junit/report-all.xml"
    report.write(report_xml_file, True)
    return report_xml_file


def main(argv):
    working_dir = os.getcwd()
    if not os.path.isdir(f"{working_dir}/bin"):
        download_base_build()
    report_dir = f"{working_dir}/report"
    report_html_file = f"{report_dir}/report.html"
    shutil.rmtree(report_dir, ignore_errors=True)
    workflow_tests_command = f"{working_dir}/bin/windows/Delft-FEWSc.exe -Dregion.home={working_dir}/region_home -DautoRollingBarrel=false -Xmx20484m -DoldPID=13096_1555070573358 -Djava.locale.providers=SPI,JRE -Dstart.time=1630454400000 -Djava.library.path={working_dir}/bin/windows -Wvm.location={working_dir}/bin/windows/jre/bin/server/jvm.dll -Wclasspath.1={working_dir}/region_home/patch.jar -Wclasspath.2={working_dir}/bin/*.jar -Wmain.class=nl.wldelft.fews.system.workflowtestrun.WorkflowTestRun -Warg.1={working_dir}/region_home -Warg.2={working_dir}/workflowtests/configuration"
    print("%s", workflow_tests_command)
    # Run the workflow tests.
    os.system(workflow_tests_command)
    # Merge all xml reports.
    report_xml_file = merge_xml_reports(report_dir)
    os.system(f"junit2html {report_xml_file} {report_html_file}")

# ------------------------------------------------------------------------------
if __name__ == "__main__":
    start_time = datetime.now()
    print('Start Workflow Test Runner: %s\n' % start_time.strftime("%Y-%m-%d %H:%M:%S"))
    main(sys.argv[0:])
    print('End  : %s' % datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
    print('Finished')

...