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

test: Expand backup integration tests #1699

Merged

Conversation

AndrewSisley
Copy link
Contributor

Relevant issue(s)

Resolves #1696

Description

Expands the backup integration tests, and fixes an invalid schema declaration.

Documents #1697

I went over the CLI tests too, but found no gaps.

@AndrewSisley AndrewSisley added area/db-system Related to the core system related components of the DB area/testing Related to any test or testing suite code quality Related to improving code quality action/no-benchmark Skips the action that runs the benchmark. labels Jul 24, 2023
@AndrewSisley AndrewSisley added this to the DefraDB v0.6 milestone Jul 24, 2023
@AndrewSisley AndrewSisley requested a review from a team July 24, 2023 17:00
@AndrewSisley AndrewSisley self-assigned this Jul 24, 2023
@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.04% ⚠️

Comparison is base (101bb37) 75.42% compared to head (1f5fc8c) 75.38%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1699      +/-   ##
===========================================
- Coverage    75.42%   75.38%   -0.04%     
===========================================
  Files          208      208              
  Lines        21694    21694              
===========================================
- Hits         16362    16353       -9     
- Misses        4195     4201       +6     
- Partials      1137     1140       +3     
Flag Coverage Δ
all-tests 75.38% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 101bb37...1f5fc8c. Read the comment docs.

ImportContent: `{
"User":[
{
"_key":"bae-790e7e49-f2e3-5ad6-83d9-5dfb6d8ba81d",
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: Since _newKey will be used to check if it's a self reference, I suggest we change _key for _newKey or have both.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Jul 24, 2023

Choose a reason for hiding this comment

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

_newKey will be used to check if it's a self reference

It would? I always saw it the other way round, as any exported relation id fields would contain the old key, not the new one.

Happy to have both.

- [ ] add _newKey

Copy link
Collaborator

Choose a reason for hiding this comment

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

The relation ID will be updated on export.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Jul 24, 2023

Choose a reason for hiding this comment

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

Ah, okay nice :)

But wouldn't it make more sense for the export to contain _oldKey and _key then (instead of _newKey)? As the docs in the export reference the new key, not the old one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Converted to the import-export flow suggested in another comment

executeTestCase(t, test)
}

func TestBackupImport_WithMultipleNoKeysAndInvalidField_NoError(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: Change function name to end with _ReturnError as that is what is expected of the function under test.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Jul 24, 2023

Choose a reason for hiding this comment

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

My bad, will change, thanks

  • Fix test name


// This test documents undesirable behaviour, as the documents are not linked.
// https://github.com/sourcenetwork/defradb/issues/1697
func TestBackupSelfRefImport_SplitPrimaryRelationWithSecondCollection_NoError(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: This test would work if the import content was taken from the generated export. I suggest either it documents an invalid import content and we remove the linked issue above the function name or we change the test to use a valid import content.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Jul 24, 2023

Choose a reason for hiding this comment

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

That's fair, and it is more descriptive, even if a little longer/more-complex. Will change.

  • import an export (and in the other similar test)

@AndrewSisley AndrewSisley force-pushed the 1696-import-self-ref-tests branch 2 times, most recently from 2fca8f8 to 676d8dd Compare July 24, 2023 19:04
Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

LGTM. Just notice my note on the import error that you linked.

}

// This test documents undesirable behaviour, as the documents are not linked.
// https://github.com/sourcenetwork/defradb/issues/1697
Copy link
Collaborator

Choose a reason for hiding this comment

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

note: This test isn't linked to an import error. It's an export error. It's having trouble setting the right expected book ID because they both have a primary field related to each other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah nice spot - would be good to fix that too if you have time, I'm not sure your fix-PR solves for this kind of schema anyway and it is hard to test fully independently of the import

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can't test it on import. It has to be tested on export. The json object representing the exported data is clearly wrong so we could correct it manually and assert an error instead, Showing a wrong output after import is fine. Just a little less clear as to what the problem is.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Jul 24, 2023

Choose a reason for hiding this comment

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

Ah true - good shout. Tweaking now, will link to a new ticket.

  • Different bug

@AndrewSisley AndrewSisley merged commit f4bc169 into sourcenetwork:develop Jul 24, 2023
11 checks passed
@AndrewSisley AndrewSisley deleted the 1696-import-self-ref-tests branch July 24, 2023 20:37
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
## Relevant issue(s)

Resolves sourcenetwork#1696 

## Description

Expands the backup integration tests, and fixes an invalid schema
declaration.

Documents sourcenetwork#1697

I went over the CLI tests too, but found no gaps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/db-system Related to the core system related components of the DB area/testing Related to any test or testing suite code quality Related to improving code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Self-reference import missing integration tests
2 participants