-
Notifications
You must be signed in to change notification settings - Fork 3
refactor: co-locate workload code and assets #159
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package bench | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "testing" | ||
| "testing/fstest" | ||
|
|
||
| "github.com/stroppy-io/stroppy/workloads" | ||
| ) | ||
|
|
||
| func TestLoadSQLUsesLocalOverrideBeforeEmbeddedFallback(t *testing.T) { | ||
| const ( | ||
| preset = "bench-sql-resolution-test" | ||
| fileName = "dialect.sql" | ||
| embeddedBody = "--+ query\n--= body\nSELECT 'embedded';\n" | ||
| localBody = "--+ query\n--= body\nSELECT 'local';\n" | ||
| ) | ||
|
|
||
| workloads.Register(preset, fstest.MapFS{ | ||
| fileName: &fstest.MapFile{Data: []byte(embeddedBody)}, | ||
| }) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| t.Run("embedded fallback", func(t *testing.T) { | ||
| t.Chdir(t.TempDir()) | ||
|
|
||
| assertSQLBody(t, preset, fileName, "SELECT 'embedded';") | ||
| }) | ||
|
|
||
| t.Run("local workload file", func(t *testing.T) { | ||
| directory := t.TempDir() | ||
| t.Chdir(directory) | ||
| if err := os.MkdirAll(filepath.Join("workloads", preset), 0o755); err != nil { | ||
|
Check failure on line 33 in pkg/bench/sql_file_test.go
|
||
| t.Fatal(err) | ||
| } | ||
| if err := os.WriteFile(filepath.Join("workloads", preset, fileName), []byte(localBody), 0o600); err != nil { | ||
|
Check failure on line 36 in pkg/bench/sql_file_test.go
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| t.Fatal(err) | ||
| } | ||
|
|
||
| assertSQLBody(t, preset, fileName, "SELECT 'local';") | ||
| }) | ||
| } | ||
|
|
||
| func assertSQLBody(t *testing.T, preset, fileName, want string) { | ||
| t.Helper() | ||
|
|
||
| sql, err := LoadSQL(preset, fileName) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if got, ok := sql.Query("query", "body"); !ok || got != want { | ||
|
Check failure on line 51 in pkg/bench/sql_file_test.go
|
||
| t.Fatalf("query body = %q, %v; want %q, true", got, ok, want) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Package all registers every built-in workload through blank imports. | ||
| package all | ||
|
|
||
| import ( | ||
| _ "github.com/stroppy-io/stroppy/workloads/execute_sql" | ||
| _ "github.com/stroppy-io/stroppy/workloads/simple" | ||
| _ "github.com/stroppy-io/stroppy/workloads/tpcb" | ||
| _ "github.com/stroppy-io/stroppy/workloads/tpcc" | ||
| _ "github.com/stroppy-io/stroppy/workloads/tpcds" | ||
| _ "github.com/stroppy-io/stroppy/workloads/tpch" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
...rnal/workloads/execute_sql/execute_sql.go → workloads/execute_sql/execute_sql.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.