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

Schema commit time validations #290

Merged
merged 29 commits into from
Jul 19, 2024
Merged

Schema commit time validations #290

merged 29 commits into from
Jul 19, 2024

Conversation

farost
Copy link
Member

@farost farost commented Jul 17, 2024

Usage and product changes

We fix old concept/schema-validation behaviour tests, reformatting them to the new ConceptAPI steps declarations and changing small details in its logic to follow the new validation rules of 3.0.

We also fix a number of new concept/type tests that expected transaction commits; fails; results based on the final versions of commit time validations of the 3.0 server. It is expected that every commit-time validation is now covered by BDD tests.

Additionally, this PR presents new steps for @values, @ranges, @card annotations (with a separate check of get cardinality constraint), and other small things that were forgotten in the past.

Implementation

I'd like to move schema-validation tests to different type files as they have just the same meaning and it's hard to split operation time validations with commit time validations (schema validations in migration). Right now all the old tests are still in the old file for easier review.

For more details, check out the comments in the changed files.

@typedb-bot
Copy link
Member

PR Review Checklist

Do not edit the content of this comment. The PR reviewer should simply update this comment by ticking each review item below, as they get completed.


Trivial Change

  • This change is trivial and does not require a code or architecture review.

Code

  • Packages, classes, and methods have a single domain of responsibility.
  • Packages, classes, and methods are grouped into cohesive and consistent domain model.
  • The code is canonical and the minimum required to achieve the goal.
  • Modules, libraries, and APIs are easy to use, robust (foolproof and not errorprone), and tested.
  • Logic and naming has clear narrative that communicates the accurate intent and responsibility of each module (e.g. method, class, etc.).
  • The code is algorithmically efficient and scalable for the whole application.

Architecture

  • Any required refactoring is completed, and the architecture does not introduce technical debt incidentally.
  • Any required build and release automations are updated and/or implemented.
  • Any new components follows a consistent style with respect to the pre-existing codebase.
  • The architecture intuitively reflects the application domain, and is easy to understand.
  • The architecture has a well-defined hierarchy of encapsulated components.
  • The architecture is extensible and scalable.

Copy link
Member Author

@farost farost left a comment

Choose a reason for hiding this comment

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

lgtm

| annotation | annotation-category |
| abstract | abstract |
| independent | independent |
# TODO: Only for typeql as we can't parse value types without set value types
Copy link
Member Author

Choose a reason for hiding this comment

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

That's a quite sad limitation for concept api at the moment, but it's fine as we'll have simple typeql tests anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

This file's tests run for about 3000 seconds (50 minutes) after the reduction of Examples with
bazel test //tests/behaviour/concept/type/... --jobs=1
Maybe it requires separating it into different files, but there is just a huge mass of annotation tests that is around 40-45 minutes, I guess, so it's not totally clear how to do it. At the same time, I don't want to shorten the number of Examples further as some of these Examples really showed some small tricky bugs with specific value types!

Copy link
Member Author

Choose a reason for hiding this comment

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

I just updated general type steps to align with the new "language".

Copy link
Member Author

Choose a reason for hiding this comment

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

I just updated general type steps to align with the new "language".

@@ -11,490 +11,734 @@ Feature: Schema validation
Given connection has been opened
Given connection does not have any database
Given connection create database: typedb
Given connection open schema session for database: typedb
Given session opens transaction of type: write
Given connection open schema transaction for database: typedb


Scenario: Cyclic type hierarchies are disallowed
Copy link
Member Author

Choose a reason for hiding this comment

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

This test can be split into 3 (even 4 with role types) tests and be put into concept files.


When connection open schema transaction for database: typedb
When entity(ent1) get plays(rel1:role1) set override: rel0:role0
Then transaction commits; fails


Scenario: A thing-type may not be moved in a way that its plays declarations are hidden by an override
Copy link
Member Author

Choose a reason for hiding this comment

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

plays.feature

Given create attribute type: attr00, with value type: string
Given attribute(attr00) set abstract: true
Given create attribute type: attr10, with value type: string
Scenario: A concrete type must override any ownerships of abstract attributes it inherits
Copy link
Member Author

Choose a reason for hiding this comment

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

owns.feature

When connection open schema transaction for database: typedb
When entity(ent1) set supertype: ent01; fails

# TODO: Refactor to functions
Copy link
Member Author

Choose a reason for hiding this comment

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

Gonna rename this file to functions after I move everything else and leave it until we refactor these steps.

# Then transaction commits; fails


Scenario: Annotations on ownership overrides must be at least as strict as the overridden ownerships
Copy link
Member Author

Choose a reason for hiding this comment

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

owns.feature

When transaction closes
When connection open schema transaction for database: typedb
When entity(ent0n) get owns(attr0) set annotation: @key
Then transaction commits; fails


Scenario: Annotations on ownership redeclarations must be stricter than the previous declaration or will be flagged as redundant on commit.
Copy link
Member Author

Choose a reason for hiding this comment

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

owns.feature

@farost farost marked this pull request as ready for review July 18, 2024 09:34
@farost
Copy link
Member Author

farost commented Jul 18, 2024

Server PR for these tests: typedb/typedb#7104

Copy link
Member Author

Choose a reason for hiding this comment

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

As we discussed with @flyingsilverfin , I've renamed this file to function.featureand moved all the possible tests from it to different type/ files.

Copy link
Member Author

Choose a reason for hiding this comment

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

It previously was schema-validation.feature

Copy link
Member Author

Choose a reason for hiding this comment

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

I split one owns.feature file into two files. It is still not perfect and can be split further if we just want to speed up the test executions because of the cucumber crate bug (cucumber-rs/cucumber#331), but it should be enough for now to move forward.

There is a specific todo with a link to the cucumber issue in the file's header.

@farost farost merged commit ba6f933 into typedb:3.0 Jul 19, 2024
1 check passed
@farost farost deleted the 3.0-validation-bdd branch August 21, 2024 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants