|
5 | 5 |
|
6 | 6 | # Setup |
7 | 7 | mkdir -p scripts/temp |
8 | | -NS=$BMCS_CLI_NAMESPACE |
| 8 | +NS=$OCI_CLI_NAMESPACE |
9 | 9 | BUCKET=TestScriptBucket$(( ( RANDOM % 10000 ) + 1 )) |
10 | | -C=$BMCS_CLI_COMPARTMENT_ID |
| 10 | +C=$OCI_CLI_COMPARTMENT_ID |
11 | 11 | FILE=scripts/temp/content.txt |
12 | 12 | EMPTY_FILE=scripts/temp/empty_file |
13 | | -ARGS="--config-file $BMCS_CLI_CONFIG_FILE" |
| 13 | +ARGS="--config-file $OCI_CLI_CONFIG_FILE" |
14 | 14 |
|
| 15 | +# test that invoking with deprecated entry point 'bmcs' still works |
15 | 16 | bmcs $ARGS os ns get |
16 | | -bmcs $ARGS os bucket create -ns $NS --compartment-id $C --name $BUCKET |
| 17 | +oci $ARGS os ns get |
| 18 | +oci $ARGS os bucket create -ns $NS --compartment-id $C --name $BUCKET |
17 | 19 | echo 'example object content!' > $FILE |
18 | | -bmcs $ARGS os object put -ns $NS -bn $BUCKET --name object1 --file $FILE |
| 20 | +oci $ARGS os object put -ns $NS -bn $BUCKET --name object1 --file $FILE |
19 | 21 |
|
20 | 22 | # Put an object with metadata and ensure that you get the metadata back. |
21 | | -bmcs $ARGS os object put -ns $NS -bn $BUCKET --name object2 --file $FILE --metadata '{"foo1":"bar1","foo2":"bar2"}' |
| 23 | +oci $ARGS os object put -ns $NS -bn $BUCKET --name object2 --file $FILE --metadata '{"foo1":"bar1","foo2":"bar2"}' |
22 | 24 | # Two greps since they're on different lines |
23 | | -bmcs $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep foo1 |
24 | | -bmcs $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep bar2 |
| 25 | +oci $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep foo1 |
| 26 | +oci $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep bar2 |
25 | 27 |
|
26 | 28 | # Put an empty file and get it back. |
27 | 29 | touch $EMPTY_FILE |
28 | | -bmcs $ARGS os object put -ns $NS -bn $BUCKET --name object3 --file $EMPTY_FILE |
29 | | -bmcs $ARGS os object get -ns $NS -bn $BUCKET --name object3 --file - |
| 30 | +oci $ARGS os object put -ns $NS -bn $BUCKET --name object3 --file $EMPTY_FILE |
| 31 | +oci $ARGS os object get -ns $NS -bn $BUCKET --name object3 --file - |
30 | 32 |
|
31 | | -# Put a file from stdin and get it back |
32 | | -bmcs $ARGS os object put -ns $NS -bn $BUCKET --name object4 --file - <<< "This is some object content" |
33 | | -bmcs $ARGS os object get -ns $NS -bn $BUCKET --name object4 --file - | grep "This is some object content" |
| 33 | +# Put a file from stdin and get it back. Also check we can assign metadata when putting from stdin |
| 34 | +oci $ARGS os object put -ns $NS -bn $BUCKET --name object4 --metadata '{"foo1":"bar1","foo2":"bar2"}' --file - <<< "This is some object content" |
| 35 | +oci $ARGS os object get -ns $NS -bn $BUCKET --name object4 --file - | grep "This is some object content" |
| 36 | +oci $ARGS os object head -ns $NS -bn $BUCKET --name object4 | grep foo1 |
| 37 | +oci $ARGS os object head -ns $NS -bn $BUCKET --name object4 | grep bar2 |
34 | 38 |
|
35 | 39 | # Try a few variations on metadata format. |
36 | | -bmcs $ARGS os object put -ns $NS -bn $BUCKET --name object2 --file $FILE --metadata '{"foo1":"a b c '"'d'"'","foo2": "bar2"}' --force |
37 | | -bmcs $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep "a b c 'd'" |
38 | | -bmcs $ARGS os object put -ns $NS -bn $BUCKET --name object2 --file $FILE --metadata '{"foo1": "a b c d","foo2": "A second value."}' --force |
| 40 | +oci $ARGS os object put -ns $NS -bn $BUCKET --name object2 --file $FILE --metadata '{"foo1":"a b c '"'d'"'","foo2": "bar2"}' --force |
| 41 | +oci $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep "a b c 'd'" |
| 42 | +oci $ARGS os object put -ns $NS -bn $BUCKET --name object2 --file $FILE --metadata '{"foo1": "a b c d","foo2": "A second value."}' --force |
39 | 43 |
|
40 | 44 | # Two greps since they're on different lines |
41 | | -bmcs $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep "a b c d" |
42 | | -bmcs $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep "A second value." |
43 | | -bmcs $ARGS os object put -ns $NS -bn $BUCKET --name object2 --file $FILE --metadata '{"foo1":"bar1","foo2":"bar 2"}' --force |
| 45 | +oci $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep "a b c d" |
| 46 | +oci $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep "A second value." |
| 47 | +oci $ARGS os object put -ns $NS -bn $BUCKET --name object2 --file $FILE --metadata '{"foo1":"bar1","foo2":"bar 2"}' --force |
44 | 48 |
|
45 | 49 | # Two greps since they're on different lines |
46 | | -bmcs $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep "bar1" |
47 | | -bmcs $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep "bar 2" |
| 50 | +oci $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep "bar1" |
| 51 | +oci $ARGS os object head -ns $NS -bn $BUCKET --name object2 | grep "bar 2" |
48 | 52 |
|
49 | 53 | # Invalid metadata format |
50 | 54 | set +e |
51 | | -bmcs $ARGS os object put -ns $NS -bn $BUCKET --name object2 --file $FILE --metadata '{"foo1":"bar1","foo2"}' --force 2>&1 | grep "Parameter 'metadata' must be in JSON format." |
52 | | -bmcs $ARGS os bucket create -ns $NS --compartment-id $C --name $BUCKET --metadata '{"foo1"}' 2>&1 | grep "Parameter 'metadata' must be in JSON format." |
| 55 | +oci $ARGS os object put -ns $NS -bn $BUCKET --name object2 --file $FILE --metadata '{"foo1":"bar1","foo2"}' --force 2>&1 | grep "Parameter 'metadata' must be in JSON format." |
| 56 | +oci $ARGS os bucket create -ns $NS --compartment-id $C --name $BUCKET --metadata '{"foo1"}' 2>&1 | grep "Parameter 'metadata' must be in JSON format." |
53 | 57 | set -e |
54 | 58 |
|
55 | 59 | # Bucket metadata |
56 | | -bmcs $ARGS os bucket create -ns $NS --compartment-id $C --name ${BUCKET}_metadata --metadata '{"foo1":"bar1","foo2":"bar2"}' |
| 60 | +oci $ARGS os bucket create -ns $NS --compartment-id $C --name ${BUCKET}_metadata --metadata '{"foo1":"bar1","foo2":"bar2"}' |
57 | 61 | # Two greps since they're on different lines |
58 | | -bmcs $ARGS os bucket get -ns $NS --name ${BUCKET}_metadata | grep foo1 |
59 | | -bmcs $ARGS os bucket get -ns $NS --name ${BUCKET}_metadata | grep bar2 |
60 | | -bmcs $ARGS os bucket delete -ns $NS --name ${BUCKET}_metadata --force |
| 62 | +oci $ARGS os bucket get -ns $NS --name ${BUCKET}_metadata | grep foo1 |
| 63 | +oci $ARGS os bucket get -ns $NS --name ${BUCKET}_metadata | grep bar2 |
| 64 | +oci $ARGS os bucket delete -ns $NS --name ${BUCKET}_metadata --force |
61 | 65 |
|
62 | | -bmcs $ARGS os object list -ns $NS -bn $BUCKET |
63 | | -bmcs $ARGS os bucket list -ns $NS --compartment-id $C |
64 | | -bmcs $ARGS os object delete -ns $NS -bn $BUCKET --name object1 --force |
65 | | -bmcs $ARGS os object delete -ns $NS -bn $BUCKET --name object2 --force |
66 | | -bmcs $ARGS os object delete -ns $NS -bn $BUCKET --name object3 --force |
67 | | -bmcs $ARGS os object delete -ns $NS -bn $BUCKET --name object4 --force |
68 | | -bmcs $ARGS os bucket delete -ns $NS --name $BUCKET --force |
| 66 | +oci $ARGS os object list -ns $NS -bn $BUCKET |
| 67 | +oci $ARGS os bucket list -ns $NS --compartment-id $C |
| 68 | +oci $ARGS os object delete -ns $NS -bn $BUCKET --name object1 --force |
| 69 | +oci $ARGS os object delete -ns $NS -bn $BUCKET --name object2 --force |
| 70 | +oci $ARGS os object delete -ns $NS -bn $BUCKET --name object3 --force |
| 71 | +oci $ARGS os object delete -ns $NS -bn $BUCKET --name object4 --force |
| 72 | +oci $ARGS os bucket delete -ns $NS --name $BUCKET --force |
69 | 73 |
|
70 | 74 | echo "Success!" |
0 commit comments