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

tests: run test against actual schema files, not snapshots #256

Open
3 of 4 tasks
jkowalleck opened this issue Jun 21, 2023 · 10 comments · May be fixed by #592
Open
3 of 4 tasks

tests: run test against actual schema files, not snapshots #256

jkowalleck opened this issue Jun 21, 2023 · 10 comments · May be fixed by #592
Assignees
Labels
chore: QA A chore related to Quality Assurance test-data related to test-resources and -data

Comments

@jkowalleck
Copy link
Member

jkowalleck commented Jun 21, 2023

Current implementation of java tests run against a snapshot of the schema files, shipped with org.cyclinedx java package.
This is undesired and error-prone, as changes to the schema files in this repo are not checked against the schema example files.
Therefore, most java checks in pull requests are just bogus results without any meaning.
This must change ASAP.

Use cases:

  • a PullRequest is opened, that modifies a schema file. tests must run based on these changes, not some snapshots.
  • a PullRequest is opened, that modify some test-resources. tests must run based on these changes.

acceptance criteria

  • all test run against the actual schema files in this repo, not against any other snapshots
  • optional, but preferred: tests run offline, do not load any data from external sources
  • all currently running tests still pass

scope

targets

out of scope (since already fixed/done)

  • PHP tests -- done, uses local versions
  • JS tests -- done, uses local versions
  • ProtoBuf tests -- done, uses local versions
    • see
      function validate() {
      FILE="$1"
      SCHEMA_VERS="$2"
      SCHEMA_FILE="bom-${SCHEMA_VERS}.proto"
      MESSAGE="cyclonedx.v${SCHEMA_VERS/./_}.Bom"
      echo ">> validate $(realpath --relative-to="$PWD" "$FILE") as ${MESSAGE} of ${SCHEMA_FILE}" >&2
      # this test method is a bare minimum, and it might not detect all kinds of malformed input.
      # could be improved by utilizing protoc -- see https://github.com/CycloneDX/specification/pull/385/commits/8db0967c11cb913ac3c7a9a037159338df3f3bd9
      docker run --rm \
      --volume "${ROOT_PATH}/${SCHEMA_DIR}:/workspace/${SCHEMA_DIR}:ro" \
      --volume "${FILE}:/workspace/test_res:ro" \
      --workdir '/workspace' \
      bufbuild/buf:"$BUF_IMAGE_VERSION" \
      convert "${SCHEMA_DIR}/${SCHEMA_FILE}" \
      --type "$MESSAGE" \
      --from 'test_res#format=txtpb' \
      --to /dev/null
      }
      shopt -s globstar
      for test_res in "$ROOT_PATH"/"$TEST_RES_DIR"/*/valid-*.textproto
      do
      SCHEMA_VERS="$(basename "$(dirname "$test_res")")"
      validate "$test_res" "$SCHEMA_VERS"
      done

caused by #255
related: https://cyclonedx.slack.com/archives/G01PMU9ERJA/p1687363757137109

@jkowalleck
Copy link
Member Author

@CycloneDX/core-team FYI

@CycloneDX/java-maintainers can you help out and fix the tests?

@jkowalleck jkowalleck changed the title tests: tun Java test against local schema files tests: run Java test against actual schema files, not snapshots Jun 21, 2023
@stevespringett
Copy link
Member

The latest schema from the 1.5-dev branch has been incorporated into the latest Core Java 7.4.0-SNAPSHOT

@jkowalleck
Copy link
Member Author

jkowalleck commented Jun 22, 2023

re: #256 (comment)
this does not solve the following purpose: a PR modifies the schema files. tests should run on these changes, not some snapshot. here is such a case: #255

@jkowalleck jkowalleck changed the title tests: run Java test against actual schema files, not snapshots tests: run test against actual schema files, not snapshots Jun 22, 2023
@jkowalleck
Copy link
Member Author

@mr-zepol mentioned he might be able to help out here.

@jkowalleck jkowalleck added the test-data related to test-resources and -data label Dec 12, 2023
@jkowalleck jkowalleck added the chore: QA A chore related to Quality Assurance label Dec 10, 2024
jkowalleck added a commit that referenced this issue Jan 22, 2025
1. enabled test runner for schema 1.7
1. copied all test cases from 1.6 to 1.7 
1. renamed the files from `*.1.6.*` to `*.1.7.*`
1. migrated the test cases from schema 1.6 to schema 1.7

see the diff/delta of each individual commit for details

java tests are expected to fail, as long as
#256 is not done
@jkowalleck
Copy link
Member Author

the situation with java tests is so annoying.
i am going to tackle this, now.

@jkowalleck jkowalleck self-assigned this Jan 22, 2025
@ppkarwasz
Copy link

the situation with java tests is so annoying. i am going to tackle this, now.

I can look at it in the weekend.

@jkowalleck
Copy link
Member Author

the situation with java tests is so annoying. i am going to tackle this, now.

I can look at it in the weekend.

this would be fantastic.
i started butchering some code together and realized, that I did not do any java in the past 20 years. so i am not very efficient.

I'll assign the ticket to you, @ppkarwasz , in hope you'll find time for it :D

@jkowalleck jkowalleck assigned ppkarwasz and unassigned jkowalleck Jan 22, 2025
@jkowalleck
Copy link
Member Author

Hi @ppkarwasz ,
Just wanted to check back on this. Did you find some time for this ticket?
No pressure, I know how busy we all are.

If you have no time for it, just let me know, and I will set the ticket back to "need help", just let me know :)

@ppkarwasz
Copy link

I am recovering from FOSDEM, but I put this item at the top of my TODO list for this weekend.

ppkarwasz added a commit to ppkarwasz/specification that referenced this issue Feb 9, 2025
This change modifies the Java Unit tests to use the schemas in this repository to validate the examples, instead of those bundled in the `cyclonedx-java-core` artifact.

Closes CycloneDX#256
ppkarwasz added a commit to ppkarwasz/specification that referenced this issue Feb 9, 2025
This change modifies the Java Unit tests to use the schemas in this repository to validate the examples, instead of those bundled in the `cyclonedx-java-core` artifact.

Closes CycloneDX#256
@ppkarwasz ppkarwasz linked a pull request Feb 9, 2025 that will close this issue
ppkarwasz added a commit to ppkarwasz/specification that referenced this issue Feb 9, 2025
This change modifies the Java Unit tests to use the schemas in this repository to validate the examples, instead of those bundled in the `cyclonedx-java-core` artifact.

Closes CycloneDX#256

Signed-off-by: Piotr P. Karwasz <piotr.github@karwasz.org>
@ppkarwasz
Copy link

@jkowalleck,

I fixed the tests in #592.

n1ckl0sk0rtge pushed a commit to n1ckl0sk0rtge/specification that referenced this issue Feb 11, 2025
n1ckl0sk0rtge pushed a commit to n1ckl0sk0rtge/specification that referenced this issue Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore: QA A chore related to Quality Assurance test-data related to test-resources and -data
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants