Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Generate fake_root for selfupdate test dynamically.
Browse files Browse the repository at this point in the history
Fixes OTA-2706 (Remove tests/test_data/fake_root). Also fixes the last
broken test due to the Target matching changes.

Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
  • Loading branch information
pattivacek committed Jul 19, 2019
1 parent dc944b5 commit 4620480
Show file tree
Hide file tree
Showing 22 changed files with 14 additions and 88 deletions.
2 changes: 1 addition & 1 deletion scripts/build_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LDFLAGS="-s" "$GITREPO_ROOT/scripts/test.sh"
cp -rf "$GITREPO_ROOT/tests/test_data/prov_selfupdate" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/tests/config/selfupdate.toml" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/scripts/selfupdate_server.py" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/tests/test_data/fake_root" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/tests/test_data/selfupdate_2.0" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/src/aktualizr_repo/run/create_repo.sh" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/src/aktualizr_repo/run/serve_repo.py" "$TEST_INSTALL_DESTDIR"

Expand Down
9 changes: 7 additions & 2 deletions scripts/selfupdate_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@

class Handler(BaseHTTPRequestHandler):
def do_GET(self):
print("GET: " + self.path)
local_path = self.path
print("GET: " + local_path)
# Fix annoying issue where aktualizr-repo generates metadata for the
# images repository in /image but aktualizr expects /repo.
if local_path.startswith("/repo/"):
local_path = local_path.replace('/repo/', '/image/', 1)
self.send_response(200)
self.end_headers()
with open(self.server.base_dir + "/fake_root/repo/" + self.path, "rb") as fl:
with open(self.server.base_dir + "/fake_root/repo/" + local_path, "rb") as fl:
self.wfile.write(bytearray(fl.read()))

def do_POST(self):
Expand Down
5 changes: 5 additions & 0 deletions scripts/test_install_aktualizr_and_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ dpkg-deb -I "$TEST_INSTALL_DESTDIR"/aktualizr*.deb && dpkg -i "$TEST_INSTALL_DES
akt_version=$(aktualizr --version)
(grep "$(cat "$TEST_INSTALL_DESTDIR"/aktualizr-version)" <<< "$akt_version") || (echo "$akt_version"; false)

aktualizr-repo generate --path "$TEST_INSTALL_DESTDIR/fake_root"
aktualizr-repo image --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --filename "$TEST_INSTALL_DESTDIR/selfupdate_2.0" --hwid selfupdate-device
aktualizr-repo addtarget --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --hwid selfupdate-device --serial 723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66
aktualizr-repo signtargets --path "$TEST_INSTALL_DESTDIR/fake_root"

TEMP_DIR=$(mktemp -d)
mkdir -m 700 -p "$TEMP_DIR/import"
cp "$TEST_INSTALL_DESTDIR"/prov_selfupdate/* "$TEMP_DIR/import"
Expand Down
2 changes: 1 addition & 1 deletion tests/config/selfupdate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ key_source = "file"

[provision]
primary_ecu_serial = "723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66"
primary_ecu_hardware_id = "patriotyk-laptop"
primary_ecu_hardware_id = "selfupdate-device"

[pacman]
type = "debian"
1 change: 0 additions & 1 deletion tests/test_data/fake_root/keys/director/key_type

This file was deleted.

27 changes: 0 additions & 27 deletions tests/test_data/fake_root/keys/director/private.key

This file was deleted.

9 changes: 0 additions & 9 deletions tests/test_data/fake_root/keys/director/public.key

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_data/fake_root/keys/image/key_type

This file was deleted.

27 changes: 0 additions & 27 deletions tests/test_data/fake_root/keys/image/private.key

This file was deleted.

9 changes: 0 additions & 9 deletions tests/test_data/fake_root/keys/image/public.key

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_data/fake_root/repo/director/1.root.json

This file was deleted.

Empty file.
1 change: 0 additions & 1 deletion tests/test_data/fake_root/repo/director/root.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_data/fake_root/repo/director/snapshot.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_data/fake_root/repo/director/targets.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_data/fake_root/repo/director/timestamp.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_data/fake_root/repo/repo/1.root.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_data/fake_root/repo/repo/root.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_data/fake_root/repo/repo/snapshot.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_data/fake_root/repo/repo/targets.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/test_data/fake_root/repo/repo/timestamp.json

This file was deleted.

0 comments on commit 4620480

Please sign in to comment.