Skip to content

Commit 4e65970

Browse files
committed
objstorageprovider: improve "open" test directive
Make the creator-id an optional key-value.
1 parent e0b71b5 commit 4e65970

File tree

10 files changed

+28
-19
lines changed

10 files changed

+28
-19
lines changed

objstorage/objstorageprovider/provider_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"context"
99
"fmt"
1010
"math/rand/v2"
11+
"slices"
1112
"strings"
1213
"sync"
1314
"sync/atomic"
@@ -64,7 +65,17 @@ func TestProvider(t *testing.T) {
6465
case "open":
6566
var fsDir string
6667
var creatorID objstorage.CreatorID
67-
scanArgs("<fs-dir> <remote-creator-id>", &fsDir, &creatorID)
68+
d.CmdArgs = slices.DeleteFunc(d.CmdArgs, func(arg datadriven.CmdArg) bool {
69+
switch arg.Key {
70+
case "creator-id":
71+
var id uint64
72+
arg.Scan(t, 0, &id)
73+
creatorID = objstorage.CreatorID(id)
74+
return true
75+
}
76+
return false
77+
})
78+
scanArgs("<fs-dir> [creator-id=X]", &fsDir)
6879

6980
st := DefaultSettings(fs, fsDir)
7081
if creatorID != 0 {

objstorage/objstorageprovider/testdata/provider/local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Basic provider tests without shared storage.
22

3-
open p0 0
3+
open p0
44
----
55
<local fs> mkdir-all: p0 0755
66
<local fs> open-dir: p0

objstorage/objstorageprovider/testdata/provider/local_readahead

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
open p1 1
1+
open p1 creator-id=1
22
----
33
<local fs> mkdir-all: p1 0755
44
<local fs> open-dir: p1

objstorage/objstorageprovider/testdata/provider/shared_attach

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Basic tests for obtaining the backing of shared objects and attaching them to
22
# another provider.
33

4-
open p1 1
4+
open p1 creator-id=1
55
----
66
<local fs> mkdir-all: p1 0755
77
<local fs> open-dir: p1
@@ -70,7 +70,7 @@ close
7070
<local fs> close: p1/REMOTE-OBJ-CATALOG-000001
7171
<local fs> close: p1
7272

73-
open p2 2
73+
open p2 creator-id=2
7474
----
7575
<local fs> mkdir-all: p2 0755
7676
<local fs> open-dir: p2

objstorage/objstorageprovider/testdata/provider/shared_attach_after_unref

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Tests when an object is unrefed before it is attached to another provider.
22

3-
open p5 5
3+
open p5 creator-id=5
44
----
55
<local fs> mkdir-all: p5 0755
66
<local fs> open-dir: p5
@@ -27,7 +27,7 @@ save-backing p5b1 1
2727
remove 1
2828
----
2929

30-
open p6 6
30+
open p6 creator-id=6
3131
----
3232
<local fs> mkdir-all: p6 0755
3333
<local fs> open-dir: p6

objstorage/objstorageprovider/testdata/provider/shared_attach_multi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Tests with the same shared object attached as multiple objects.
22

3-
open p1 1
3+
open p1 creator-id=1
44
----
55
<local fs> mkdir-all: p1 0755
66
<local fs> open-dir: p1
@@ -23,7 +23,7 @@ create 1 shared 1 100
2323
save-backing b1 1
2424
----
2525

26-
open p2 2
26+
open p2 creator-id=2
2727
----
2828
<local fs> mkdir-all: p2 0755
2929
<local fs> open-dir: p2

objstorage/objstorageprovider/testdata/provider/shared_basic

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Basic provider tests with shared storage.
22

3-
# open <fs-dir> <creator-id>
4-
open p1 1
3+
open p1 creator-id=1
54
----
65
<local fs> mkdir-all: p1 0755
76
<local fs> open-dir: p1
@@ -60,7 +59,7 @@ close
6059
<local fs> close: p1
6160

6261
# Test that the objects are there on re-open.
63-
open p1 1
62+
open p1 creator-id=1
6463
----
6564
<local fs> mkdir-all: p1 0755
6665
<local fs> open-dir: p1

objstorage/objstorageprovider/testdata/provider/shared_no_ref

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Tests with shared storage when ref tracking is disabled.
22

3-
# open <fs-dir> <creator-id>
4-
open p1 1
3+
open p1 creator-id=1
54
----
65
<local fs> mkdir-all: p1 0755
76
<local fs> open-dir: p1
@@ -73,7 +72,7 @@ close
7372
<local fs> close: p1
7473

7574
# Test that the objects are there on re-open.
76-
open p1 1
75+
open p1 creator-id=1
7776
----
7877
<local fs> mkdir-all: p1 0755
7978
<local fs> open-dir: p1
@@ -120,7 +119,7 @@ save-backing b1 1
120119
save-backing b2 1
121120
----
122121

123-
open p2 2
122+
open p2 creator-id=2
124123
----
125124
<local fs> mkdir-all: p2 0755
126125
<local fs> open-dir: p2

objstorage/objstorageprovider/testdata/provider/shared_readahead

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
open p1 1
1+
open p1 creator-id=1
22
----
33
<local fs> mkdir-all: p1 0755
44
<local fs> open-dir: p1

objstorage/objstorageprovider/testdata/provider/shared_remove

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
open p1 1
1+
open p1 creator-id=1
22
----
33
<local fs> mkdir-all: p1 0755
44
<local fs> open-dir: p1
@@ -38,7 +38,7 @@ save-backing b1 1
3838
save-backing b2 2
3939
----
4040

41-
open p2 2
41+
open p2 creator-id=2
4242
----
4343
<local fs> mkdir-all: p2 0755
4444
<local fs> open-dir: p2

0 commit comments

Comments
 (0)