Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codecov #237

Merged
merged 114 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 106 commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
9fc335e
mock server test
TingDaoK Nov 14, 2022
b22af9a
add it to CO
TingDaoK Nov 14, 2022
569ab8e
fix the test
TingDaoK Nov 14, 2022
4dd231c
Merge branch 'main' into mock-s3-test
TingDaoK Nov 14, 2022
2dab4cc
format error
TingDaoK Nov 14, 2022
cc0a8cf
remove non-used import
TingDaoK Nov 14, 2022
ce35d84
missing -D
TingDaoK Nov 14, 2022
16062ac
update the windows one
TingDaoK Nov 14, 2022
12d2d18
why
TingDaoK Nov 14, 2022
9c305c5
accident
TingDaoK Nov 14, 2022
2a1bf09
extra line copied
TingDaoK Nov 14, 2022
d8fcccc
doesn't make sense
TingDaoK Nov 14, 2022
5f78137
what about the latest?
TingDaoK Nov 14, 2022
4c47712
handle different path
TingDaoK Nov 14, 2022
273149d
fix the path and add default
TingDaoK Nov 14, 2022
898fd7e
report the internal error case
TingDaoK Nov 14, 2022
6736f3c
get it ready for review
TingDaoK Nov 14, 2022
b1ff3ff
more test
TingDaoK Nov 15, 2022
f9f6e21
add readme and stuff
TingDaoK Nov 15, 2022
da67c11
I don't know
TingDaoK Nov 15, 2022
42ecec8
try to see if it's because the ubuntu version
TingDaoK Nov 15, 2022
7275878
try 18.04
TingDaoK Nov 15, 2022
7084d69
what about using container
TingDaoK Nov 15, 2022
ea32977
18
TingDaoK Nov 15, 2022
9cf7b8b
It probably not matters
TingDaoK Nov 15, 2022
577e358
remove not used line
TingDaoK Nov 15, 2022
d0fbc08
Merge branch 'main' into mock-s3-test
TingDaoK Nov 28, 2022
d3f076e
seems working
TingDaoK Dec 2, 2022
05d25fa
ops..
TingDaoK Dec 2, 2022
ba68502
exit if install failed
TingDaoK Dec 2, 2022
22ce005
exit when failed
TingDaoK Dec 2, 2022
c6fa19e
skip mock server test sliently?
TingDaoK Dec 2, 2022
1df2327
remove special CI
TingDaoK Dec 2, 2022
28fe75c
remove copy/pasted comment
TingDaoK Dec 5, 2022
3f5e699
Merge branch 'main' into mock-s3-test
TingDaoK Dec 5, 2022
2f70eb2
use {python}?
TingDaoK Dec 5, 2022
c537d24
Merge branch 'mock-s3-test' of github.com:awslabs/aws-c-s3 into mock-…
TingDaoK Dec 5, 2022
1d6f882
KEYS?
TingDaoK Dec 5, 2022
b2e1f38
data.keys?
TingDaoK Dec 5, 2022
c553c2a
env.config["python"]
TingDaoK Dec 5, 2022
94c3322
finally
TingDaoK Dec 5, 2022
a233c25
return op_success instead
TingDaoK Dec 5, 2022
4d74da6
test
TingDaoK Dec 5, 2022
47827d8
test
TingDaoK Dec 5, 2022
0582133
test
TingDaoK Dec 5, 2022
0f119bb
compiler flags
TingDaoK Dec 5, 2022
38c9378
check others
TingDaoK Dec 5, 2022
9c28514
test
TingDaoK Dec 5, 2022
d8c34ce
missing steps
TingDaoK Dec 5, 2022
82edcc7
use gcc
TingDaoK Dec 6, 2022
d376ebd
it can fail from another error code
TingDaoK Dec 6, 2022
54162fa
source prefix
TingDaoK Dec 6, 2022
220136d
include?
TingDaoK Dec 6, 2022
8986357
see if it works at all
TingDaoK Dec 6, 2022
56476fe
one
TingDaoK Dec 6, 2022
fcca46c
two
TingDaoK Dec 6, 2022
c13bdda
three
TingDaoK Dec 6, 2022
9f3dddb
remove install?
TingDaoK Dec 6, 2022
d99ed64
what about this?
TingDaoK Dec 6, 2022
566f2af
try this?
TingDaoK Dec 6, 2022
0911ec5
last shot
TingDaoK Dec 6, 2022
6f6f823
directory?
TingDaoK Dec 6, 2022
5b4a2c1
the root is aws-c-s3/aws-c-s3, so try this
TingDaoK Dec 6, 2022
ecc662a
directory
TingDaoK Dec 6, 2022
3f02e89
what about this
TingDaoK Dec 6, 2022
4a4435a
Keep hacking
TingDaoK Dec 6, 2022
518952b
that's it. I am done with it
TingDaoK Dec 6, 2022
6ea3025
use cmake coverage
TingDaoK Dec 6, 2022
4030912
the folder seems wrong
TingDaoK Dec 6, 2022
1d1b848
test
TingDaoK Dec 5, 2022
c3dfa7b
test
TingDaoK Dec 5, 2022
a32404a
test
TingDaoK Dec 5, 2022
a65c709
compiler flags
TingDaoK Dec 5, 2022
187b820
check others
TingDaoK Dec 5, 2022
97a00e6
test
TingDaoK Dec 5, 2022
2a338d7
missing steps
TingDaoK Dec 5, 2022
33c0ecb
use gcc
TingDaoK Dec 6, 2022
4a27662
source prefix
TingDaoK Dec 6, 2022
4e9272d
include?
TingDaoK Dec 6, 2022
dce0f0b
see if it works at all
TingDaoK Dec 6, 2022
351249b
one
TingDaoK Dec 6, 2022
a828419
two
TingDaoK Dec 6, 2022
7a57696
three
TingDaoK Dec 6, 2022
ebe7a63
remove install?
TingDaoK Dec 6, 2022
0c4aa04
what about this?
TingDaoK Dec 6, 2022
107fdeb
try this?
TingDaoK Dec 6, 2022
7a0c7ce
last shot
TingDaoK Dec 6, 2022
d78950e
directory?
TingDaoK Dec 6, 2022
b9a8a76
the root is aws-c-s3/aws-c-s3, so try this
TingDaoK Dec 6, 2022
8c44cdf
directory
TingDaoK Dec 6, 2022
4eab55d
what about this
TingDaoK Dec 6, 2022
0337814
Keep hacking
TingDaoK Dec 6, 2022
5faf7a8
that's it. I am done with it
TingDaoK Dec 6, 2022
74a9f56
use cmake coverage
TingDaoK Dec 6, 2022
fec58f3
the folder seems wrong
TingDaoK Dec 6, 2022
2e519db
Merge branch 'codecov' of github.com:awslabs/aws-c-s3 into codecov
TingDaoK Dec 6, 2022
d697bd2
try this
TingDaoK Dec 6, 2022
e17ec57
it can fail to import
TingDaoK Dec 6, 2022
8a1c496
try this out
TingDaoK Dec 6, 2022
a57870a
I am losing my mind
TingDaoK Dec 6, 2022
2b636d0
make it fail
TingDaoK Dec 6, 2022
a7ef552
fxxk off
TingDaoK Dec 6, 2022
033b528
just use executatble
TingDaoK Dec 6, 2022
c01875f
comment addresed
TingDaoK Dec 6, 2022
1ff5bca
Merge branch 'mock-s3-test' into codecov
TingDaoK Dec 6, 2022
b66afdb
add comment and remove useless ls
TingDaoK Dec 6, 2022
ae2ddf2
try to exculde tests
TingDaoK Dec 7, 2022
e6fab28
rename the test file to have test in it
TingDaoK Dec 7, 2022
98f4846
Merge branch 'main' into codecov
TingDaoK Dec 7, 2022
1f74f86
include path in the file name to remove tests/
TingDaoK Dec 7, 2022
0d4fd8b
add comment
TingDaoK Dec 7, 2022
6fc4787
actually this for cmake flag
TingDaoK Dec 7, 2022
1cc3fe8
get better path name
TingDaoK Dec 7, 2022
b87bb25
why not only report source/
TingDaoK Dec 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .builder/actions/mock_server_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
Setup local mock server for tests
"""

import Builder

import os
import sys
import subprocess
import atexit


class MockServerSetup(Builder.Action):
"""
Set up this machine for running the mock server test

This action should be run in the 'pre_build_steps' or 'build_steps' stage.
"""

def run(self, env):
self.env = env
python_path = sys.executable
# install dependency for mock server
self.env.shell.exec(python_path,
'-m', 'pip', 'install', 'h11', 'trio', check=True)
# check the deps can be import correctly
self.env.shell.exec(python_path,
'-c', 'import h11, trio', check=True)

# set cmake flag so mock server tests are enabled
env.project.config['cmake_args'].append(
'-DENABLE_MOCK_SERVER_TESTS=ON')

base_dir = os.path.dirname(os.path.realpath(__file__))
dir = os.path.join(base_dir, "..", "..", "tests", "mock_s3_server")
os.chdir(dir)

p = subprocess.Popen([python_path, "mock_s3_server.py"])

@atexit.register
def close_mock_server():
p.terminate()
8 changes: 8 additions & 0 deletions .github/.codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://docs.codecov.com/docs/common-recipe-list

comment: # this is a top-level key
layout: "reach, diff, flags, files"
behavior: default
require_changes: false # if true: only post the comment if coverage changes
require_base: no # [yes :: must have a base report to post]
require_head: yes # [yes :: must have a head report to post]
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,22 @@ jobs:
run: |
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build downstream -p ${{ env.PACKAGE_NAME }}

codecov-linux:
runs-on: ubuntu-22.04
steps:
- name: Checkout Sources
uses: actions/checkout@v3
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
chmod a+x builder
./builder build -p ${{ env.PACKAGE_NAME }} --compiler=gcc-9 --cmake-extra=-DASSERT_LOCK_HELD=ON --cmake-extra=-DCMAKE_C_FLAGS="-fprofile-arcs -ftest-coverage"
# Get test coverage report from CMAKE coverage
- name: Ctest Coverage
run: |
cd build/aws-c-s3
ctest -T coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ if (POLICY CMP0069)
endif()

option(ASSERT_LOCK_HELD "Enable ASSERT_SYNCED_DATA_LOCK_HELD for checking thread issue" OFF)
option(ENABLE_MOCK_SERVER_TESTS "Whether to run the integration tests that rely on pre-configured mock server" OFF)

if (ASSERT_LOCK_HELD)
add_definitions(-DASSERT_LOCK_HELD)
endif()
Expand Down
3 changes: 2 additions & 1 deletion builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
],
"test_steps": [
"test"
]
],
"pre_build_steps": ["mock-server-setup"]
}
4 changes: 3 additions & 1 deletion source/s3_meta_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@ void aws_s3_meta_request_set_fail_synced(

meta_request->synced_data.finish_result_set = true;

if (error_code == AWS_ERROR_S3_INVALID_RESPONSE_STATUS && failed_request != NULL) {
if ((error_code == AWS_ERROR_S3_INVALID_RESPONSE_STATUS ||
error_code == AWS_ERROR_S3_NON_RECOVERABLE_ASYNC_ERROR) &&
failed_request != NULL) {
aws_s3_meta_request_result_setup(
meta_request,
&meta_request->synced_data.finish_result,
Expand Down
7 changes: 7 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,12 @@ add_test_case(test_s3_list_bucket_init_mem_safety)
add_test_case(test_s3_list_bucket_init_mem_safety_optional_copies)
add_net_test_case(test_s3_list_bucket_valid)

# Tests against local mock server
if (ENABLE_MOCK_SERVER_TESTS)
add_net_test_case(multipart_upload_mock_server)
add_net_test_case(async_internal_error_from_complete_multipart_mock_server)
add_net_test_case(async_access_denied_from_complete_multipart_mock_server)
endif()

set(TEST_BINARY_NAME ${PROJECT_NAME}-tests)
generate_test_driver(${TEST_BINARY_NAME})
6 changes: 6 additions & 0 deletions tests/mock_s3_server/AbortMultipartUpload/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"status": 204,
"headers": {"Connection": "keep-alive"},
"body": [
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"status": 200,
"headers": {"Connection": "close"},
"body": [
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"",
"<Error>",
"<Code>AccessDenied</Code>",
"<Message>Access denied.</Message>",
"<RequestId>656c76696e6727732072657175657374</RequestId>",
"<HostId>Uuag1LuByRx9e6j5Onimru9pO4ZVKnJ2Qz7/C1NPcfTWAtRPfTaOFg==</HostId>",
"</Error>"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"status": 200,
"headers": {"Connection": "close"},
"body": [
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"",
"<Error>",
"<Code>InternalError</Code>",
"<Message>We encountered an internal error. Please try again.</Message>",
"<RequestId>656c76696e6727732072657175657374</RequestId>",
"<HostId>Uuag1LuByRx9e6j5Onimru9pO4ZVKnJ2Qz7/C1NPcfTWAtRPfTaOFg==</HostId>",
"</Error>"
]
}
13 changes: 13 additions & 0 deletions tests/mock_s3_server/CompleteMultipartUpload/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"status": 200,
"headers": {"Connection": "close"},
"body": [
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<CompleteMultipartUploadResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">",
"<Location>http://default.s3.us-west-2.amazonaws.com/default</Location>",
"<Bucket>default</Bucket>",
"<Key>default</Key>",
"<ETag>\"3858f62230ac3c915f300c664312c11f-9\"</ETag>",
"</CompleteMultipartUploadResult>"
]
}
12 changes: 12 additions & 0 deletions tests/mock_s3_server/CreateMultipartUpload/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"status": 200,
"headers": {},
"body": [
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<InitiateMultipartUploadResult>",
"<Bucket>default</Bucket>",
"<Key>default</Key>",
"<UploadId>defaultID</UploadId>",
"</InitiateMultipartUploadResult>"
]
}
40 changes: 40 additions & 0 deletions tests/mock_s3_server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Mock S3 server

A **NON-TLS** mock S3 server based on [python-hyper/h11](https://github.com/python-hyper/h11) and [trio](http://trio.readthedocs.io/en/latest/index.html). The server code implementation is based on the trio-server example from python-hyper/h11 [here](https://github.com/python-hyper/h11/blob/master/examples/trio-server.py). Only supports very basic mock response for request received.

## How to run the server

Python 3.5+ required.

- Install hyper/h11 and trio python module. `python3 -m pip install h11 trio`
- Run python. `python3 ./mock_s3_server.py`.

### Supported Operations

- CreateMultipartUpload
- CompleteMultipartUpload
- UploadPart
- AbortMultipartUpload

### Defined response

The server will read from ./{OperationName}/{Key}.json. The json file is formatted as following:

```json
{
"status": 200,
"headers": {"Connection": "close"},
"body": [
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"",
"<Error>",
"<Code>InternalError</Code>",
"<Message>We encountered an internal error. Please try again.</Message>",
"<RequestId>656c76696e6727732072657175657374</RequestId>",
"<HostId>Uuag1LuByRx9e6j5Onimru9pO4ZVKnJ2Qz7/C1NPcfTWAtRPfTaOFg==</HostId>",
"</Error>"
]
}
```

Where you can define the expected response status, header and response body. If the {Key}.json is not found from file system, it will load the `default.json`.
6 changes: 6 additions & 0 deletions tests/mock_s3_server/UploadPart/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"status": 200,
"headers": {"ETag": "b54357faf0632cce46e942fa68356b38", "Connection": "keep-alive"},
"body": [
]
}
Loading