Skip to content

Commit

Permalink
Fix ct tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shapovalovts committed Aug 24, 2024
1 parent 1f017ec commit 2a3a62b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
27 changes: 25 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
permissions:
contents: read

env:
PYTHON_VERSION: 3.10
PYTHON_VERSION_FULL: 3.10.0

jobs:

unit_tests:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions test/wm_gate_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -95,15 +95,13 @@ 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"},
{name, "cirros"},
{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)).
Expand All @@ -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)),
Expand Down
1 change: 1 addition & 0 deletions test/wm_virtres_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 2a3a62b

Please sign in to comment.