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

Global setting of test_engine and clone_db #89

Merged
merged 2 commits into from
Jul 18, 2024
Merged

Conversation

ttonelli
Copy link
Contributor

This PR adds support to setting the test_engine and clone_db in a global fashion.

The idea is that we can set which engine to use for running the tests, and from which database to clone for each test. We currently can do that on a per-@test_rel basis, but we would like to support a way to globally define a default.

This has been tested with the package manager testing harness.

This PR also includes changes done by the JuliaFormatter.

@ttonelli ttonelli requested a review from mmcgr July 16, 2024 20:25
query = """
def result { 1 }
""",)
@test_rel(name = "No input, expected, or output", query = """
Copy link
Contributor

Choose a reason for hiding this comment

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

JuliaFormatter does not get on well with multi-line strings, which is most of @test_rel. Could you revert the formatting changes in this file?

Comment on lines +77 to +79
function set_test_engine!(new_engine::Option{AbstractString})
return TEST_DEFAULTS[].engine = new_engine
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a little redundant since there is already add_test_engine!(name::String) which adds the single listed engine to the pool. Given an empty pool the result is the same.

You are not the first to want to set a single default engine, though, so maybe it could map to

resize_test_engine_pool!(0)
add_test_engine!(name)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked a bit more into the code, and I think there's still benefits in having this specific container for the "default engine". The solution I implemented here has 2 main advantages over mapping to resize_test_engine_pool! + add_test_engine!:

  1. It is way more efficient, because resize_test_engine_pool! looks like a somewhat expensive operation, and add_test_engine! needs to actually call the RAI API to try to create the engine, and then detect a 409 to know the engine already exists. This is very heavyweight for just setting the name of the default engine.
  2. It does not mess up with the pool, so it can be used temporarily. That is, I can have a pool with a few engines, then I set the default engine to run a few tests, then when I unset the default engine and my pool is still there with my original engines. I understand this is not a great use case, but I think it's better if we don't have those side effects when setting the default engine name.

What do you think about this? I am fine either way, I can rewrite to delegate like you suggest, but in my opinion having an explicit default engine configuration would be better.

Copy link
Contributor

Choose a reason for hiding this comment

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

My objection is just the (minor) added complexity, but given it's an implementation detail rather than API I'm fine with it either way.

@@ -49,8 +114,10 @@ function create_test_database(
clone_db::Option{String}=nothing;
retries_remaining=3,
)
db = isnothing(clone_db) ? get_default_clone_db() : clone_db
!isnothing(db) && @debug("Cloning '$name' from '$db'")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice (debug) warning!

@@ -116,11 +116,11 @@ end
# Vectors.

# :a => [3, 4, 5]
type_string(::Vector{T}) where T = type_string(T)
type_string(::Vector{T}) where {T} = type_string(T)
Copy link
Contributor

Choose a reason for hiding this comment

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

So stylish!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You have to thank JuliaFormatter!

Copy link
Contributor

@mmcgr mmcgr left a comment

Choose a reason for hiding this comment

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

Looks good to me. The integration tests still need some de-JuliaFormatterisation, though.

Comment on lines +77 to +79
function set_test_engine!(new_engine::Option{AbstractString})
return TEST_DEFAULTS[].engine = new_engine
end
Copy link
Contributor

Choose a reason for hiding this comment

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

My objection is just the (minor) added complexity, but given it's an implementation detail rather than API I'm fine with it either way.

@ttonelli ttonelli merged commit 2c565c7 into master Jul 18, 2024
2 checks passed
@ttonelli ttonelli deleted the ttb-adjustments branch July 18, 2024 14:54
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.

2 participants