-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
containerized_test: create test module
Create new containerized test module focused in containerized deployment. This test will check uploading and downloading with a containerized imageio version. Initial version only tests that starting a server with an initial ticket works, and we can upload and download with that server. Signed-off-by: Albert Esteve <aesteve@redhat.com>
- Loading branch information
1 parent
56d1ed7
commit 32855ab
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright (C) 2022 Red Hat, Inc. | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
|
||
import json | ||
import http.client as http_client | ||
|
||
from ovirt_imageio._internal import config | ||
from ovirt_imageio._internal import server | ||
from ovirt_imageio._internal.units import KiB | ||
|
||
from . import testutil | ||
from . import http | ||
|
||
|
||
TICKET_SIZE = 16 * KiB | ||
|
||
|
||
def test_start_with_ticket(tmpdir): | ||
# Create ticket | ||
image = testutil.create_tempfile(tmpdir, name="disk.raw", size=TICKET_SIZE) | ||
ticket = testutil.create_ticket(size=TICKET_SIZE, url=f'file://{image}') | ||
ticket_id = ticket['uuid'] | ||
ticket_path = tmpdir.join("file.json") | ||
ticket_path.write(json.dumps(ticket)) | ||
|
||
# Start server with ticket | ||
cfg = config.load("test/conf/daemon.conf") | ||
srv = server.Server(cfg, ticket=ticket_path) | ||
srv.start() | ||
try: | ||
data = b"a" * (TICKET_SIZE // 2) + b"b" * (TICKET_SIZE // 2) | ||
# Test that we can upload | ||
with http.RemoteClient(srv.config) as c: | ||
res = c.put(f'/images/{ticket_id}', data) | ||
assert res.status == http_client.OK | ||
# Test that we can download and matches the uploaded data | ||
with http.RemoteClient(srv.config) as c: | ||
res = c.get(f'/images/{ticket_id}') | ||
assert res.read() == data | ||
assert res.status == http_client.OK | ||
finally: | ||
srv.stop() |