-
Notifications
You must be signed in to change notification settings - Fork 403
Add catalog test suite to unify catalog's behavior. #2131
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
base: main
Are you sure you want to change the base?
Conversation
CTTY
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @blackmwk for the PR! This makes the test code much easier to manage.
Just finished a round of review and left some comments
| let metadata_location = root_namespace_state.remove_existing_table(table_ident)?; | ||
| self.file_io.delete(&metadata_location).await | ||
| root_namespace_state.remove_existing_table(table_ident)?; | ||
| Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized we don't have a catalog API to purge table in iceberg-rust?
Probably need to add this API to better define the expected behavior
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn test_register_table() -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this? This is already covered by table_register_suite
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn test_register_table() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, this is already covered by table_register_suite
| ) -> Result<Namespace> { | ||
| if self.namespace_exists(namespace).await? { | ||
| return Err(Error::new( | ||
| ErrorKind::DataInvalid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be ErrorKind::NamespaceAlreadyExists
| ) -> Result<()> { | ||
| if !self.namespace_exists(namespace).await? { | ||
| return Err(Error::new( | ||
| ErrorKind::DataInvalid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be NamespaceNotFound
| let db_name = validate_namespace(table.namespace())?; | ||
| if !self.namespace_exists(table.namespace()).await? { | ||
| return Err(Error::new( | ||
| ErrorKind::DataInvalid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
| )); | ||
| } | ||
| if !self.table_exists(table).await? { | ||
| return Err(Error::new(ErrorKind::DataInvalid, "Table does not exist")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be TableNotFound
|
|
||
| cleanup_namespace_dyn(catalog.as_ref(), &namespace).await; | ||
|
|
||
| assert!(catalog.get_namespace(&namespace).await.is_err()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good opportunity for us to enforce the correct error type across catalogs. Instead of assert_err, we can do something like assert_eq!(err, ErrorKind::xxx);
| catalog | ||
| .create_namespace(&namespace, HashMap::new()) | ||
| .await | ||
| .is_err() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, we can assert exact error type
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn test_list_namespaces_returns_only_top_level_namespaces() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we migrate these tests as well?
Which issue does this PR close?
What changes are included in this PR?
In this pr we introduced catalog test suite in catalog-loader, which could unify the behavior of catalogs.
Are these changes tested?
Yes.