Skip to content

Commit

Permalink
[tests-only][full-ci]Check for suite existence in the expected to fai…
Browse files Browse the repository at this point in the history
…lure files (#9827)

* check for suite existence in the expected to failure file

* Review address and refactor

* change script name
  • Loading branch information
SagarGi authored Nov 1, 2023
1 parent a282534 commit eac1f01
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 4 deletions.
26 changes: 26 additions & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ def main(ctx):
def beforePipelines(ctx):
return checkStarlark() + \
licenseCheck(ctx) + \
checkTestSuitesInExpectedFailures(ctx) + \
documentation(ctx) + \
changelog(ctx) + \
pnpmCache(ctx) + \
Expand Down Expand Up @@ -1681,6 +1682,31 @@ def licenseCheck(ctx):
},
}]

def checkTestSuitesInExpectedFailures(ctx):
return [{
"kind": "pipeline",
"type": "docker",
"name": "check-suites-in-expected-failures",
"workspace": {
"base": dir["base"],
"path": config["app"],
},
"steps": [
{
"name": "check-suites",
"image": OC_CI_ALPINE,
"commands": [
"%s/tests/acceptance/check-deleted-suites-in-expected-failure.sh" % dir["web"],
],
},
],
"trigger": {
"ref": [
"refs/pull/**",
],
},
}]

def middlewareService():
environment = {
"BACKEND_HOST": "https://ocis:9200",
Expand Down
63 changes: 63 additions & 0 deletions tests/acceptance/check-deleted-suites-in-expected-failure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash

# when deleting the tests suites from /features there might be the tests scenarios that might be in the expected to failure file
# this script checks if there are such scenarios in the expected to failure file which needs to be deleted

# helper functions
log_error() {
echo -e "\e[31m$1\e[0m"
}

log_info() {
echo -e "\e[37m$1\e[0m"
}

log_success() {
echo -e "\e[32m$1\e[0m"
}

SCRIPT_PATH=$(dirname "$0")
PATH_TO_SUITES="${SCRIPT_PATH}/features"
PATH_TO_EXPECTED_FAILURE_FILE="${SCRIPT_PATH}/expected-failures-with-ocis-server-ocis-storage.md"
# contains all the suites names inside tests/acceptance/features
AVAILABLE_SUITES=($(ls -l "$PATH_TO_SUITES" | grep '^d' | awk '{print $NF}'))

# regex to match [someSuites/someFeatureFile.feature:lineNumber]
SCENARIO_REGEX="\[([a-zA-Z0-9]+/[a-zA-Z0-9]+\.feature:[0-9]+)]"

# contains all those suites available in the expected to failure files in pattern [someSuites/someFeatureFile.feature:lineNumber]
EXPECTED_FAILURE_SCENARIOS=($(grep -Eo ${SCENARIO_REGEX} ${PATH_TO_EXPECTED_FAILURE_FILE}))

# get and store only the suites names from EXPECTED_FAILURE_SCENARIOS
EXPECTED_FAILURE_SUITES=()
for scenario in "${EXPECTED_FAILURE_SCENARIOS[@]}"; do
if [[ $scenario =~ \[([a-zA-Z0-9]+) ]]; then
suite="${BASH_REMATCH[1]}"
EXPECTED_FAILURE_SUITES+=("$suite")
fi
done

# also filter the duplicated suites name
EXPECTED_FAILURE_SUITES=($(echo "${EXPECTED_FAILURE_SUITES[@]}" | tr ' ' '\n' | sort | uniq))

# Check the existence of the suite
NONEXISTING_SCENARIOS=()
for suite in "${EXPECTED_FAILURE_SUITES[@]}"; do
if [[ " ${AVAILABLE_SUITES[*]} " != *" $suite "* ]]; then
pattern="(${suite}/[a-zA-Z0-9]+\\.feature:[0-9]+)"
NONEXISTING_SCENARIOS+=($(grep -Eo ${pattern} ${PATH_TO_EXPECTED_FAILURE_FILE}))
fi
done

count="${#NONEXISTING_SCENARIOS[@]}"

if [ "$count" -gt 0 ]; then
log_info "The following test scenarios do not exist anymore:"
log_info "They can be deleted from the '${PATH_TO_EXPECTED_FAILURE_FILE}'."
for scenario_path in "${NONEXISTING_SCENARIOS[@]}"; do
log_error "$scenario_path"
done
exit 1
fi

log_success "All the suites in the expected failure file exist in the test suites"
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ Other free text and markdown formatting can be used elsewhere in the document if
- [webUIWebdavLockProtection/upload.feature:32](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIWebdavLockProtection/upload.feature#L32)
- [webUIWebdavLockProtection/upload.feature:33](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIWebdavLockProtection/upload.feature#L33)

### [Federated shares not showing in shared with me page](https://github.com/owncloud/web/issues/2510)
- [webUISharingExternal/federationSharing.feature:38](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUISharingExternal/federationSharing.feature#L38)
- [webUISharingExternal/federationSharing.feature:166](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUISharingExternal/federationSharing.feature#L166)

### [empty subfolder inside a folder to be uploaded is not created on the server](https://github.com/owncloud/web/issues/6348)
- [webUIUpload/upload.feature:43](https://github.com/owncloud/web/blob/master/tests/acceptance/features/webUIUpload/upload.feature#L43)

Expand Down

0 comments on commit eac1f01

Please sign in to comment.