From 2a3a62b71c67fc42b7992bdef70f3c103a6ed9b5 Mon Sep 17 00:00:00 2001 From: Taras Shapovalov Date: Sat, 24 Aug 2024 13:11:38 +0400 Subject: [PATCH] Fix ct tests --- .github/workflows/ci.yml | 27 +++++++++++++++++++++++++-- Makefile | 2 +- test/wm_gate_SUITE.erl | 9 +++------ test/wm_virtres_SUITE.erl | 1 + 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a6aaf5..c5cb8bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,10 @@ on: permissions: contents: read +env: + PYTHON_VERSION: 3.10 + PYTHON_VERSION_FULL: 3.10.0 + jobs: unit_tests: @@ -35,14 +39,33 @@ jobs: name: Checkout uses: actions/checkout@v4 - - name: Compile + name: Install Python dependencies + run: | + apt-get update + apt-get install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev + apt-get install -y libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev + - + name: Download Python sources + run: | + wget https://www.python.org/ftp/python/${{env.PYTHON_VERSION_FULL}}/Python-${{env.PYTHON_VERSION_FULL}}.tgz + tar -xf Python-${{env.PYTHON_VERSION_FULL}}.tgz + - + name: Compile and install Python + run: | + cd Python-${{env.PYTHON_VERSION_FULL}} + ./configure --enable-optimizations + make -j $(nproc) + make altinstall + ln -s /usr/local/bin/python${{env.PYTHON_VERSION}} /usr/local/bin/python + ln -s /usr/local/bin/pip${{env.PYTHON_VERSION}} /usr/local/bin/pip + - + name: Compile SWM run: | make compile make release - name: Prepate cloud gate run: | - apt-get update -y && apt-get install python3-pip -y git config --global url.https://github.com/.insteadOf git://github.com/ mkdir _build/ct-tests git clone https://github.com/openworkload/swm-cloud-gate.git _build/ct-tests/swm-cloud-gate diff --git a/Makefile b/Makefile index 1b4a3a9..2d4aa72 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ test_unit: ##@TESTS Run unit erlang tests $(REBAR) eunit skip_deps=true test_ct: ##@TESTS Run common erlang tests - $(REBAR) ct --dir test + $(REBAR) ct --dir test --verbose ftest: ##@TESTS Run functional tests scripts/swm.env diff --git a/test/wm_gate_SUITE.erl b/test/wm_gate_SUITE.erl index 3fc0d0a..054445d 100644 --- a/test/wm_gate_SUITE.erl +++ b/test/wm_gate_SUITE.erl @@ -77,9 +77,9 @@ get_remote() -> {account_id, "accid123"}], wm_entity:new(remote)). --spec get_creds() -> {ok, map()}. +-spec get_creds() -> [{binary(), binary()}]. get_creds() -> - maps:from_list([{tenantname, "demo1"}, {keyname, "demo1"}, {username, "demo1"}, {password, "demo1"}]). + [{<<"username">>, <<"demo1">>}, {<<"tenantname">>, <<"demo1">>}, {<<"password">>, <<"demo1">>}]. %% ============================================================================ %% Tests @@ -95,7 +95,6 @@ list_images(_Config) -> {status, "creating"}, {created, ""}, {remote_id, wm_entity:get(id, Remote)}, - {updated, ""}, {kind, cloud}], wm_entity:new(image)), wm_entity:set([{id, "i2"}, @@ -103,7 +102,6 @@ list_images(_Config) -> {status, "created"}, {remote_id, wm_entity:get(id, Remote)}, {created, ""}, - {updated, ""}, {kind, cloud}], wm_entity:new(image))], ?assertEqual({list_images, Ref, ExpectedImages}, wm_utils:await(list_images, Ref, 2000)). @@ -112,8 +110,7 @@ list_images(_Config) -> get_image(_Config) -> {ok, Ref1} = wm_gate:get_image(self(), get_remote(), get_creds(), "i2"), ExpectedImage = - wm_entity:set([{id, "i2"}, {name, "cirros"}, {status, "created"}, {created, ""}, {updated, ""}, {kind, cloud}], - wm_entity:new(image)), + wm_entity:set([{id, "i2"}, {name, "cirros"}, {status, "created"}, {kind, cloud}], wm_entity:new(image)), ?assertEqual({get_image, Ref1, ExpectedImage}, wm_utils:await(get_image, Ref1, 2000)), {ok, Ref2} = wm_gate:get_image(self(), get_remote(), get_creds(), "foo"), ?assertMatch({error, Ref2, _}, wm_utils:await(get_image, Ref2, 2000)), diff --git a/test/wm_virtres_SUITE.erl b/test/wm_virtres_SUITE.erl index 0554db5..8eba9da 100644 --- a/test/wm_virtres_SUITE.erl +++ b/test/wm_virtres_SUITE.erl @@ -92,6 +92,7 @@ init_test_group(Action, Config) -> meck:expect(wm_virtres_handler, wait_for_ssh_connection, fun(_) -> erlang:make_ref() end), meck:expect(wm_virtres_handler, delete_partition, fun(_, _) -> {ok, WaitRef} end), meck:expect(wm_virtres_handler, start_job_data_uploading, fun(_, _, _) -> {ok, WaitRef} end), + meck:expect(wm_virtres_handler, update_job, fun(_, _) -> 1 end), meck:expect(wm_conf, select, SelectById), meck:expect(wm_conf, g, fun(_, {X, _}) -> X end), meck:expect(wm_self, get_node_id, fun() -> "nodeid" end),