Skip to content

Commit

Permalink
Merge a58cfcd into efb72b5
Browse files Browse the repository at this point in the history
  • Loading branch information
dichn committed Feb 16, 2022
2 parents efb72b5 + a58cfcd commit 07ccbf2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 2 additions & 0 deletions support/reftest/data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ test_data:
- path: /content/dist/rhel/atomic/7/7Server/x86_64/ostree/repo/refs/heads/rhel-atomic-host/7/x86_64/standard
content-type: text/plain
- path: /content/dist/rhel8/8.2/x86_64/baseos/iso/rhel-8.2-x86_64-boot.iso
- path: /content/dist/rhel8/8.2/x86_64/baseos/iso/does-not-exist.iso
state: absent
26 changes: 25 additions & 1 deletion support/reftest/reftest
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ class DBHandler:
Item=item,
)

def put_absent_item(self, path, from_date=None):
if not from_date:
from_date = self.default_from_date

item = {
"web_uri": {"S": path},
"from_date": {"S": from_date},
"object_key": {"S": "absent"},
"content_type": {"S": ""},
"metadata": {"M": {}},
}

self.dynamodb.put_item(
TableName=self.table,
Item=item,
)


class S3Handler:
def __init__(self, bucket, session):
Expand Down Expand Up @@ -242,6 +259,11 @@ def prepare(db_client, s3_client, config, opt):
# skip items that specify deploy=false
continue

if item.get("state") == "absent":
# skip all the downloading and checking when absent=true
db_client.put_absent_item(item["path"])
continue

url = config.prod_cdn_url + item["path"]
# download test data to local with a name "NamedTemporaryFile"
temp_file, cdn_data_checksum = download_to_local(
Expand Down Expand Up @@ -288,7 +310,9 @@ def main():
region_name=opt.default_region,
)

db_client = DBHandler(table=opt.table, config_table=opt.config_table, session=session)
db_client = DBHandler(
table=opt.table, config_table=opt.config_table, session=session
)
s3_client = S3Handler(bucket=opt.bucket, session=session)

res = False
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/test_exodus.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,16 @@ def test_no_content_type(cdn_test_url, testdata_path):
print(json.dumps(dict(r.headers), indent=2))
assert r.status_code == 200
assert r.headers["Content-Type"] == "application/octet-stream"


testdata_absent_item = [
"/content/dist/rhel8/8.2/x86_64/baseos/iso/does-not-exist.iso"
]


@pytest.mark.parametrize("testdata_path", testdata_absent_item)
def test_absent_item(cdn_test_url, testdata_path):
url = cdn_test_url + testdata_path
r = requests.get(url)
print(json.dumps(dict(r.headers), indent=2))
assert r.status_code == 404

0 comments on commit 07ccbf2

Please sign in to comment.