-
Notifications
You must be signed in to change notification settings - Fork 1
fix/opv2-feedback #315
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
base: main
Are you sure you want to change the base?
fix/opv2-feedback #315
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1986,8 +1986,8 @@ func TestConvertTo_NoClickHouseLeavesEmpty(t *testing.T) { | |
| require.NotContains(t, dst.Annotations, ClickHousePendingAnnotation) | ||
| } | ||
|
|
||
| // TestConvertTo_ClickHouseOnlyNonConnectionKeys: keys like replicated/install | ||
| // must not be misread as an external connection. | ||
| // TestConvertTo_ClickHouseOnlyNonConnectionKeys: keys like replicated must not | ||
| // be misread as an external connection. (install is meaningful — see below.) | ||
| func TestConvertTo_ClickHouseOnlyNonConnectionKeys(t *testing.T) { | ||
| dst := &appsv2.WeightsAndBiases{} | ||
| src := newV1(map[string]interface{}{ | ||
|
|
@@ -2003,3 +2003,135 @@ func TestConvertTo_ClickHouseOnlyNonConnectionKeys(t *testing.T) { | |
| "only non-connection keys must not assert an external clickhouse") | ||
| require.NotContains(t, dst.Annotations, ClickHousePendingAnnotation) | ||
| } | ||
|
|
||
| // TestConvertTo_ClickHouseTopLevelSectionConnection: the Altinity subchart | ||
| // section supplies the connection when global.clickhouse doesn't. | ||
| func TestConvertTo_ClickHouseTopLevelSectionConnection(t *testing.T) { | ||
| dst := &appsv2.WeightsAndBiases{} | ||
| src := newV1(map[string]interface{}{ | ||
| "clickhouse": map[string]interface{}{ | ||
| "install": false, | ||
| "host": "ch.example.com", | ||
| "database": "wandb", | ||
| "password": map[string]interface{}{ | ||
| "valueFrom": map[string]interface{}{ | ||
| "secretKeyRef": map[string]interface{}{ | ||
| "name": "ch-secret", | ||
| "key": "password", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
| require.NoError(t, src.ConvertTo(dst)) | ||
|
|
||
| conn := dst.Spec.ClickHouse[appsv2.DefaultInstanceName].ExternalClickHouse | ||
| require.NotNil(t, conn, "install=false must assert an external clickhouse") | ||
| require.Equal(t, "ch-secret", conn.Password.Name) | ||
| require.Equal(t, "password", conn.Password.Key) | ||
|
|
||
| var pending map[string]string | ||
| require.NoError(t, json.Unmarshal([]byte(dst.Annotations[ClickHousePendingAnnotation]), &pending)) | ||
| require.Equal(t, "ch.example.com", pending["host"]) | ||
| require.Equal(t, "wandb", pending["database"]) | ||
| } | ||
|
|
||
| // TestConvertTo_ClickHouseInstallFalseGlobalConnection: install lives in the | ||
| // subchart section while the connection lives under global. | ||
| func TestConvertTo_ClickHouseInstallFalseGlobalConnection(t *testing.T) { | ||
| dst := &appsv2.WeightsAndBiases{} | ||
| src := newV1(map[string]interface{}{ | ||
| "clickhouse": map[string]interface{}{"install": false}, | ||
| "global": map[string]interface{}{ | ||
| "clickhouse": map[string]interface{}{"host": "ch.example.com"}, | ||
| }, | ||
| }) | ||
| require.NoError(t, src.ConvertTo(dst)) | ||
|
|
||
| require.NotNil(t, dst.Spec.ClickHouse[appsv2.DefaultInstanceName].ExternalClickHouse) | ||
| } | ||
|
|
||
| // TestConvertTo_ClickHouseGlobalWinsOverTopLevel: global.clickhouse is the | ||
| // app-facing connection, so it takes precedence per field. | ||
| func TestConvertTo_ClickHouseGlobalWinsOverTopLevel(t *testing.T) { | ||
| dst := &appsv2.WeightsAndBiases{} | ||
| src := newV1(map[string]interface{}{ | ||
| "clickhouse": map[string]interface{}{ | ||
| "install": false, | ||
| "host": "subchart.example.com", | ||
| "user": "subchart-user", | ||
| }, | ||
| "global": map[string]interface{}{ | ||
| "clickhouse": map[string]interface{}{"host": "global.example.com"}, | ||
| }, | ||
| }) | ||
| require.NoError(t, src.ConvertTo(dst)) | ||
|
|
||
| var pending map[string]string | ||
| require.NoError(t, json.Unmarshal([]byte(dst.Annotations[ClickHousePendingAnnotation]), &pending)) | ||
| require.Equal(t, "global.example.com", pending["host"], "global.clickhouse wins") | ||
| require.Equal(t, "subchart-user", pending["user"], "subchart fills what global omits") | ||
| } | ||
|
|
||
| // TestConvertTo_ClickHouseInstallTrueStaysManaged: v1 owned ClickHouse, so the | ||
| // spec is left empty for the defaulter even though a connection is present. | ||
| func TestConvertTo_ClickHouseInstallTrueStaysManaged(t *testing.T) { | ||
| dst := &appsv2.WeightsAndBiases{} | ||
| src := newV1(map[string]interface{}{ | ||
| "clickhouse": map[string]interface{}{"install": true}, | ||
| "global": map[string]interface{}{ | ||
| "clickhouse": map[string]interface{}{ | ||
| "host": "clickhouse.default.svc.cluster.local", | ||
| "user": "wandb", | ||
| }, | ||
| }, | ||
| }) | ||
| require.NoError(t, src.ConvertTo(dst)) | ||
|
|
||
| require.Empty(t, dst.Spec.ClickHouse, | ||
| "install=true must not assert external; the defaulter makes it managed") | ||
| require.NotContains(t, dst.Annotations, ClickHousePendingAnnotation) | ||
| } | ||
|
|
||
| // TestConvertTo_ClickHouseInstallFalseNoConnectionFails: falling through to the | ||
| // defaulter here would silently provision managed ClickHouse. | ||
| func TestConvertTo_ClickHouseInstallFalseNoConnectionFails(t *testing.T) { | ||
| dst := &appsv2.WeightsAndBiases{} | ||
| src := newV1(map[string]interface{}{ | ||
| "clickhouse": map[string]interface{}{ | ||
| "install": false, | ||
| "replicated": true, | ||
| }, | ||
| }) | ||
| err := src.ConvertTo(dst) | ||
| require.Error(t, err) | ||
| require.Contains(t, err.Error(), "install=false but no connection found") | ||
| } | ||
|
|
||
| // TestConvertTo_ClickHouseInstallStringBool: helm values are frequently | ||
| // stringly-typed; "false" must behave like false. | ||
| func TestConvertTo_ClickHouseInstallStringBool(t *testing.T) { | ||
| dst := &appsv2.WeightsAndBiases{} | ||
| src := newV1(map[string]interface{}{ | ||
| "clickhouse": map[string]interface{}{ | ||
| "install": "false", | ||
| "host": "ch.example.com", | ||
| }, | ||
| }) | ||
| require.NoError(t, src.ConvertTo(dst)) | ||
|
|
||
| require.NotNil(t, dst.Spec.ClickHouse[appsv2.DefaultInstanceName].ExternalClickHouse) | ||
| } | ||
|
|
||
| // TestConvertTo_ClickHouseInstallNonBoolIsUnset: an uninterpretable flag must | ||
| // not make a v1 object unservable; it falls back to connection presence. | ||
| func TestConvertTo_ClickHouseInstallNonBoolIsUnset(t *testing.T) { | ||
| dst := &appsv2.WeightsAndBiases{} | ||
| src := newV1(map[string]interface{}{ | ||
| "clickhouse": map[string]interface{}{ | ||
| "install": map[string]interface{}{"nested": "nonsense"}, | ||
| }, | ||
| }) | ||
| require.NoError(t, src.ConvertTo(dst)) | ||
| require.Empty(t, dst.Spec.ClickHouse) | ||
| } | ||
|
Comment on lines
+2009
to
+2137
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find the configured Ginkgo/Gomega suites and their setup patterns.
fd 'suite_test\.go$|go\.mod$' .
rg -n -C 3 'RunSpecs|RegisterFailHandler|ginkgo|gomega' \
--glob '*.go' --glob 'go.mod'Repository: wandb/operator Length of output: 1110 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Changed file candidates:\n'
git ls-files | rg '(^|/)weightsandbiases_conversion_test\.go$|suite_test\.go$' || true
printf '\nFile stats:\n'
wc -l $(git ls-files | rg '(^|/)weightsandbiases_conversion_test\.go$|suite_test\.go$' || true) | tail -20
printf '\nImports and test style in weightsandбиases_conversion_test.go:\n'
file=$(git ls-files | rg '(^|/)weightsandbiases_conversion_test\.go$' | head -1)
if [ -n "${file:-}" ]; then
sed -n '1,80p' "$file"
printf '\nFunction declarations in file:\n'
rg -n '^\s*func\s+Test|Describe|Context|It|When|Ginkgo|Gomega|require|assert' "$file" || true
fi
printf '\nRelevant suite_test.go examples:\n'
for f in internal/controller/common/common_suite_test.go internal/controller/suite_test.go internal/webhook/v2/webhook_suite_test.go; do
if [ -f "$f" ]; then
echo "--- $f"
sed -n '1,140p' "$f"
fi
doneRepository: wandb/operator Length of output: 46687 Move the added ClickHouse conversion cases into a Ginkgo/Gomega suite.
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: wandb/operator
Length of output: 9308
🏁 Script executed:
Repository: wandb/operator
Length of output: 243
🏁 Script executed:
Repository: wandb/operator
Length of output: 2267
Reject numeric ClickHouse install scalars before parsing.
scalarToStringrenders JSON numbers as strings such as"0"and"1", sofirstClickHouseInstallFlagcan returninstall: 1as enabled. Keep the declared behavior that onlytrue/falseset the flag, and add coverage for numeric values remaining unset.🤖 Prompt for AI Agents