Skip to content

test(r): configure the live warehouse tests from the shared contract, and run them in CI - #431

Draft
jat255 wants to merge 7 commits into
jat255/whhh-live-warehouse-pythonfrom
jat255/whhh-live-warehouse-r
Draft

jat255 wants to merge 7 commits into
jat255/whhh-live-warehouse-pythonfrom
jat255/whhh-live-warehouse-r

Conversation

@jat255

@jat255 jat255 commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds a CI workflow for the R live warehouse tests, and configures them with the same environment variables as the Python suite (#434). Before this, they ran only on a machine with hand-set R options and a hand-made ODBC data source.

Refs #303

Review notes

  • The workflow installs the Snowflake ODBC driver 3.21 and the Databricks (Simba Spark) driver 2.9.2 at the paths that odbc searches by default. The Snowflake 4.x driver installs to a path that odbc does not search, so the workflow uses 3.x.
  • For Databricks with GitHub OIDC, the workflow gets the GitHub token as the last step before the tests, because odbc exchanges it on every connection. If the token expires during a run, the fix is odbc's file-based OIDC option with a file that is refreshed during the run. This applies only if the Databricks service principal uses OIDC rather than a client secret.
  • The configuration check in the Python workflow moves to a script that both workflows call.

Testing

In a linux/amd64 container, both drivers install and load. Snowflake rejects the CI key only because its user does not exist yet, and Databricks rejects a dummy token with a 403. Locally, all 20 R live tests skip with a message that names the missing variable. R CMD check was not run, because only the test helper, the test README, and CI files changed.

For the R reviewer

The live tests used to read one commons.test.* R option per object and to connect to Databricks through a DSN named Databricks. Now the helper reads the environment variables in tests/shared/live-warehouse-env.json, connects with odbc::snowflake() (key pair) and odbc::databricks() (credentials from the environment), and uses the orders table that the provisioning script creates. The assertions in test-live-warehouses.R are unchanged. The old options no longer have an effect, so a local setup must move to the variables in the README. The contract gains a parameterized model and its JSON arguments for each warehouse, which replace the Databricks metric_view entry.

Agent-written notes

kata: whhh (milestone M10). Live runs wait on the same access as #434.

@jat255
jat255 added this pull request to stack #432 October 20, 2026 21:02
@jat255 jat255 changed the title jat255/whhh live warehouse r test(r): configure the live warehouse tests from the shared contract, and run them in CI Oct 20, 2026
@jat255 jat255 added r Affects the R implementation tests Related to testing or the test suite needs-manual-review Agent-created work that needs a human review labels Oct 20, 2026
@jat255
jat255 force-pushed the jat255/whhh-live-warehouse-r branch 2 times, most recently from 4ec8fe6 to 6857489 Compare October 20, 2026 21:27
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployed to Connect (dogfood.team.pct.posit.it): https://dogfood.team.pct.posit.it/connect/#/apps/d7a36cae-8f27-448b-a478-61b81fbe3942/draft/382029

Deployed from commit 8b095ae.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployed to Connect (connect.staging.pct.posit.it): https://connect.staging.pct.posit.it/connect/#/apps/ad662e1b-5048-4acc-9ad7-f9478c92274e/draft/3723

Deployed from commit 8b095ae.

@jat255
jat255 removed this pull request from stack #432 October 20, 2026 22:54
@jat255
jat255 force-pushed the jat255/whhh-live-warehouse-r branch from 6857489 to 4b65054 Compare October 20, 2026 22:54
@jat255
jat255 changed the base branch from jat255/whhh-live-warehouse-python to main October 20, 2026 22:54
@jat255
jat255 changed the base branch from main to jat255/whhh-live-warehouse-python October 20, 2026 22:55
@jat255
jat255 added this pull request to stack #435 October 20, 2026 22:55
@jat255
jat255 force-pushed the jat255/whhh-live-warehouse-r branch 4 times, most recently from 223a343 to dce7070 Compare October 21, 2026 03:33
…act, and run them in CI

The R live tests read R options naming each object. They now read the
variables in tests/shared/live-warehouse-env.json, the same ones the Python
suite reads, and use the orders table that provision-live-warehouse.py
creates in the configured schema. The contract gains a parameterized model
and its JSON arguments for each backend, which the R semantic-model tests
need; the Databricks metric_view entry becomes parameterized_model.

Snowflake connects with the key pair from SNOWFLAKE_PRIVATE_KEY_FILE. The
helper passes the account and host explicitly, though odbc reads both from
the same variables by default, so every contract variable it relies on is
visible at the call.

Databricks connects through odbc::databricks(), which finds a token, a client
secret, or a federated OIDC token in the environment, so the DSN named
Databricks is no longer needed.

R-live-warehouse.yaml installs each vendor's ODBC driver where odbc looks for
it and runs the tests from the same GitHub environments as the Python job.
For GitHub OIDC it fetches the token just before the tests, with the audience
the Databricks SDK uses, so one federation policy serves both languages. The
check for a configured backend moves to a script both workflows call.

Checked in a linux/amd64 container: both drivers install and load, Snowflake
rejects the not-yet-created service user's JWT, and Databricks rejects a
dummy token with a 403.
…missing

Snowflake leaves a relation the role holds no privilege on out of the listing, and the shared access-precedence contract reports a name the listing never returned as missing ahead of any refusal. The probe still classifies the query failure as an authorization refusal.
@jat255
jat255 force-pushed the jat255/whhh-live-warehouse-r branch from dce7070 to ed8e840 Compare October 21, 2026 22:02
The provisioning script now creates two semantic views over the orders table: ORDERS_MODEL, with a metric and a verified query, and ORDERS_PARAM_MODEL, with a variable. It grants them to the test role and prints the exports for the semantic view, verified query view, and parameterized model fixtures, with the arguments to call the model with. Variable names come from the env contract.
Snowflake folds a semantic view's member names to upper case, and commons reports the parameter as MIN_TOTAL, so the arguments the live test passes have to use that spelling.
The script quotes every other identifier it writes, but put the database and schema into the semantic view YAML, its verified query, and the procedure's schema argument bare, so a lowercase namespace would resolve to an upper-case one.
Doubling apostrophes is right for the YAML scalars but changed the identifiers inside the verified query's SQL, which named a different database for a namespace with an apostrophe.
@github-actions

Copy link
Copy Markdown
Contributor

Preview root: https://posit-dev.github.io/commons/pr-431/

Python site preview: https://posit-dev.github.io/commons/pr-431/py/

Built from the latest commit on this branch. The R links in it point at the published R site, which no pull request rebuilds.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-manual-review Agent-created work that needs a human review r Affects the R implementation tests Related to testing or the test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant