Unified Storage: Don't read before create (#102906)

* Unified Storage: Don't read before create

* test: use the existing test infra

* fix: support pq

We use pgx, but it seems to be wrapped in a pq driver shim, causing the errors to be remapped to pq's type. Weird
situation.

* feat: support CDK backend

* revert: there is a postgres_tests block

* fix(CDK): only check existence on ADDED updates

* fix(CDK): use ReadResource to deal with deleted files
This commit is contained in:
Mariell Hoversholm
2025-03-31 15:06:31 +02:00
committed by GitHub
parent 827d86a985
commit f0a6327edc
7 changed files with 93 additions and 18 deletions

View File

@ -2456,6 +2456,21 @@ func RunTestGuaranteedUpdateChecksStoredData(ctx context.Context, t *testing.T,
}
}
func RunTestValidUpdate(ctx context.Context, t *testing.T, store storage.Interface) {
pod := &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "test-ns"}}
key, pod := testPropagateStore(ctx, t, store, pod)
err := store.GuaranteedUpdate(ctx, key, &example.Pod{}, false, nil,
storage.SimpleUpdate(func(o runtime.Object) (runtime.Object, error) {
pod := o.(*example.Pod)
pod.Spec.Hostname = "example"
return pod, nil
}), pod)
if err != nil {
t.Errorf("got error on update: %v", err)
}
}
func RunTestGuaranteedUpdateWithConflict(ctx context.Context, t *testing.T, store storage.Interface) {
key, _ := testPropagateStore(ctx, t, store, &example.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "test-ns"}})