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

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