Commit e7be9d69 authored by Simon McVittie's avatar Simon McVittie

tests/: Rely on Ribchester 0.1709 to call TerminateBundle()

This provides a "full-stack" test for T2621: removing an app-bundle
causes termination of the processes from that app-bundle.

Apertis: https://phabricator.apertis.org/T2621Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
Reviewed-by: Frédéric Dalleau's avatarFrédéric Dalleau <frederic.dalleau@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D7090
parent 1235d9b3
......@@ -2,21 +2,21 @@ Tests: build
Depends: build-essential, canterbury-dev
Tests: core agents-slow
Depends: apertis-tests, canterbury-core-tests, gnome-desktop-testing, ribchester-core (>= 0.1706.3~)
Depends: apertis-tests, canterbury-core-tests, gnome-desktop-testing, ribchester-core (>= 0.1709.0~)
Tests: core-as-root
Depends: canterbury-core-tests, gnome-desktop-testing, ribchester-core (>= 0.1706.3~)
Depends: canterbury-core-tests, gnome-desktop-testing, ribchester-core (>= 0.1709.0~)
Tests: full
Depends: apertis-tests, canterbury-tests, gnome-desktop-testing, libglib2.0-bin
Tests: full-as-root
Depends: canterbury-tests, gnome-desktop-testing, ribchester-full (>= 0.1706.3~)
Depends: canterbury-tests, gnome-desktop-testing, ribchester-full (>= 0.1709.0~)
Tests: store-app-bundle-apparmor agent-after-reboot
Depends: canterbury-common, canterbury-core-tests, ribchester-core
Depends: canterbury-common, canterbury-core-tests, ribchester-core (>= 0.1709.0~)
Restrictions: allow-stderr, isolation-machine, needs-root
Tests: agent-after-reboot-full
Depends: canterbury-core-tests, canterbury-full, ribchester-full
Depends: canterbury-core-tests, canterbury-full, ribchester-full (>= 0.1709.0~)
Restrictions: allow-stderr, isolation-machine, needs-root
......@@ -264,20 +264,12 @@ install_bundle_and_wait_for_agent (Fixture *f)
}
static void
terminate_agent_and_wait (Fixture *f)
remove_agent_and_wait (Fixture *f)
{
g_auto (TestsScopedTimeout) timeout = 0;
g_autoptr (GError) error = NULL;
/* Make sure any automated restart processing implemented for
* https://phabricator.apertis.org/T3414 has stopped. */
g_dbus_connection_call_sync (f->session_bus, SYSTEMD_BUS_NAME,
SYSTEMD_PATH_MANAGER,
SYSTEMD_IFACE_MANAGER,
"StopUnit",
g_variant_new ("(ss)", SYSTEMD_UNIT, "replace"),
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
g_assert_no_error (error);
tests_app_bundle_remove (&f->bundle);
tests_scoped_timeout_start (&timeout, 10);
......@@ -295,7 +287,9 @@ test_basic (Fixture *f,
return;
install_bundle_and_wait_for_agent (f);
terminate_agent_and_wait (f);
/* Now that we've implemented T2621, removing the agent terminates it
* as a side-effect. */
remove_agent_and_wait (f);
g_assert_cmpstr (f->agent_unique_name, ==, NULL);
g_assert_cmpuint (f->agent_appeared_count, ==, 1);
......@@ -394,8 +388,9 @@ test_crash_once (Fixture *f,
g_assert_cmpuint (f->agent_appeared_count, ==, 2);
}
/* Clean up */
terminate_agent_and_wait (f);
/* Now that we've implemented T2621, removing the agent terminates it
* as a side-effect. */
remove_agent_and_wait (f);
g_assert_cmpstr (f->agent_unique_name, ==, NULL);
g_assert_cmpuint (f->agent_appeared_count, ==, 2);
......@@ -487,7 +482,9 @@ test_crash_repeatedly (Fixture *f,
g_assert_cmpuint (f->agent_appeared_count, ==, 5);
}
terminate_agent_and_wait (f);
/* Now that we've implemented T2621, removing the agent terminates it
* as a side-effect. */
remove_agent_and_wait (f);
g_assert_cmpstr (f->agent_unique_name, ==, NULL);
......@@ -504,10 +501,7 @@ static void
teardown (Fixture *f,
gconstpointer unused G_GNUC_UNUSED)
{
/* TODO: For now, all tests that start an agent are expected to stop it
* and wait for it to stop. When we have finished
* https://phabricator.apertis.org/T2621 we should adjust this, because
* Canterbury itself will stop the agent as a side-effect of removal. */
/* We already removed the agent, which terminated it as a side-effect */
g_assert_cmpstr (f->agent_unique_name, ==, NULL);
tests_app_bundle_tear_down (&f->bundle);
......
......@@ -188,7 +188,7 @@ setup (Fixture *f,
static void
test_basic (Fixture *f,
gconstpointer nil G_GNUC_UNUSED)
gconstpointer user_data)
{
g_autoptr (GError) error = NULL;
g_autoptr (GVariant) tuple = NULL;
......@@ -258,17 +258,27 @@ test_basic (Fixture *f,
}
g_assert_cmpuint (f->sigterm_received_times, ==, 0);
tuple =
g_dbus_connection_call_sync (f->system_bus,
CBY_SYSTEM_BUS_NAME_PER_USER_APP_MANAGER1,
CBY_OBJECT_PATH_PER_USER_APP_MANAGER1,
CBY_INTERFACE_PER_USER_APP_MANAGER1,
"TerminateBundle",
g_variant_new ("(s)", BUNDLE_ID),
G_VARIANT_TYPE_UNIT, G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
g_assert_no_error (error);
g_clear_pointer (&tuple, g_variant_unref);
if (g_strcmp0 (user_data, "during-remove") == 0)
{
/* Integration test for T2621: removing the app-bundle causes it to be
* terminated as a side-effect */
tests_app_bundle_remove (&f->bundle);
}
else
{
tuple =
g_dbus_connection_call_sync (f->system_bus,
CBY_SYSTEM_BUS_NAME_PER_USER_APP_MANAGER1,
CBY_OBJECT_PATH_PER_USER_APP_MANAGER1,
CBY_INTERFACE_PER_USER_APP_MANAGER1,
"TerminateBundle",
g_variant_new ("(s)", BUNDLE_ID),
G_VARIANT_TYPE_UNIT, G_DBUS_CALL_FLAGS_NONE,
-1, NULL, &error);
g_assert_no_error (error);
g_clear_pointer (&tuple, g_variant_unref);
}
{
g_auto (TestsScopedTimeout) timeout = 0;
......@@ -324,6 +334,8 @@ main (int argc,
g_test_init (&argc, &argv, NULL);
g_test_add ("/terminate/basic", Fixture, NULL, setup, test_basic, teardown);
g_test_add ("/terminate/during-remove", Fixture, "during-remove",
setup, test_basic, teardown);
return g_test_run ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment