# Tests for getting the backing of shared objects and attaching them to another
# provider.

open p1 1
----
<local fs> mkdir-all: p1 0755
<local fs> open-dir: p1
<local fs> open-dir: p1
<local fs> create: p1/SHARED-CATALOG-000001
<local fs> sync: p1/SHARED-CATALOG-000001
<local fs> create: p1/marker.shared-catalog.000001.SHARED-CATALOG-000001
<local fs> close: p1/marker.shared-catalog.000001.SHARED-CATALOG-000001
<local fs> sync: p1
<local fs> sync: p1/SHARED-CATALOG-000001

create 1 shared
obj-one
----
<shared> create object "00000000000000000001-000001.sst"
<shared> close writer for "00000000000000000001-000001.sst" after 7 bytes

create 2 shared
obj-two
----
<shared> create object "00000000000000000001-000002.sst"
<shared> close writer for "00000000000000000001-000002.sst" after 7 bytes

create 3 shared
obj-three
----
<shared> create object "00000000000000000001-000003.sst"
<shared> close writer for "00000000000000000001-000003.sst" after 9 bytes

create 100 local
obj-one
----
<local fs> create: p1/000100.sst
<local fs> sync-data: p1/000100.sst
<local fs> close: p1/000100.sst

list
----
000001 -> shared://00000000000000000001-000001.sst
000002 -> shared://00000000000000000001-000002.sst
000003 -> shared://00000000000000000001-000003.sst
000100 -> p1/000100.sst

# Can't get backing of local object.
save-backing foo 100
----
object 000100 not on shared storage

save-backing b1 1
----

save-backing b2 2
----

save-backing b3 3
----

close
----
<local fs> sync: p1
<local fs> sync: p1/SHARED-CATALOG-000001
<local fs> close: p1

open p2 2
----
<local fs> mkdir-all: p2 0755
<local fs> open-dir: p2
<local fs> open-dir: p2
<local fs> create: p2/SHARED-CATALOG-000001
<local fs> sync: p2/SHARED-CATALOG-000001
<local fs> create: p2/marker.shared-catalog.000001.SHARED-CATALOG-000001
<local fs> close: p2/marker.shared-catalog.000001.SHARED-CATALOG-000001
<local fs> sync: p2
<local fs> sync: p2/SHARED-CATALOG-000001

create 100 shared
obj-one-hundred
----
<shared> create object "00000000000000000002-000100.sst"
<shared> close writer for "00000000000000000002-000100.sst" after 15 bytes

attach
b1 101
b2 102
b3 103
----
<local fs> sync: p2/SHARED-CATALOG-000001
000101 -> shared://00000000000000000001-000001.sst
000102 -> shared://00000000000000000001-000002.sst
000103 -> shared://00000000000000000001-000003.sst

list
----
000100 -> shared://00000000000000000002-000100.sst
000101 -> shared://00000000000000000001-000001.sst
000102 -> shared://00000000000000000001-000002.sst
000103 -> shared://00000000000000000001-000003.sst

read 101
----
<shared> size of object "00000000000000000001-000001.sst": 7
<shared> read object "00000000000000000001-000001.sst" at 0: 7 bytes
data: obj-one

read 102
----
<shared> size of object "00000000000000000001-000002.sst": 7
<shared> read object "00000000000000000001-000002.sst" at 0: 7 bytes
data: obj-two

read 103
----
<shared> size of object "00000000000000000001-000003.sst": 9
<shared> read object "00000000000000000001-000003.sst" at 0: 9 bytes
data: obj-three
