From 71c4eb71ff984a24c8c75d95c66d5390ae5da325 Mon Sep 17 00:00:00 2001 From: Zee314159 <252806294@qq.com> Date: Tue, 17 Sep 2019 09:27:04 +0200 Subject: [PATCH 1/3] Change selfupdate to use fake package manager Signed-off-by: Zee314159 <252806294@qq.com> --- ci/gitlab/.gitlab-ci.yml | 2 +- scripts/test_aktualizr_deb_ubuntu.sh | 2 +- scripts/test_install_aktualizr.sh | 10 +++++ scripts/test_install_aktualizr_and_update.sh | 29 -------------- tests/CMakeLists.txt | 2 + tests/config/selfupdate.toml | 6 +-- tests/test_install_aktualizr_and_update.sh | 42 ++++++++++++++++++++ 7 files changed, 58 insertions(+), 35 deletions(-) create mode 100755 scripts/test_install_aktualizr.sh delete mode 100755 scripts/test_install_aktualizr_and_update.sh create mode 100755 tests/test_install_aktualizr_and_update.sh diff --git a/ci/gitlab/.gitlab-ci.yml b/ci/gitlab/.gitlab-ci.yml index 29c179c51d..5a5bfec72a 100644 --- a/ci/gitlab/.gitlab-ci.yml +++ b/ci/gitlab/.gitlab-ci.yml @@ -183,7 +183,7 @@ xenial-pkg-test: stage: pkg-test script: - ./scripts/test_install_garage_deploy.sh - - ./scripts/test_install_aktualizr_and_update.sh + - ./scripts/test_install_aktualizr.sh - ./scripts/test-uptane-generator.sh # -- yocto tests diff --git a/scripts/test_aktualizr_deb_ubuntu.sh b/scripts/test_aktualizr_deb_ubuntu.sh index 2f8959e22f..0079c0c756 100755 --- a/scripts/test_aktualizr_deb_ubuntu.sh +++ b/scripts/test_aktualizr_deb_ubuntu.sh @@ -9,4 +9,4 @@ IMG_TAG=aktualizr-deb-$(cat /proc/sys/kernel/random/uuid) echo "Building docker for testing aktualizr deb package inside it." docker build -t "${IMG_TAG}" -f "${INSTALL_DOCKERFILE}" . echo "Running docker container with aktualizr debian package inside." -docker run --rm -v "${PKG_SRCDIR}":/persistent -t "${IMG_TAG}" /bin/bash -c "/scripts/test_install_aktualizr_and_update.sh && /scripts/test-uptane-generator.sh" +docker run --rm -v "${PKG_SRCDIR}":/persistent -t "${IMG_TAG}" /bin/bash -c "/scripts/test-uptane-generator.sh" diff --git a/scripts/test_install_aktualizr.sh b/scripts/test_install_aktualizr.sh new file mode 100755 index 0000000000..995607aed9 --- /dev/null +++ b/scripts/test_install_aktualizr.sh @@ -0,0 +1,10 @@ +#! /bin/bash + +set -exuo pipefail + +TEST_INSTALL_DESTDIR=${TEST_INSTALL_DESTDIR:-/persistent} + +dpkg-deb -I "$TEST_INSTALL_DESTDIR"/aktualizr*.deb && dpkg -i "$TEST_INSTALL_DESTDIR"/aktualizr*.deb +akt_version=$(aktualizr --version) +(grep "$(cat "$TEST_INSTALL_DESTDIR"/aktualizr-version)" <<< "$akt_version") || (echo "$akt_version"; false) + diff --git a/scripts/test_install_aktualizr_and_update.sh b/scripts/test_install_aktualizr_and_update.sh deleted file mode 100755 index 9b736390d6..0000000000 --- a/scripts/test_install_aktualizr_and_update.sh +++ /dev/null @@ -1,29 +0,0 @@ -#! /bin/bash - -set -exuo pipefail - -TEST_INSTALL_DESTDIR=${TEST_INSTALL_DESTDIR:-/persistent} - -"$TEST_INSTALL_DESTDIR/selfupdate_server.py" 8000 "$TEST_INSTALL_DESTDIR"& - -dpkg-deb -I "$TEST_INSTALL_DESTDIR"/aktualizr*.deb && dpkg -i "$TEST_INSTALL_DESTDIR"/aktualizr*.deb -akt_version=$(aktualizr --version) -(grep "$(cat "$TEST_INSTALL_DESTDIR"/aktualizr-version)" <<< "$akt_version") || (echo "$akt_version"; false) - -uptane-generator generate --path "$TEST_INSTALL_DESTDIR/fake_root" -uptane-generator image --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --filename "$TEST_INSTALL_DESTDIR/selfupdate_2.0" --hwid selfupdate-device -uptane-generator addtarget --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --hwid selfupdate-device --serial 723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66 -uptane-generator 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" -echo -e "[storage]\\npath = \"$TEMP_DIR\"\\n[import]\\nbase_path = \"$TEMP_DIR/import\"" > "$TEMP_DIR/conf.toml" -aktualizr -c "$TEST_INSTALL_DESTDIR"/selfupdate.toml -c "$TEMP_DIR/conf.toml" once - -# check that the version was updated -akt_version=$(aktualizr --version) -(grep 2.0-selfupdate <<< "$akt_version") || (echo "$akt_version"; false) - -# check that aktualizr-info succeeds -aktualizr-info diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 249c5cf192..3a74833b9c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -192,6 +192,8 @@ add_test(NAME test_backend_failure COMMAND ${PROJECT_SOURCE_DIR}/tests/test_backend_failure.py --build-dir ${PROJECT_BINARY_DIR} --src-dir ${PROJECT_SOURCE_DIR}) +add_test(NAME test_install_aktualizr_and_update COMMAND ${PROJECT_SOURCE_DIR}/tests/test_install_aktualizr_and_update.sh ${PROJECT_BINARY_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) + add_executable(aktualizr-cycle-simple aktualizr_cycle_simple.cc) target_link_libraries(aktualizr-cycle-simple aktualizr_static_lib ${AKTUALIZR_EXTERNAL_LIBS}) aktualizr_source_file_checks(aktualizr_cycle_simple.cc) diff --git a/tests/config/selfupdate.toml b/tests/config/selfupdate.toml index 8d67d24c47..7c106e00a6 100644 --- a/tests/config/selfupdate.toml +++ b/tests/config/selfupdate.toml @@ -1,6 +1,3 @@ -[tls] -server = "http://localhost:8000" - [import] tls_cacert_path = "ca.pem" tls_pkey_path = "pkey.pem" @@ -16,4 +13,5 @@ primary_ecu_serial = "723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51 primary_ecu_hardware_id = "selfupdate-device" [pacman] -type = "debian" +type = "none" + diff --git a/tests/test_install_aktualizr_and_update.sh b/tests/test_install_aktualizr_and_update.sh new file mode 100755 index 0000000000..97a7024bdf --- /dev/null +++ b/tests/test_install_aktualizr_and_update.sh @@ -0,0 +1,42 @@ +#! /bin/bash + +set -exuo pipefail +SCRIPT_DIR="$(dirname "$0")" +TEST_INSTALL_DESTDIR=$(mktemp -d)/install +./scripts/selfupdate_server.py 0 "$TEST_INSTALL_DESTDIR"& +PORT=$("$SCRIPT_DIR/find_listening_port.sh" $!) +trap 'kill %1' EXIT + +until curl 127.0.0.1:"$PORT" &> /dev/null; do + sleep 0.2 +done + +$1/src/aktualizr_primary/aktualizr --version + +$1/src/uptane_generator/uptane-generator generate --path "$TEST_INSTALL_DESTDIR/fake_root" +$1/src/uptane_generator/uptane-generator image --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --filename "./tests/test_data/selfupdate_2.0" --hwid selfupdate-device +$1/src/uptane_generator/uptane-generator addtarget --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --hwid selfupdate-device --serial 723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66 +$1/src/uptane_generator/uptane-generator signtargets --path "$TEST_INSTALL_DESTDIR/fake_root" + +TEMP_DIR=$(mktemp -d) +mkdir -m 700 -p "$TEMP_DIR/import" +cp ./tests/test_data/prov_selfupdate/* "$TEMP_DIR/import" +echo -e "[storage]\\npath = \"$TEMP_DIR\"\\n[import]\\nbase_path = \"$TEMP_DIR/import\"" > "$TEMP_DIR/conf.toml" +echo -e "[tls]\\nserver = \"http://localhost:$PORT\"" >> "$TEMP_DIR/conf.toml" +$1/src/aktualizr_primary/aktualizr -c ./tests/config/selfupdate.toml -c "$TEMP_DIR/conf.toml" once + +# check the updated file appeared in the installation directory and sha256sum matches expectation +TEST_INSTALL_IMAGE_DIR=$TEMP_DIR/images +if [ ! -d $TEST_INSTALL_IMAGE_DIR ]; then + echo "$TEST_INSTALL_IMAGE_DIR does not exist" + exit 1 +else + cd $TEST_INSTALL_IMAGE_DIR + for filename in `ls`; do + checksum=$(echo $(sha256sum $filename) | cut -f 1 -d " " | tr [a-f] [A-F] ) + if [ "$checksum" != "$filename" ]; then + echo "ERROR: sha256sum does not match." + exit 1 + fi + done +fi From d6db79047dbc0fb2197c9462e026b63875b7f89d Mon Sep 17 00:00:00 2001 From: Zee314159 <252806294@qq.com> Date: Tue, 24 Sep 2019 05:18:34 +0200 Subject: [PATCH 2/3] Run aktualizr-info to get hash Signed-off-by: Zee314159 <252806294@qq.com> --- ci/gitlab/.gitlab-ci.yml | 1 + tests/test_install_aktualizr_and_update.sh | 35 ++++++++++++++-------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ci/gitlab/.gitlab-ci.yml b/ci/gitlab/.gitlab-ci.yml index 5a5bfec72a..24ed4320d0 100644 --- a/ci/gitlab/.gitlab-ci.yml +++ b/ci/gitlab/.gitlab-ci.yml @@ -172,6 +172,7 @@ bionic-pkg-test: stage: pkg-test script: - ./scripts/test_install_garage_deploy.sh + - ./scripts/test_install_aktualizr.sh xenial-pkg-test: variables: diff --git a/tests/test_install_aktualizr_and_update.sh b/tests/test_install_aktualizr_and_update.sh index 97a7024bdf..0fa6ed0059 100755 --- a/tests/test_install_aktualizr_and_update.sh +++ b/tests/test_install_aktualizr_and_update.sh @@ -24,19 +24,28 @@ cp ./tests/test_data/prov_selfupdate/* "$TEMP_DIR/import" echo -e "[storage]\\npath = \"$TEMP_DIR\"\\n[import]\\nbase_path = \"$TEMP_DIR/import\"" > "$TEMP_DIR/conf.toml" echo -e "[tls]\\nserver = \"http://localhost:$PORT\"" >> "$TEMP_DIR/conf.toml" $1/src/aktualizr_primary/aktualizr -c ./tests/config/selfupdate.toml -c "$TEMP_DIR/conf.toml" once - -# check the updated file appeared in the installation directory and sha256sum matches expectation TEST_INSTALL_IMAGE_DIR=$TEMP_DIR/images -if [ ! -d $TEST_INSTALL_IMAGE_DIR ]; then - echo "$TEST_INSTALL_IMAGE_DIR does not exist" +filename=$(echo $($1/src/aktualizr_info/aktualizr-info -c ./tests/config/selfupdate.toml -c "$TEMP_DIR/conf.toml" --director-target | jq '(.signed.targets["selfupdate_2.0"].hashes.sha256)') | tr [a-f] [A-F] | tr -d '"') + +ls $TEST_INSTALL_IMAGE_DIR/$filename + +if [ $? -ne 0 ];then + echo "ERROR: $filename does not exist or sha256sum does not match." exit 1 -else - cd $TEST_INSTALL_IMAGE_DIR - for filename in `ls`; do - checksum=$(echo $(sha256sum $filename) | cut -f 1 -d " " | tr [a-f] [A-F] ) - if [ "$checksum" != "$filename" ]; then - echo "ERROR: sha256sum does not match." - exit 1 - fi - done fi + +# check the updated file appeared in the installation directory and sha256sum matches expectation +#TEST_INSTALL_IMAGE_DIR=$TEMP_DIR/images +# if [ ! -d $TEST_INSTALL_IMAGE_DIR ]; then +# echo "$TEST_INSTALL_IMAGE_DIR does not exist" +# exit 1 +#else +# cd $TEST_INSTALL_IMAGE_DIR +# for filename in `ls`; do +# checksum=$(echo $(sha256sum $filename) | cut -f 1 -d " " | tr [a-f] [A-F] ) +# if [ "$checksum" != "$filename" ]; then +# echo "ERROR: sha256sum does not match." +# exit 1 +# fi +# done +#fi From cfa5179ff89486f5d230de9f63b1932c9a3fb535 Mon Sep 17 00:00:00 2001 From: Zee314159 <252806294@qq.com> Date: Tue, 24 Sep 2019 08:12:57 +0200 Subject: [PATCH 3/3] Rename selfupdate to testupdate Signed-off-by: Zee314159 <252806294@qq.com> --- scripts/build_ubuntu.sh | 8 ++--- ...fupdate_server.py => testupdate_server.py} | 0 src/libaktualizr/config/config_test.cc | 2 +- .../{selfupdate.toml => testupdate.toml} | 2 +- .../ca.pem | 0 .../client.pem | 0 .../device_id | 0 .../ecukey.pem | 0 .../ecukey.pub | 0 .../is_registered | 0 .../misconfigured_ecus | 0 .../pkey.pem | 0 .../secondaries_list | 0 .../{selfupdate_2.0 => testupdate_2.0} | Bin tests/test_fixtures.py | 6 ++-- tests/test_install_aktualizr_and_update.sh | 33 +++++------------- 16 files changed, 18 insertions(+), 33 deletions(-) rename scripts/{selfupdate_server.py => testupdate_server.py} (100%) rename tests/config/{selfupdate.toml => testupdate.toml} (86%) rename tests/test_data/{prov_selfupdate => prov_testupdate}/ca.pem (100%) rename tests/test_data/{prov_selfupdate => prov_testupdate}/client.pem (100%) rename tests/test_data/{prov_selfupdate => prov_testupdate}/device_id (100%) rename tests/test_data/{prov_selfupdate => prov_testupdate}/ecukey.pem (100%) rename tests/test_data/{prov_selfupdate => prov_testupdate}/ecukey.pub (100%) rename tests/test_data/{prov_selfupdate => prov_testupdate}/is_registered (100%) rename tests/test_data/{prov_selfupdate => prov_testupdate}/misconfigured_ecus (100%) rename tests/test_data/{prov_selfupdate => prov_testupdate}/pkey.pem (100%) rename tests/test_data/{prov_selfupdate => prov_testupdate}/secondaries_list (100%) rename tests/test_data/{selfupdate_2.0 => testupdate_2.0} (100%) diff --git a/scripts/build_ubuntu.sh b/scripts/build_ubuntu.sh index c8de1fa292..26d3baa679 100755 --- a/scripts/build_ubuntu.sh +++ b/scripts/build_ubuntu.sh @@ -17,10 +17,10 @@ mkdir -p "$TEST_INSTALL_DESTDIR" LDFLAGS="-s" "$GITREPO_ROOT/scripts/test.sh" # copy provisioning data and scripts -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/selfupdate_2.0" "$TEST_INSTALL_DESTDIR" +cp -rf "$GITREPO_ROOT/tests/test_data/prov_testupdate" "$TEST_INSTALL_DESTDIR" +cp -rf "$GITREPO_ROOT/tests/config/testupdate.toml" "$TEST_INSTALL_DESTDIR" +cp -rf "$GITREPO_ROOT/scripts/testupdate_server.py" "$TEST_INSTALL_DESTDIR" +cp -rf "$GITREPO_ROOT/tests/test_data/testupdate_2.0" "$TEST_INSTALL_DESTDIR" cp -rf "$GITREPO_ROOT/src/uptane_generator/run/create_repo.sh" "$TEST_INSTALL_DESTDIR" cp -rf "$GITREPO_ROOT/src/uptane_generator/run/serve_repo.py" "$TEST_INSTALL_DESTDIR" diff --git a/scripts/selfupdate_server.py b/scripts/testupdate_server.py similarity index 100% rename from scripts/selfupdate_server.py rename to scripts/testupdate_server.py diff --git a/src/libaktualizr/config/config_test.cc b/src/libaktualizr/config/config_test.cc index 54a155a213..2c3e7d2f91 100644 --- a/src/libaktualizr/config/config_test.cc +++ b/src/libaktualizr/config/config_test.cc @@ -46,7 +46,7 @@ TEST(config, TomlInt) { */ TEST(config, TomlPrimarySerial) { RecordProperty("zephyr_key", "OTA-988"); - Config conf("tests/config/selfupdate.toml"); + Config conf("tests/config/testupdate.toml"); EXPECT_EQ(conf.provision.primary_ecu_serial, "723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66"); } diff --git a/tests/config/selfupdate.toml b/tests/config/testupdate.toml similarity index 86% rename from tests/config/selfupdate.toml rename to tests/config/testupdate.toml index 7c106e00a6..90fcba63b0 100644 --- a/tests/config/selfupdate.toml +++ b/tests/config/testupdate.toml @@ -10,7 +10,7 @@ key_source = "file" [provision] primary_ecu_serial = "723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66" -primary_ecu_hardware_id = "selfupdate-device" +primary_ecu_hardware_id = "testupdate-device" [pacman] type = "none" diff --git a/tests/test_data/prov_selfupdate/ca.pem b/tests/test_data/prov_testupdate/ca.pem similarity index 100% rename from tests/test_data/prov_selfupdate/ca.pem rename to tests/test_data/prov_testupdate/ca.pem diff --git a/tests/test_data/prov_selfupdate/client.pem b/tests/test_data/prov_testupdate/client.pem similarity index 100% rename from tests/test_data/prov_selfupdate/client.pem rename to tests/test_data/prov_testupdate/client.pem diff --git a/tests/test_data/prov_selfupdate/device_id b/tests/test_data/prov_testupdate/device_id similarity index 100% rename from tests/test_data/prov_selfupdate/device_id rename to tests/test_data/prov_testupdate/device_id diff --git a/tests/test_data/prov_selfupdate/ecukey.pem b/tests/test_data/prov_testupdate/ecukey.pem similarity index 100% rename from tests/test_data/prov_selfupdate/ecukey.pem rename to tests/test_data/prov_testupdate/ecukey.pem diff --git a/tests/test_data/prov_selfupdate/ecukey.pub b/tests/test_data/prov_testupdate/ecukey.pub similarity index 100% rename from tests/test_data/prov_selfupdate/ecukey.pub rename to tests/test_data/prov_testupdate/ecukey.pub diff --git a/tests/test_data/prov_selfupdate/is_registered b/tests/test_data/prov_testupdate/is_registered similarity index 100% rename from tests/test_data/prov_selfupdate/is_registered rename to tests/test_data/prov_testupdate/is_registered diff --git a/tests/test_data/prov_selfupdate/misconfigured_ecus b/tests/test_data/prov_testupdate/misconfigured_ecus similarity index 100% rename from tests/test_data/prov_selfupdate/misconfigured_ecus rename to tests/test_data/prov_testupdate/misconfigured_ecus diff --git a/tests/test_data/prov_selfupdate/pkey.pem b/tests/test_data/prov_testupdate/pkey.pem similarity index 100% rename from tests/test_data/prov_selfupdate/pkey.pem rename to tests/test_data/prov_testupdate/pkey.pem diff --git a/tests/test_data/prov_selfupdate/secondaries_list b/tests/test_data/prov_testupdate/secondaries_list similarity index 100% rename from tests/test_data/prov_selfupdate/secondaries_list rename to tests/test_data/prov_testupdate/secondaries_list diff --git a/tests/test_data/selfupdate_2.0 b/tests/test_data/testupdate_2.0 similarity index 100% rename from tests/test_data/selfupdate_2.0 rename to tests/test_data/testupdate_2.0 diff --git a/tests/test_fixtures.py b/tests/test_fixtures.py index 6b11b90332..01f92c4ea0 100644 --- a/tests/test_fixtures.py +++ b/tests/test_fixtures.py @@ -190,15 +190,15 @@ class KeyStore: @staticmethod def ca(): - return path.join(KeyStore.base_dir, 'tests/test_data/prov_selfupdate/ca.pem') + return path.join(KeyStore.base_dir, 'tests/test_data/prov_testupdate/ca.pem') @staticmethod def pkey(): - return path.join(KeyStore.base_dir, 'tests/test_data/prov_selfupdate/pkey.pem') + return path.join(KeyStore.base_dir, 'tests/test_data/prov_testupdate/pkey.pem') @staticmethod def cert(): - return path.join(KeyStore.base_dir, 'tests/test_data/prov_selfupdate/client.pem') + return path.join(KeyStore.base_dir, 'tests/test_data/prov_testupdate/client.pem') class IPSecondary: diff --git a/tests/test_install_aktualizr_and_update.sh b/tests/test_install_aktualizr_and_update.sh index 0fa6ed0059..6a50d79b2e 100755 --- a/tests/test_install_aktualizr_and_update.sh +++ b/tests/test_install_aktualizr_and_update.sh @@ -1,9 +1,10 @@ #! /bin/bash set -exuo pipefail + SCRIPT_DIR="$(dirname "$0")" TEST_INSTALL_DESTDIR=$(mktemp -d)/install -./scripts/selfupdate_server.py 0 "$TEST_INSTALL_DESTDIR"& +./scripts/testupdate_server.py 0 "$TEST_INSTALL_DESTDIR"& PORT=$("$SCRIPT_DIR/find_listening_port.sh" $!) trap 'kill %1' EXIT @@ -14,38 +15,22 @@ done $1/src/aktualizr_primary/aktualizr --version $1/src/uptane_generator/uptane-generator generate --path "$TEST_INSTALL_DESTDIR/fake_root" -$1/src/uptane_generator/uptane-generator image --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --filename "./tests/test_data/selfupdate_2.0" --hwid selfupdate-device -$1/src/uptane_generator/uptane-generator addtarget --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --hwid selfupdate-device --serial 723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66 +$1/src/uptane_generator/uptane-generator image --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname testupdate_2.0 --filename "./tests/test_data/testupdate_2.0" --hwid testupdate-device +$1/src/uptane_generator/uptane-generator addtarget --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname testupdate_2.0 --hwid testupdate-device --serial 723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66 $1/src/uptane_generator/uptane-generator signtargets --path "$TEST_INSTALL_DESTDIR/fake_root" TEMP_DIR=$(mktemp -d) mkdir -m 700 -p "$TEMP_DIR/import" -cp ./tests/test_data/prov_selfupdate/* "$TEMP_DIR/import" +cp ./tests/test_data/prov_testupdate/* "$TEMP_DIR/import" echo -e "[storage]\\npath = \"$TEMP_DIR\"\\n[import]\\nbase_path = \"$TEMP_DIR/import\"" > "$TEMP_DIR/conf.toml" echo -e "[tls]\\nserver = \"http://localhost:$PORT\"" >> "$TEMP_DIR/conf.toml" -$1/src/aktualizr_primary/aktualizr -c ./tests/config/selfupdate.toml -c "$TEMP_DIR/conf.toml" once -TEST_INSTALL_IMAGE_DIR=$TEMP_DIR/images -filename=$(echo $($1/src/aktualizr_info/aktualizr-info -c ./tests/config/selfupdate.toml -c "$TEMP_DIR/conf.toml" --director-target | jq '(.signed.targets["selfupdate_2.0"].hashes.sha256)') | tr [a-f] [A-F] | tr -d '"') - -ls $TEST_INSTALL_IMAGE_DIR/$filename +$1/src/aktualizr_primary/aktualizr -c ./tests/config/testupdate.toml -c "$TEMP_DIR/conf.toml" once +# check the updated file appeared in the installation directory and sha256sum matches expectation +filename=$(echo $($1/src/aktualizr_info/aktualizr-info -c ./tests/config/testupdate.toml -c "$TEMP_DIR/conf.toml" --director-target | jq '(.signed.targets["testupdate_2.0"].hashes.sha256)') | tr [a-f] [A-F] | tr -d '"') +ls $TEMP_DIR/images/$filename if [ $? -ne 0 ];then echo "ERROR: $filename does not exist or sha256sum does not match." exit 1 fi -# check the updated file appeared in the installation directory and sha256sum matches expectation -#TEST_INSTALL_IMAGE_DIR=$TEMP_DIR/images -# if [ ! -d $TEST_INSTALL_IMAGE_DIR ]; then -# echo "$TEST_INSTALL_IMAGE_DIR does not exist" -# exit 1 -#else -# cd $TEST_INSTALL_IMAGE_DIR -# for filename in `ls`; do -# checksum=$(echo $(sha256sum $filename) | cut -f 1 -d " " | tr [a-f] [A-F] ) -# if [ "$checksum" != "$filename" ]; then -# echo "ERROR: sha256sum does not match." -# exit 1 -# fi -# done -#fi