objectputget.robot 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. *** Settings ***
  16. Documentation S3 gateway test with aws cli
  17. Library OperatingSystem
  18. Library String
  19. Resource ../commonlib.robot
  20. Resource commonawslib.robot
  21. Test Setup Setup s3 tests
  22. *** Variables ***
  23. ${ENDPOINT_URL} http://s3g:9878
  24. ${OZONE_TEST} true
  25. ${BUCKET} generated
  26. *** Test Cases ***
  27. Put object to s3
  28. Execute echo "Randomtext" > /tmp/testfile
  29. ${result} = Execute AWSS3ApiCli put-object --bucket ${BUCKET} --key putobject/f1 --body /tmp/testfile
  30. ${result} = Execute AWSS3ApiCli list-objects --bucket ${BUCKET} --prefix putobject/
  31. Should contain ${result} f1
  32. Execute touch -f /tmp/zerobyte
  33. ${result} = Execute AWSS3ApiCli put-object --bucket ${BUCKET} --key putobject/zerobyte --body /tmp/zerobyte
  34. ${result} = Execute AWSS3ApiCli list-objects --bucket ${BUCKET} --prefix putobject/
  35. Should contain ${result} zerobyte
  36. #This test depends on the previous test case. Can't be executes alone
  37. Get object from s3
  38. ${result} = Execute AWSS3ApiCli get-object --bucket ${BUCKET} --key putobject/f1 /tmp/testfile.result
  39. Compare files /tmp/testfile /tmp/testfile.result
  40. Get Partial object from s3 with both start and endoffset
  41. ${result} = Execute AWSS3ApiCli get-object --bucket ${BUCKET} --key putobject/f1 --range bytes=0-4 /tmp/testfile1.result
  42. Should contain ${result} ContentRange
  43. Should contain ${result} bytes 0-4/11
  44. Should contain ${result} AcceptRanges
  45. ${expectedData} = Execute dd if=/tmp/testfile skip=0 bs=1 count=5 2>/dev/null
  46. ${actualData} = Execute cat /tmp/testfile1.result
  47. Should Be Equal ${expectedData} ${actualData}
  48. ${result} = Execute AWSS3ApiCli get-object --bucket ${BUCKET} --key putobject/f1 --range bytes=2-4 /tmp/testfile1.result1
  49. Should contain ${result} ContentRange
  50. Should contain ${result} bytes 2-4/11
  51. Should contain ${result} AcceptRanges
  52. ${expectedData} = Execute dd if=/tmp/testfile skip=2 bs=1 count=3 2>/dev/null
  53. ${actualData} = Execute cat /tmp/testfile1.result1
  54. Should Be Equal ${expectedData} ${actualData}
  55. # end offset greater than file size and start with in file length
  56. ${result} = Execute AWSS3ApiCli get-object --bucket ${BUCKET} --key putobject/f1 --range bytes=2-1000 /tmp/testfile1.result2
  57. Should contain ${result} ContentRange
  58. Should contain ${result} bytes 2-10/11
  59. Should contain ${result} AcceptRanges
  60. ${expectedData} = Execute dd if=/tmp/testfile skip=2 bs=1 count=9 2>/dev/null
  61. ${actualData} = Execute cat /tmp/testfile1.result2
  62. Should Be Equal ${expectedData} ${actualData}
  63. Get Partial object from s3 with both start and endoffset(start offset and endoffset is greater than file size)
  64. ${result} = Execute AWSS3APICli and checkrc get-object --bucket ${BUCKET} --key putobject/f1 --range bytes=10000-10000 /tmp/testfile2.result 255
  65. Should contain ${result} InvalidRange
  66. Get Partial object from s3 with both start and endoffset(end offset is greater than file size)
  67. ${result} = Execute AWSS3ApiCli get-object --bucket ${BUCKET} --key putobject/f1 --range bytes=0-10000 /tmp/testfile2.result
  68. Should contain ${result} ContentRange
  69. Should contain ${result} bytes 0-10/11
  70. Should contain ${result} AcceptRanges
  71. ${expectedData} = Execute cat /tmp/testfile
  72. ${actualData} = Execute cat /tmp/testfile2.result
  73. Should Be Equal ${expectedData} ${actualData}
  74. Get Partial object from s3 with only start offset
  75. ${result} = Execute AWSS3ApiCli get-object --bucket ${BUCKET} --key putobject/f1 --range bytes=0- /tmp/testfile3.result
  76. Should contain ${result} ContentRange
  77. Should contain ${result} bytes 0-10/11
  78. Should contain ${result} AcceptRanges
  79. ${expectedData} = Execute cat /tmp/testfile
  80. ${actualData} = Execute cat /tmp/testfile3.result
  81. Should Be Equal ${expectedData} ${actualData}
  82. Get Partial object from s3 with both start and endoffset which are equal
  83. ${result} = Execute AWSS3ApiCli get-object --bucket ${BUCKET} --key putobject/f1 --range bytes=0-0 /tmp/testfile4.result
  84. Should contain ${result} ContentRange
  85. Should contain ${result} bytes 0-0/11
  86. Should contain ${result} AcceptRanges
  87. ${expectedData} = Execute dd if=/tmp/testfile skip=0 bs=1 count=1 2>/dev/null
  88. ${actualData} = Execute cat /tmp/testfile4.result
  89. Should Be Equal ${expectedData} ${actualData}
  90. ${result} = Execute AWSS3ApiCli get-object --bucket ${BUCKET} --key putobject/f1 --range bytes=4-4 /tmp/testfile5.result
  91. Should contain ${result} ContentRange
  92. Should contain ${result} bytes 4-4/11
  93. Should contain ${result} AcceptRanges
  94. ${expectedData} = Execute dd if=/tmp/testfile skip=4 bs=1 count=1 2>/dev/null
  95. ${actualData} = Execute cat /tmp/testfile5.result
  96. Should Be Equal ${expectedData} ${actualData}
  97. Get Partial object from s3 to get last n bytes
  98. ${result} = Execute AWSS3ApiCli get-object --bucket ${BUCKET} --key putobject/f1 --range bytes=-4 /tmp/testfile6.result
  99. Should contain ${result} ContentRange
  100. Should contain ${result} bytes 7-10/11
  101. Should contain ${result} AcceptRanges
  102. ${expectedData} = Execute dd if=/tmp/testfile skip=7 bs=1 count=4 2>/dev/null
  103. ${actualData} = Execute cat /tmp/testfile6.result
  104. Should Be Equal ${expectedData} ${actualData}
  105. # if end is greater than file length, returns whole file
  106. ${result} = Execute AWSS3ApiCli get-object --bucket ${BUCKET} --key putobject/f1 --range bytes=-10000 /tmp/testfile7.result
  107. Should contain ${result} ContentRange
  108. Should contain ${result} bytes 0-10/11
  109. Should contain ${result} AcceptRanges
  110. ${expectedData} = Execute cat /tmp/testfile
  111. ${actualData} = Execute cat /tmp/testfile7.result
  112. Should Be Equal ${expectedData} ${actualData}
  113. Incorrect values for end and start offset
  114. ${result} = Execute AWSS3ApiCli get-object --bucket ${BUCKET} --key putobject/f1 --range bytes=-11-10000 /tmp/testfile8.result
  115. Should not contain ${result} ContentRange
  116. Should contain ${result} AcceptRanges
  117. ${expectedData} = Execute cat /tmp/testfile
  118. ${actualData} = Execute cat /tmp/testfile8.result
  119. Should Be Equal ${expectedData} ${actualData}
  120. ${result} = Execute AWSS3ApiCli get-object --bucket ${BUCKET} --key putobject/f1 --range bytes=11-8 /tmp/testfile9.result
  121. Should not contain ${result} ContentRange
  122. Should contain ${result} AcceptRanges
  123. ${expectedData} = Execute cat /tmp/testfile
  124. ${actualData} = Execute cat /tmp/testfile8.result
  125. Should Be Equal ${expectedData} ${actualData}
  126. Zero byte file
  127. ${result} = Execute AWSS3APICli and checkrc get-object --bucket ${BUCKET} --key putobject/zerobyte --range bytes=0-0 /tmp/testfile2.result 255
  128. Should contain ${result} InvalidRange
  129. ${result} = Execute AWSS3APICli and checkrc get-object --bucket ${BUCKET} --key putobject/zerobyte --range bytes=0-1 /tmp/testfile2.result 255
  130. Should contain ${result} InvalidRange
  131. ${result} = Execute AWSS3APICli and checkrc get-object --bucket ${BUCKET} --key putobject/zerobyte --range bytes=0-10000 /tmp/testfile2.result 255
  132. Should contain ${result} InvalidRange