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

Session settings #247

Merged
merged 6 commits into from
Dec 21, 2022
Merged

Conversation

DifferentialOrange
Copy link
Member

@DifferentialOrange DifferentialOrange commented Dec 9, 2022

Support session settings in a separate subpackage "settings" [1]. It allows to create a specific Select/Update requests to get or set session settings. Settings are independent for each connection.

I didn't forget about (remove if it is not applicable):

Closes #215

session.go Outdated Show resolved Hide resolved
tarantool_test.go Outdated Show resolved Hide resolved
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-215-session-settings branch from 4e2f115 to 31a1af1 Compare December 13, 2022 11:15
Use skipIfLess helpers like in other test conditions.

Follows #119
In Tarantool, user space ids starts from 512. You can set arbitrary id
or use autoincrement (sequence also starts from 512). Unfortunately,
mixing spaces with autoincremented ids and spaces with explicit ids may
cause id conflict [1]. Since there are cases when we cannot explicitly
set space id (creating a space with SQL), a short range of free ids
(from 512 to 515) causes problems. This patch increases range of free
ids (now it's from 512 to 615) so it should be ok until [1] is resolved.

1. tarantool/tarantool#8036

Part of #215
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-215-session-settings branch from da30c5b to 8ab466a Compare December 13, 2022 13:49
Set up package paths so queue test instances could be run with arbitrary
work_dir.

Part of #215
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-215-session-settings branch 3 times, most recently from 9bf4566 to c5cd184 Compare December 13, 2022 15:04
@DifferentialOrange DifferentialOrange marked this pull request as ready for review December 13, 2022 15:10
settings/const.go Outdated Show resolved Hide resolved
test_helpers/main.go Outdated Show resolved Hide resolved
test_helpers/main.go Show resolved Hide resolved
test_helpers/pool_helper.go Outdated Show resolved Hide resolved
settings/request.go Outdated Show resolved Hide resolved
settings/request_test.go Outdated Show resolved Hide resolved
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-215-session-settings branch from 12096dc to 404772c Compare December 14, 2022 14:57
Generate tmp work directories for each new Tarantool instance, if not
specified. It prevents possible directory clash issues.

Later `ioutil.TempDir` (deprecated since Go 1.17) must be replaced with
`os.MkdirTemp` (introduced in Go 1.16 as a replacement) when we drop
support of Go 1.16 an older.

Part of #215
Make skip helpers public. Add more wrappers to reduce code duplication.

Part of #215
settings/request.go Outdated Show resolved Hide resolved
settings/request.go Outdated Show resolved Hide resolved
settings/request_test.go Outdated Show resolved Hide resolved
Comment on lines 615 to 74
func TestRequestsAsync(t *testing.T) {
tests := []struct {
req tarantool.Request
async bool
}{
{req: NewErrorMarshalingEnabledSetRequest(false), async: false},
{req: NewErrorMarshalingEnabledGetRequest(), async: false},
{req: NewSQLDefaultEngineSetRequest("memtx"), async: false},
{req: NewSQLDefaultEngineGetRequest(), async: false},
{req: NewSQLDeferForeignKeysSetRequest(false), async: false},
{req: NewSQLDeferForeignKeysGetRequest(), async: false},
{req: NewSQLFullColumnNamesSetRequest(false), async: false},
{req: NewSQLFullColumnNamesGetRequest(), async: false},
{req: NewSQLFullMetadataSetRequest(false), async: false},
{req: NewSQLFullMetadataGetRequest(), async: false},
{req: NewSQLParserDebugSetRequest(false), async: false},
{req: NewSQLParserDebugGetRequest(), async: false},
{req: NewSQLRecursiveTriggersSetRequest(false), async: false},
{req: NewSQLRecursiveTriggersGetRequest(), async: false},
{req: NewSQLReverseUnorderedSelectsSetRequest(false), async: false},
{req: NewSQLReverseUnorderedSelectsGetRequest(), async: false},
{req: NewSQLSelectDebugSetRequest(false), async: false},
{req: NewSQLSelectDebugGetRequest(), async: false},
{req: NewSQLVDBEDebugSetRequest(false), async: false},
{req: NewSQLVDBEDebugGetRequest(), async: false},
}

for _, test := range tests {
if async := test.req.Async(); async != test.async {
t.Errorf("An invalid async %t, expected %t", async, test.async)
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still need to add unit-tests for methods:

Code(), Body(), Context(), Ctx()

It would be good to split integration tests and unit tests into two files: tarantool_test.go? (integration), request_test.go (unit).

Copy link
Member Author

Choose a reason for hiding this comment

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

Separated, added simple unit tests (without Body buffer comparison)

Copy link
Collaborator

Choose a reason for hiding this comment

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

without Body buffer comparison

If we want complete beauty, it is better to add (SelectRequest.Body() == GetRequest.Body(), UpdateRequest.Body() == SetRequest.Body()), but it doesn't look critical, so up to you.

settings/config.lua Outdated Show resolved Hide resolved
Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

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

Thank you for the patch!

Support session settings in a separate subpackage "settings" [1]. It
allows to create a specific requests to get or set session
settings. Settings are independent for each connection.

1. https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/_session_settings/

Closes #215
@DifferentialOrange DifferentialOrange force-pushed the DifferentialOrange/gh-215-session-settings branch from cdf2abe to 7665568 Compare December 16, 2022 12:16
@oleg-jukovec oleg-jukovec merged commit a1f28a6 into master Dec 21, 2022
@oleg-jukovec oleg-jukovec deleted the DifferentialOrange/gh-215-session-settings branch December 21, 2022 12:05
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.

Support session settings
3 participants