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

Fix bugs in XQSuite and XQuery tests written for XQSuite #4622

Conversation

adamretter
Copy link
Member

@adamretter adamretter commented Nov 28, 2022

Closes #4612

Unfortunately fixing a number of bugs in XQSuite has revealed:

  1. A number of tests written for XQSuite that are invalid XQuery (according to the W3C spec)
  2. A number of sub-type promotion errors in eXist-db

@adamretter adamretter added bug issue confirmed as bug high prio labels Nov 28, 2022
@adamretter adamretter added this to the eXist-7.0.0 milestone Nov 28, 2022
@adamretter adamretter force-pushed the hotfix/xqsuite-non-error-reported-as-error branch from b33fa3a to 13f1522 Compare November 28, 2022 18:08
@adamretter adamretter self-assigned this Nov 28, 2022
@adamretter adamretter force-pushed the hotfix/xqsuite-non-error-reported-as-error branch from 13f1522 to 767239a Compare November 29, 2022 00:49
@adamretter adamretter marked this pull request as ready for review November 29, 2022 00:50
@adamretter adamretter requested a review from a team November 29, 2022 00:50
@line-o
Copy link
Member

line-o commented Nov 29, 2022

Please have a look at the test failures.

@adamretter adamretter force-pushed the hotfix/xqsuite-non-error-reported-as-error branch from 767239a to 80283bc Compare November 29, 2022 12:24
@adamretter
Copy link
Member Author

adamretter commented Nov 29, 2022

Please have a look at the test failures

@line-o All tests are now passing.

@line-o
Copy link
Member

line-o commented Nov 29, 2022

What about the error in Deploy / Build and Test Images?

@adamretter
Copy link
Member Author

adamretter commented Nov 29, 2022

What about the error in Deploy / Build and Test Images?

@line-o I don't know what the Bats tests do and I don't understand them. Any idea who added them and/or what they do?

@duncdrum
Copy link
Contributor

They test the docker container. In this case https://github.com/eXist-db/exist/actions/runs/3574037174/jobs/6008812699#step:11:12 if the logs are free of errors on startup. They are not in this branch

@adamretter
Copy link
Member Author

Okay thanks @duncdrum, do you know where I can see the logs?

@duncdrum
Copy link
Contributor

duncdrum commented Nov 30, 2022

@adamretter simply build and run the container and see what it pipes to console, or download exist.log

@adamretter
Copy link
Member Author

@duncdrum Unless I am mistaken the exist.log or Docker console log is not available from the CI for this?

@adamretter
Copy link
Member Author

adamretter commented Nov 30, 2022

I built a Docker image locally, and it does indeed show that there was a hidden XQuery error in Monex which is shown by the fixes in this PR:

30 Nov 2022 22:03:45,321 [main] ERROR (AutoDeploymentTrigger.java [execute]:127) - Exception during deployment of app monex-3.0.4.xar: Error found while processing repo.xml: err:XPTY0004 xs:string(/db/apps/monex/data) is not a sub-type of xs:anyURI [at line 12, column 15, source: /exist/etc/../data/expathrepo/monex-3.0.4/post-install.xql]
org.expath.pkg.repo.PackageException: Error found while processing repo.xml: err:XPTY0004 xs:string(/db/apps/monex/data) is not a sub-type of xs:anyURI [at line 12, column 15, source: /exist/etc/../data/expathrepo/monex-3.0.4/post-install.xql]
	at org.exist.repo.Deployment.deploy(Deployment.java:469) ~[exist.uber.jar:6.1.0-SNAPSHOT]
	at org.exist.repo.Deployment.installAndDeploy(Deployment.java:281) ~[exist.uber.jar:6.1.0-SNAPSHOT]

Seems we will also need to fix Monex and get a new release of that out...

@adamretter
Copy link
Member Author

adamretter commented Nov 30, 2022

@line-o @duncdrum Okay I fixed this issue in a quick hotfix release of Monex 3.0.5 and this has fixed the build here.

Copy link
Member

@line-o line-o left a comment

Choose a reason for hiding this comment

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

Since one of the bundled applications seems to choke on the changes in this PR we need to investigate first if other packages might also be affected.

@line-o
Copy link
Member

line-o commented Dec 1, 2022

related to #4632

line-o
line-o previously requested changes Dec 1, 2022
Copy link
Member

@line-o line-o left a comment

Choose a reason for hiding this comment

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

Please have a look at the comments.

@line-o
Copy link
Member

line-o commented Dec 1, 2022

Regarding problems with bundled applications: the necessity of commit a1a35e0 indicates that there might be more problems after this PR is merged.

@line-o
Copy link
Member

line-o commented Dec 1, 2022

This PR contains several - welcome and good - changes that would warrant their own separate PRs. The risk is that we accidentally create more harm than we solve.

@adamretter
Copy link
Member Author

Since one of the bundled applications seems to choke on the changes in this PR we need to investigate first if other packages might also be affected.

@line-o I am afraid that is not specific to this PR. That is just a general statement that: whenever we modify eXist-db's XQuery engine to be more spec compliant, then it is likely that any code that relied on behaviour that is not spec compliant will need to be fixed. This has been true for every XQuery change to eXist-db, and does not relate specifically to this PR.

This change, just like any other PR that changes eXist-db's XQuery compliance in a non-compatible way, is scheduled for a major release.

Copy link
Member

@line-o line-o left a comment

Choose a reason for hiding this comment

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

There is still an open question on the adaptive serialization test where the expected value changed from a string to a number literal.
I would like to have proof that XQsuite is able to assert a string '1234' was returned.

@adamretter
Copy link
Member Author

adamretter commented Feb 14, 2023

There is still an open question on the adaptive serialization test where the expected value changed from a string to a number literal.

@line-o As I tried to explain above there is a sequence of operations that happens. This test is not only testing that a specific string is returned from fn:serialize for Adaptive Serialization, but it is also testing the steps that happen after that. I will elaborate here to try and make the intention of the test clearer...

  1. A Literal un-quoted annotation with value 1234 is passed as the argument to the function, and XQSuite has to parse this and cast it to the correct sub-type of xs:anyAtomicType. In this test it will be parsed and cast to xs:integer.
  2. The function under test is executed by XQSuite.
  3. The function under test eventually calls fn:serialize with the Adaptive Serialization mode set; fn:serialize returns an xs:string.
  4. The function under test returns the xs:string value.
  5. XQSuite needs to convert that xs:string value to a type and/or value that is appropriate for comparison to the expected value instructed by the %test:assert* annotation.
  6. For this test the assert annotation has an *un-quotedvalue of1234. XQSuite has to coerce this and the result of the function to a type that it can compare according to the XQuery specs for type promotion and type derivation. In this test it will be parsed and cast to xs:integer`.
  7. Finally the two xs:integer values are compared for equality.

I hope that helps explain the purpose of this test (which I think is the thing that is not being understood here). To summarise - it covers both the xs:string case that you are concerned about, as well as the actual xs:integer case that I am trying to test.

I would like to have proof that XQsuite is able to assert a string '1234' was returned.

That is already present on that test, both implicitly through the explanation above that uses:

%test:args(1234)
%test:assertEquals(1234)

and also explicitly by the additional assertions on the same function under test:

%test:args('Hello "world"!')
%test:assertEquals('"Hello ""world""!"')

Additionally... I think you are already aware of many tests, including some written by yourself, within the full XQSuite of tests that already cover that use-case.

@line-o
Copy link
Member

line-o commented Feb 14, 2023

The two tests in question do test the raw output of serialize (they are part of the spec of our implementation of fn:serialize). The function under test is fn:serialize. Thus have to return xs:string correct?

declare
    %test:args(1234)
    %test:assertEquals(1234)
    %test:args('Hello "world"!')
    %test:assertEquals('"Hello ""world""!"')
function ser:adaptive-simple-atomic($atomic as xs:anyAtomicType) {
    ser:adaptive($atomic)
};

declare
    %test:args(1234)
    %test:assertEquals(1234)
    %test:args('Hello "world"!')
    %test:assertEquals('"Hello ""world""!"')
function ser:adaptive-simple-atomic-map-params($atomic as xs:anyAtomicType) {
    ser:adaptive-map-params($atomic)
};

@adamretter
Copy link
Member Author

adamretter commented Feb 21, 2023

Thus have to return xs:string correct?

I am afraid @line-o that you are still missing the point of my changes. I am not sure how I can explain them any better, as I have tried several times now. Perhaps someone else could assist here?

So... Yes, fn:serialize returns an xs:string. I am not disputing that! I even said above:

  1. The function under test eventually calls fn:serialize with the Adaptive Serialization mode set; fn:serialize returns an xs:string.

However, that's not the point of these additions that I have made. As I said above:

To summarise - it covers both the xs:string case that you are concerned about, as well as the actual xs:integer case that I am trying to test.

Can we please move on?

@line-o
Copy link
Member

line-o commented Feb 21, 2023

actual xs:integer case that I am trying to test.

The test are for fn:serialize! They must stay testing that the return value is xs:string, otherwise they do not make sense for anyone looking at them in a few months. They were changed in this PR for no apparent reason. Please let's move on by reverting the changes to those two tests.
If you want test type promotion capabilities of XQSuite, please add them separately to an xqsuite specific testsuite.

@adamretter
Copy link
Member Author

@dizzzz @reinhapa Would you be able to spare some time to help @line-o understand what I am trying to achieve here please?

@reinhapa
Copy link
Member

reinhapa commented Feb 21, 2023

actual xs:integer case that I am trying to test.

The test are for fn:serialize! They must stay testing that the return value is xs:string, otherwise they do not make sense for anyone looking at them in a few months. They were changed in this PR for no apparent reason. Please let's move on by reverting the changes to those two tests. If you want test type promotion capabilities of XQSuite, please add them separately to an xqsuite specific testsuite.

@line-o I can not see a problem with the changes from @adamretter here. In my opinion the fix is as much as important as the test. As I understand it your requirements where covered as explained by Adam earlier. I see no point of changing the tests again.

@line-o
Copy link
Member

line-o commented Feb 21, 2023

@reinhapa a test that has to ensure the function under test returns the expected value and type.
Since the modified tests test fn:serialize it has to be xs:string. At the moment this is the case. In this PR the expected return type is changed to a literal xs:decimal ("1234" was changed to 1234).
If this does not make a difference technologically it does change the meaning of the test semantically.
In worst case it can lead to uncaught regressions.

@line-o line-o self-requested a review February 28, 2023 15:48
@reinhapa reinhapa dismissed line-o’s stale review February 28, 2023 16:31

Let's proceed as discussed in the call here...

…ic, rather it is implicitly a member by the fact that it is a sub-type of xs:decimal (which is a direct member)
…correctly mixing xs:integer and xs:long for handles, should be xs:long
@adamretter adamretter force-pushed the hotfix/xqsuite-non-error-reported-as-error branch from edab247 to 0c66292 Compare February 28, 2023 17:36
@sonarcloud
Copy link

sonarcloud bot commented Feb 28, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

77.8% 77.8% Coverage
0.0% 0.0% Duplication

@reinhapa reinhapa merged commit d3cc1e7 into eXist-db:develop Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issue confirmed as bug high prio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XQSuite incorrectly reports non-error as success for %test:assertError
6 participants