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

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