-
Notifications
You must be signed in to change notification settings - Fork 129
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
OLAP Connectors: Test the connection before exiting the "Add Data" modal #6892
Open
ericpgreen2
wants to merge
19
commits into
main
Choose a base branch
from
olap-connector-test-connection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
db3aaad
Fix bug in connector explorer
ericpgreen2 c6ff1fb
Add alternate form for DSN
ericpgreen2 f14df87
Add tests
ericpgreen2 95bd470
Cleanup
ericpgreen2 ddb29e7
Give the DSN form its own error state
ericpgreen2 34d3379
Remove debug line
ericpgreen2 fcb7da6
Add `waitForURL` to tests
ericpgreen2 019fa71
Merge branch 'main' into olap-connector-dsn-form
ericpgreen2 fc8061e
Update locator
ericpgreen2 1a38e5e
Use native Clickhouse protocol for placeholder
ericpgreen2 0b39021
Revert file changes if unable to connect to the OLAP connector
ericpgreen2 d3bdb40
Split `source` & `connector` form submission functions
ericpgreen2 1038545
Prevent closing the dialog when connection is being tested
ericpgreen2 34872f1
Adjust tests
ericpgreen2 3edc188
Add auth to ClickHouse testcontainer
ericpgreen2 10aa2b7
Self-review
ericpgreen2 7b423f3
Merge branch 'main' into olap-connector-dsn-form
ericpgreen2 66d4c48
Merge branch 'olap-connector-dsn-form' into olap-connector-test-conne…
ericpgreen2 3882e30
Fix `package-lock.json`?
ericpgreen2 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 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 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 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 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 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 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
66 changes: 66 additions & 0 deletions
66
web-common/src/features/connectors/olap/test-connection.ts
This file contains 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,66 @@ | ||
import { get } from "svelte/store"; | ||
import { queryClient } from "../../../lib/svelte-query/globalQueryClient"; | ||
import { waitUntil } from "../../../lib/waitUtils"; | ||
import { | ||
connectorServiceOLAPListTables, | ||
getConnectorServiceOLAPListTablesQueryKey, | ||
} from "../../../runtime-client"; | ||
import { fileArtifacts } from "../../entity-management/file-artifacts"; | ||
import { humanReadableErrorMessage } from "../../sources/modal/errors"; | ||
|
||
interface TestConnectorResult { | ||
success: boolean; | ||
error?: string; | ||
} | ||
|
||
export async function testOLAPConnector( | ||
instanceId: string, | ||
newConnectorFilePath: string, | ||
newConnectorName: string, | ||
): Promise<TestConnectorResult> { | ||
// Wait a sec – give the runtime time to start reconciling the file | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
|
||
// Wait for the file to reconcile | ||
const fileArtifact = fileArtifacts.getFileArtifact(newConnectorFilePath); | ||
await waitUntil(() => !get(fileArtifact.reconciling), 500); | ||
|
||
// Check for errors | ||
const hasErrorsStore = fileArtifact.getHasErrors(queryClient, instanceId); | ||
const hasErrors = get(hasErrorsStore); | ||
if (hasErrors) { | ||
// Get the first error message | ||
const firstError = get( | ||
fileArtifact.getAllErrors(queryClient, instanceId), | ||
)[0].message; | ||
|
||
return { | ||
success: false, | ||
error: firstError, | ||
}; | ||
} | ||
|
||
// Test the connection by calling `GetTables` | ||
const queryKey = getConnectorServiceOLAPListTablesQueryKey({ | ||
instanceId, | ||
connector: newConnectorName, | ||
}); | ||
const queryFn = () => | ||
connectorServiceOLAPListTables({ | ||
instanceId, | ||
connector: newConnectorName, | ||
}); | ||
try { | ||
await queryClient.fetchQuery({ queryKey, queryFn }); | ||
return { success: true }; | ||
} catch (e) { | ||
return { | ||
success: false, | ||
error: humanReadableErrorMessage( | ||
newConnectorName, | ||
e?.response?.data?.code, | ||
e?.response?.data?.message, | ||
), | ||
}; | ||
} | ||
} |
This file contains 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
Oops, something went wrong.
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.
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.
A method called
testOLAPConnector
seems to be also checking if the file has updated as well.Perhaps we should split them out, update and confirming of reconcile can be in a method. We could also get rid of the hard wait for
1000s
. We could check for version change in ProjectParser instead?