Blame SOURCES/evolution-data-server-3.28.5-tests-retry-client-open.patch

f0a9c3
diff -up evolution-data-server-3.28.5/src/libebackend/e-data-factory.c.tests-retry-client-open evolution-data-server-3.28.5/src/libebackend/e-data-factory.c
f0a9c3
--- evolution-data-server-3.28.5/src/libebackend/e-data-factory.c.tests-retry-client-open	2018-07-30 15:17:06.000000000 +0200
f0a9c3
+++ evolution-data-server-3.28.5/src/libebackend/e-data-factory.c	2018-12-04 10:42:29.837599599 +0100
f0a9c3
@@ -1278,6 +1278,13 @@ data_factory_spawn_subprocess_backend (E
f0a9c3
 	priv = data_factory->priv;
f0a9c3
 
f0a9c3
 	source = e_source_registry_ref_source (priv->registry, uid);
f0a9c3
+
f0a9c3
+	if (!source) {
f0a9c3
+		g_set_error (
f0a9c3
+			&error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
f0a9c3
+			_("No such source for UID “%s”"), uid);
f0a9c3
+	}
f0a9c3
+
f0a9c3
 	if (source && e_source_has_extension (source, extension_name)) {
f0a9c3
 		ESourceBackend *extension;
f0a9c3
 
f0a9c3
@@ -1372,7 +1379,7 @@ data_factory_spawn_subprocess_backend (E
f0a9c3
 			NULL);
f0a9c3
 
f0a9c3
 		g_object_unref (subprocess);
f0a9c3
-	} else {
f0a9c3
+	} else if (!error) {
f0a9c3
 		error = g_error_new (G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
f0a9c3
 			_("Backend factory for source “%s” and extension “%s” cannot be found."),
f0a9c3
 			uid, extension_name);
f0a9c3
diff -up evolution-data-server-3.28.5/tests/libecal/client/test-cal-client-get-free-busy.c.tests-retry-client-open evolution-data-server-3.28.5/tests/libecal/client/test-cal-client-get-free-busy.c
f0a9c3
--- evolution-data-server-3.28.5/tests/libecal/client/test-cal-client-get-free-busy.c.tests-retry-client-open	2018-12-04 10:43:10.449599037 +0100
f0a9c3
+++ evolution-data-server-3.28.5/tests/libecal/client/test-cal-client-get-free-busy.c	2018-12-04 10:43:19.837598907 +0100
f0a9c3
@@ -94,6 +94,49 @@ teardown_fixture (ETestServerFixture *fi
f0a9c3
 }
f0a9c3
 
f0a9c3
 static void
f0a9c3
+add_component_sync (ECalClient *cal_client)
f0a9c3
+{
f0a9c3
+	const gchar *comp_str =
f0a9c3
+		"BEGIN:VEVENT\r\n"
f0a9c3
+		"UID:test-fb-event-1\r\n"
f0a9c3
+		"DTSTAMP:20040212T000000Z\r\n"
f0a9c3
+		"DTSTART:20040213T060000Z\r\n"
f0a9c3
+		"DTEND:20040213T080000Z\r\n"
f0a9c3
+		"SUMMARY:Test event\r\n"
f0a9c3
+		"TRANSP:OPAQUE\r\n"
f0a9c3
+		"CLASS:PUBLIC\r\n"
f0a9c3
+		"CREATED:20040211T080000Z\r\n"
f0a9c3
+		"LAST-MODIFIED:20040211T080000Z\r\n"
f0a9c3
+		"END:VEVENT\r\n";
f0a9c3
+	icalcomponent *icalcomp;
f0a9c3
+	GError *error = NULL;
f0a9c3
+
f0a9c3
+	icalcomp = icalcomponent_new_from_string (comp_str);
f0a9c3
+	g_assert_nonnull (icalcomp);
f0a9c3
+
f0a9c3
+	if (!e_cal_client_create_object_sync (cal_client, icalcomp, NULL, NULL, &error))
f0a9c3
+		g_error ("Failed to add component: %s", error ? error->message : "Unknown error");
f0a9c3
+
f0a9c3
+	icalcomponent_free (icalcomp);
f0a9c3
+	g_clear_error (&error);
f0a9c3
+}
f0a9c3
+
f0a9c3
+static void
f0a9c3
+wait_for_dbus_signal (GMainLoop *loop)
f0a9c3
+{
f0a9c3
+	GMainContext *main_context;
f0a9c3
+	gint retries = 0;
f0a9c3
+
f0a9c3
+	main_context = g_main_loop_get_context (loop);
f0a9c3
+
f0a9c3
+	while (!received_free_busy_data && retries < 5) {
f0a9c3
+		retries++;
f0a9c3
+
f0a9c3
+		g_main_context_iteration (main_context, TRUE);
f0a9c3
+	}
f0a9c3
+}
f0a9c3
+
f0a9c3
+static void
f0a9c3
 free_busy_data_cb (ECalClient *client,
f0a9c3
                    const GSList *free_busy,
f0a9c3
                    const gchar *func_name)
f0a9c3
@@ -114,9 +157,13 @@ test_get_free_busy_sync (ETestServerFixt
f0a9c3
 
f0a9c3
 	cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
f0a9c3
 
f0a9c3
+	add_component_sync (cal_client);
f0a9c3
+
f0a9c3
 	/* This is set by the free-busy-data callback */
f0a9c3
 	received_free_busy_data = FALSE;
f0a9c3
 
f0a9c3
+	g_signal_connect (cal_client, "free-busy-data", G_CALLBACK (free_busy_data_cb), (gpointer) G_STRFUNC);
f0a9c3
+
f0a9c3
 	utc = icaltimezone_get_utc_timezone ();
f0a9c3
 	start = time_from_isodate ("20040212T000000Z");
f0a9c3
 	end = time_add_day_with_zone (start, 2, utc);
f0a9c3
@@ -127,6 +174,9 @@ test_get_free_busy_sync (ETestServerFixt
f0a9c3
 
f0a9c3
 	g_slist_free (users);
f0a9c3
 
f0a9c3
+	wait_for_dbus_signal (fixture->loop);
f0a9c3
+
f0a9c3
+	g_assert (received_free_busy_data);
f0a9c3
 	g_assert (freebusy_data);
f0a9c3
 
f0a9c3
 	g_slist_free_full (freebusy_data, g_object_unref);
f0a9c3
@@ -147,6 +197,8 @@ async_get_free_busy_result_ready (GObjec
f0a9c3
 	if (!e_cal_client_get_free_busy_finish (cal_client, result, &freebusy_data, &error))
f0a9c3
 		g_error ("create object finish: %s", error->message);
f0a9c3
 
f0a9c3
+	wait_for_dbus_signal (loop);
f0a9c3
+
f0a9c3
 	g_assert (received_free_busy_data);
f0a9c3
 	g_assert (freebusy_data);
f0a9c3
 
f0a9c3
@@ -166,6 +218,8 @@ test_get_free_busy_async (ETestServerFix
f0a9c3
 
f0a9c3
 	cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
f0a9c3
 
f0a9c3
+	add_component_sync (cal_client);
f0a9c3
+
f0a9c3
 	/* This is set by the free-busy-data callback */
f0a9c3
 	received_free_busy_data = FALSE;
f0a9c3
 
f0a9c3
diff -up evolution-data-server-3.28.5/tests/test-server-utils/e-test-server-utils.c.tests-retry-client-open evolution-data-server-3.28.5/tests/test-server-utils/e-test-server-utils.c
f0a9c3
--- evolution-data-server-3.28.5/tests/test-server-utils/e-test-server-utils.c.tests-retry-client-open	2018-07-30 15:17:06.000000000 +0200
f0a9c3
+++ evolution-data-server-3.28.5/tests/test-server-utils/e-test-server-utils.c	2018-12-04 10:43:19.838598907 +0100
f0a9c3
@@ -199,6 +199,7 @@ assert_object_finalized (ETestServerFixt
f0a9c3
 typedef struct {
f0a9c3
 	ETestServerFixture *fixture;
f0a9c3
 	ETestServerClosure *closure;
f0a9c3
+	guint retries;
f0a9c3
 } FixturePair;
f0a9c3
 
f0a9c3
 static gboolean
f0a9c3
@@ -332,12 +333,15 @@ e_test_server_utils_bootstrap_timeout (F
f0a9c3
 	return FALSE;
f0a9c3
 }
f0a9c3
 
f0a9c3
+static gboolean e_test_server_utils_retry_open_client_cb (gpointer user_data);
f0a9c3
+
f0a9c3
 static void
f0a9c3
 e_test_server_utils_client_ready (GObject *source_object,
f0a9c3
                                   GAsyncResult *res,
f0a9c3
                                   gpointer user_data)
f0a9c3
 {
f0a9c3
 	FixturePair *pair = (FixturePair *) user_data;
f0a9c3
+	gboolean need_retry = FALSE;
f0a9c3
 	GError *error = NULL;
f0a9c3
 
f0a9c3
 	switch (pair->closure->type) {
f0a9c3
@@ -345,7 +349,10 @@ e_test_server_utils_client_ready (GObjec
f0a9c3
 		pair->fixture->service.book_client = (EBookClient *)
f0a9c3
 			e_book_client_connect_finish (res, &error);
f0a9c3
 
f0a9c3
-		if (!pair->fixture->service.book_client)
f0a9c3
+		if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
f0a9c3
+		    pair->retries < 3)
f0a9c3
+			need_retry = TRUE;
f0a9c3
+		else if (!pair->fixture->service.book_client)
f0a9c3
 			g_error ("Unable to create the test book: %s", error->message);
f0a9c3
 
f0a9c3
 		break;
f0a9c3
@@ -353,7 +360,10 @@ e_test_server_utils_client_ready (GObjec
f0a9c3
 		pair->fixture->service.book_client = (EBookClient *)
f0a9c3
 			e_book_client_connect_direct_finish (res, &error);
f0a9c3
 
f0a9c3
-		if (!pair->fixture->service.book_client)
f0a9c3
+		if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
f0a9c3
+		    pair->retries < 3)
f0a9c3
+			need_retry = TRUE;
f0a9c3
+		else if (!pair->fixture->service.book_client)
f0a9c3
 			g_error ("Unable to create the test book: %s", error->message);
f0a9c3
 
f0a9c3
 		break;
f0a9c3
@@ -361,7 +371,10 @@ e_test_server_utils_client_ready (GObjec
f0a9c3
 		pair->fixture->service.calendar_client = (ECalClient *)
f0a9c3
 			e_cal_client_connect_finish (res, &error);
f0a9c3
 
f0a9c3
-		if (!pair->fixture->service.calendar_client)
f0a9c3
+		if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
f0a9c3
+		    pair->retries < 3)
f0a9c3
+			need_retry = TRUE;
f0a9c3
+		else if (!pair->fixture->service.calendar_client)
f0a9c3
 			g_error ("Unable to create the test calendar: %s", error->message);
f0a9c3
 
f0a9c3
 		break;
f0a9c3
@@ -371,6 +384,14 @@ e_test_server_utils_client_ready (GObjec
f0a9c3
 		g_assert_not_reached ();
f0a9c3
 	}
f0a9c3
 
f0a9c3
+	g_clear_error (&error);
f0a9c3
+
f0a9c3
+	if (need_retry) {
f0a9c3
+		pair->retries++;
f0a9c3
+		g_timeout_add_seconds (1, e_test_server_utils_retry_open_client_cb, pair);
f0a9c3
+		return;
f0a9c3
+	}
f0a9c3
+
f0a9c3
 	/* Track ref counts now that we have a client */
f0a9c3
 	add_weak_ref (pair->fixture, pair->closure->type);
f0a9c3
 
f0a9c3
@@ -382,6 +403,7 @@ e_test_server_utils_source_added (ESourc
f0a9c3
                                   ESource *source,
f0a9c3
                                   FixturePair *pair)
f0a9c3
 {
f0a9c3
+	gboolean need_retry = FALSE;
f0a9c3
 	GError  *error = NULL;
f0a9c3
 
f0a9c3
 	if (g_strcmp0 (e_source_get_uid (source), pair->fixture->source_name) != 0)
f0a9c3
@@ -409,8 +431,13 @@ e_test_server_utils_source_added (ESourc
f0a9c3
 		}
f0a9c3
 
f0a9c3
 		if (!pair->closure->use_async_connect &&
f0a9c3
-		    !pair->fixture->service.book_client)
f0a9c3
-			g_error ("Unable to create the test book: %s", error ? error->message : "Unknown error");
f0a9c3
+		    !pair->fixture->service.book_client) {
f0a9c3
+			if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
f0a9c3
+			    pair->retries < 3)
f0a9c3
+				need_retry = TRUE;
f0a9c3
+			else
f0a9c3
+				g_error ("Unable to create the test book: %s", error ? error->message : "Unknown error");
f0a9c3
+		}
f0a9c3
 
f0a9c3
 		break;
f0a9c3
 
f0a9c3
@@ -418,11 +445,23 @@ e_test_server_utils_source_added (ESourc
f0a9c3
 
f0a9c3
 		/* Dont bother testing the Async apis for deprecated APIs */
f0a9c3
 		pair->fixture->service.book = e_book_new (source, &error);
f0a9c3
-		if (!pair->fixture->service.book)
f0a9c3
-			g_error ("Unable to create the test book: %s", error->message);
f0a9c3
+		if (!pair->fixture->service.book) {
f0a9c3
+			if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
f0a9c3
+			    pair->retries < 3)
f0a9c3
+				need_retry = TRUE;
f0a9c3
+			else
f0a9c3
+				g_error ("Unable to create the test book: %s", error->message);
f0a9c3
+
f0a9c3
+			break;
f0a9c3
+		}
f0a9c3
 
f0a9c3
-		if (!e_book_open (pair->fixture->service.book, FALSE, &error))
f0a9c3
-			g_error ("Unable to open book: %s", error->message);
f0a9c3
+		if (!e_book_open (pair->fixture->service.book, FALSE, &error)) {
f0a9c3
+			if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
f0a9c3
+			    pair->retries < 3)
f0a9c3
+				need_retry = TRUE;
f0a9c3
+			else
f0a9c3
+				g_error ("Unable to open book: %s", error->message);
f0a9c3
+		}
f0a9c3
 
f0a9c3
 		break;
f0a9c3
 
f0a9c3
@@ -439,8 +478,13 @@ e_test_server_utils_source_added (ESourc
f0a9c3
 				e_cal_client_connect_sync (
f0a9c3
 					source,
f0a9c3
 					pair->closure->calendar_source_type, (guint32) -1, NULL, &error);
f0a9c3
-			if (!pair->fixture->service.calendar_client)
f0a9c3
-				g_error ("Unable to create the test calendar: %s", error->message);
f0a9c3
+			if (!pair->fixture->service.calendar_client) {
f0a9c3
+				if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
f0a9c3
+				    pair->retries < 3)
f0a9c3
+					need_retry = TRUE;
f0a9c3
+				else
f0a9c3
+					g_error ("Unable to create the test calendar: %s", error->message);
f0a9c3
+			}
f0a9c3
 		}
f0a9c3
 
f0a9c3
 		break;
f0a9c3
@@ -449,11 +493,22 @@ e_test_server_utils_source_added (ESourc
f0a9c3
 
f0a9c3
 		/* Dont bother testing the Async apis for deprecated APIs */
f0a9c3
 		pair->fixture->service.calendar = e_cal_new (source, pair->closure->calendar_source_type);
f0a9c3
-		if (!pair->fixture->service.calendar)
f0a9c3
-			g_error ("Unable to create the test calendar");
f0a9c3
+		if (!pair->fixture->service.calendar) {
f0a9c3
+			if (pair->retries < 3)
f0a9c3
+				need_retry = TRUE;
f0a9c3
+			else
f0a9c3
+				g_error ("Unable to create the test calendar");
f0a9c3
 
f0a9c3
-		if (!e_cal_open (pair->fixture->service.calendar, FALSE, &error))
f0a9c3
-			g_error ("Unable to open calendar: %s", error->message);
f0a9c3
+			break;
f0a9c3
+		}
f0a9c3
+
f0a9c3
+		if (!e_cal_open (pair->fixture->service.calendar, FALSE, &error)) {
f0a9c3
+			if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
f0a9c3
+			    pair->retries < 3)
f0a9c3
+				need_retry = TRUE;
f0a9c3
+			else
f0a9c3
+				g_error ("Unable to open calendar: %s", error->message);
f0a9c3
+		}
f0a9c3
 
f0a9c3
 		break;
f0a9c3
 
f0a9c3
@@ -461,6 +516,14 @@ e_test_server_utils_source_added (ESourc
f0a9c3
 		return;
f0a9c3
 	}
f0a9c3
 
f0a9c3
+	g_clear_error (&error);
f0a9c3
+
f0a9c3
+	if (need_retry) {
f0a9c3
+		pair->retries++;
f0a9c3
+		g_timeout_add_seconds (1, e_test_server_utils_retry_open_client_cb, pair);
f0a9c3
+		return;
f0a9c3
+	}
f0a9c3
+
f0a9c3
 	/* Add the weak ref now if we just created it */
f0a9c3
 	if (pair->closure->type != E_TEST_SERVER_NONE &&
f0a9c3
 	    pair->closure->use_async_connect == FALSE)
f0a9c3
@@ -471,6 +534,22 @@ e_test_server_utils_source_added (ESourc
f0a9c3
 }
f0a9c3
 
f0a9c3
 static gboolean
f0a9c3
+e_test_server_utils_retry_open_client_cb (gpointer user_data)
f0a9c3
+{
f0a9c3
+	FixturePair *pair = user_data;
f0a9c3
+	ESource *source;
f0a9c3
+
f0a9c3
+	source = e_source_registry_ref_source (pair->fixture->registry, pair->fixture->source_name);
f0a9c3
+
f0a9c3
+	g_assert (E_IS_SOURCE (source));
f0a9c3
+
f0a9c3
+	e_test_server_utils_source_added (pair->fixture->registry, source, pair);
f0a9c3
+	g_object_unref (source);
f0a9c3
+
f0a9c3
+	return FALSE;
f0a9c3
+}
f0a9c3
+
f0a9c3
+static gboolean
f0a9c3
 e_test_server_utils_bootstrap_idle (FixturePair *pair)
f0a9c3
 {
f0a9c3
 	ESourceBackend *backend = NULL;
f0a9c3
@@ -578,7 +657,7 @@ e_test_server_utils_setup (ETestServerFi
f0a9c3
                            gconstpointer user_data)
f0a9c3
 {
f0a9c3
 	ETestServerClosure *closure = (ETestServerClosure *) user_data;
f0a9c3
-	FixturePair         pair = { fixture, closure };
f0a9c3
+	FixturePair         pair = { fixture, closure, 0 };
f0a9c3
 
f0a9c3
 	/* Create work directory */
f0a9c3
 	if (!test_installed_services ())