[libgda] postgres: added test for routines partial meta update
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] postgres: added test for routines partial meta update
- Date: Wed, 9 Jan 2019 18:50:35 +0000 (UTC)
commit cfca538b54da291c9b3e429c6b9ea1f63eca9041
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date: Wed Jan 9 12:49:49 2019 -0600
postgres: added test for routines partial meta update
tests/providers/check_postgres_meta_partial-1.c | 4 +-
tests/providers/check_postgres_meta_partial-2.c | 58 +++++++++++++
tests/providers/meson.build | 27 +++++-
tests/providers/prov-test-common.c | 110 +++++++++++++++++++++++-
tests/providers/prov-test-common.h | 1 +
5 files changed, 193 insertions(+), 7 deletions(-)
---
diff --git a/tests/providers/check_postgres_meta_partial-1.c b/tests/providers/check_postgres_meta_partial-1.c
index 745638181..3dadefbae 100644
--- a/tests/providers/check_postgres_meta_partial-1.c
+++ b/tests/providers/check_postgres_meta_partial-1.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Daniel Espinosa <esodan gmail com>
+ * Copyright (C) 2019 Daniel Espinosa <esodan gmail com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -43,7 +43,7 @@ main (int argc, char **argv)
g_warning ("Could not find provider information for %s", PROVIDER);
return EXIT_SUCCESS;
}
- g_print ("============= Provider Meta Partial Update now testing: %s =============\n", pinfo->id);
+ g_print ("============= Provider Meta Partial 1 Update now testing: %s =============\n", pinfo->id);
number_failed = prov_test_common_setup ();
diff --git a/tests/providers/check_postgres_meta_partial-2.c b/tests/providers/check_postgres_meta_partial-2.c
new file mode 100644
index 000000000..e8ae202fb
--- /dev/null
+++ b/tests/providers/check_postgres_meta_partial-2.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2019 Daniel Espinosa <esodan gmail com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#define PROVIDER "PostgreSQL"
+#include "prov-test-common.h"
+#include <sql-parser/gda-sql-parser.h>
+#include "../test-errors.h"
+
+#define CHECK_EXTRA_INFO 1
+
+extern GdaProviderInfo *pinfo;
+extern GdaConnection *cnc;
+extern gboolean params_provided;
+extern gboolean fork_tests;
+
+int
+main (int argc, char **argv)
+{
+ int number_failed = 0;
+ fork_tests = FALSE;
+
+ gda_init ();
+
+ pinfo = gda_config_get_provider_info (PROVIDER);
+ if (!pinfo) {
+ g_warning ("Could not find provider information for %s", PROVIDER);
+ return EXIT_SUCCESS;
+ }
+ g_print ("============= Provider Meta Partial 1 Update now testing: %s =============\n", pinfo->id);
+
+ number_failed = prov_test_common_setup ();
+
+ if (cnc) {
+ number_failed += prov_test_common_check_meta_partial2 ();
+ number_failed += prov_test_common_clean ();
+ }
+
+ g_print ("Test %s\n", (number_failed == 0) ? "Ok" : "failed");
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
diff --git a/tests/providers/meson.build b/tests/providers/meson.build
index d11398720..95e9404c8 100644
--- a/tests/providers/meson.build
+++ b/tests/providers/meson.build
@@ -99,7 +99,32 @@ tchkpg_mu1 = executable('check_postgres_meta_partial_1',
install: false
)
test('ProviderMetaPartialUpdate1PostgreSQL', tchkpg_mu1,
- timeout: 2000,
+ timeout: 300,
+ is_parallel: false,
+ env: [
+ 'GDA_TOP_SRC_DIR='+meson.source_root(),
+ 'GDA_TOP_BUILD_DIR='+meson.build_root()
+ ]
+ )
+
+tchkpg_mu2 = executable('check_postgres_meta_partial_2',
+ ['check_postgres_meta_partial-2.c']+providers_common_sources+common_sources+tests_sources,
+ c_args: [
+ '-include',
+ meson.build_root() + '/config.h',
+ '-DCHECK_SQL_FILES="'+meson.source_root()+'"',
+ ],
+ link_with: libgda,
+ dependencies: [
+ libgda_dep,
+ inc_rooth_dep,
+ inc_sqliteh_dep,
+ inc_testsh_dep
+ ],
+ install: false
+ )
+test('ProviderMetaPartialUpdate2PostgreSQL', tchkpg_mu2,
+ timeout: 600,
is_parallel: false,
env: [
'GDA_TOP_SRC_DIR='+meson.source_root(),
diff --git a/tests/providers/prov-test-common.c b/tests/providers/prov-test-common.c
index 34bf6ebc2..c8f7cbdf9 100644
--- a/tests/providers/prov-test-common.c
+++ b/tests/providers/prov-test-common.c
@@ -313,6 +313,109 @@ prov_test_common_check_meta_partial2 (void)
store = gda_connection_get_meta_store (cnc);
+ /* update meta store */
+#ifdef CHECK_EXTRA_INFO
+ g_print ("Updating the complete meta store...\n");
+#endif
+ if (! gda_connection_update_meta_store (cnc, NULL, &gerror)) {
+#ifdef CHECK_EXTRA_INFO
+ g_warning ("Can't update meta store (2): %s\n",
+ gerror && gerror->message ? gerror->message : "???");
+#endif
+ g_error_free (gerror);
+ number_failed++;
+ goto theend;
+ }
+ /* Update meta store by context */
+ GdaMetaContext *ctx;
+ ctx = gda_meta_context_new ();
+ gchar *meta_tables[] = {
+ "_routines",
+ NULL};
+ for (i = 0; meta_tables[i]; i++) {
+ gda_meta_context_set_table (ctx, meta_tables[i]);
+#ifdef CHECK_EXTRA_INFO
+ g_print ("Updating the meta store for table '%s'\n", meta_tables[i]);
+#endif
+ if (! gda_connection_update_meta_store (cnc, ctx, &gerror)) {
+#ifdef CHECK_EXTRA_INFO
+ g_warning ("Can't update meta store (on table %s): %s\n",
+ meta_tables[i], gerror && gerror->message ? gerror->message : "???");
+#endif
+ g_error_free (gerror);
+ number_failed++;
+ goto theend;
+ }
+ }
+ gda_meta_context_free (ctx);
+
+ for (i = 0, list = tables; list; i++, list = list->next) {
+ GdaDataModel *model;
+ gchar *tmp;
+ GError *gerror = NULL;
+
+ tmp = g_strdup_printf ("SELECT * FROM %s", (gchar*) list->data);
+ model = gda_meta_store_extract (store, tmp, &gerror, NULL);
+ g_free (tmp);
+ if (!model) {
+#ifdef CHECK_EXTRA_INFO
+ g_warning ("Can't execute SELECT statement: %s\n",
+ gerror && gerror->message ? gerror->message : "???");
+#endif
+ g_error_free (gerror);
+ number_failed++;
+ continue;
+ }
+
+ tmp = gda_data_model_export_to_string (model, GDA_DATA_MODEL_IO_DATA_ARRAY_XML,
+ NULL, 0, NULL, 0, NULL);
+ g_object_unref (model);
+ if (!tmp) {
+#ifdef CHECK_EXTRA_INFO
+ g_warning ("Can't export data model\n");
+#endif
+ number_failed++;
+ continue;
+ }
+ if (strcmp (tmp, dump1[i])) {
+#ifdef CHECK_EXTRA_INFO
+ g_warning ("Meta data has changed after update for table %s\n", (gchar*) list->data);
+ g_print ("===\n%s\n===\n%s\n===\n", tmp, dump1[i]);
+#endif
+ number_failed++;
+ g_free (tmp);
+ continue;
+ }
+#ifdef CHECK_EXTRA_INFO
+ else
+ g_print ("Meta for table '%s' Ok\n", (gchar*) list->data);
+#endif
+ g_free (tmp);
+ }
+
+ theend:
+ /* remove tmp files */
+ if (dump1)
+ g_strfreev (dump1);
+ g_slist_free (tables);
+
+ return number_failed;
+}
+
+
+int
+prov_test_common_check_meta_partial3 (void)
+{
+ int number_failed = 0;
+ GSList *tables = NULL, *list;
+ gboolean dump_ok = TRUE;
+ GdaMetaStore *store;
+ gchar **dump1 = NULL;
+ GError *gerror = NULL;
+ gint ntables, i;
+
+ store = gda_connection_get_meta_store (cnc);
+
/* update meta store */
#ifdef CHECK_EXTRA_INFO
g_print ("Updating the complete meta store...\n");
@@ -332,7 +435,7 @@ prov_test_common_check_meta_partial2 (void)
gchar *meta_tables[] = {"_attributes", "_information_schema_catalog_name",
"_schemata", "_builtin_data_types", "_udt", "_udt_columns",
"_enums", "_element_types", "_domains", "_views",
"_collations",
- "_character_sets", "_routines", "_triggers", "_columns",
+ "_character_sets", "_triggers", "_columns",
"_table_constraints", "_referential_constraints",
"_key_column_usage", "__declared_fk", "_check_column_usage",
"_view_column_usage", "_domain_constraints", "_parameters",
@@ -354,12 +457,12 @@ prov_test_common_check_meta_partial2 (void)
}
}
gda_meta_context_free (ctx);
-
+
for (i = 0, list = tables; list; i++, list = list->next) {
GdaDataModel *model;
gchar *tmp;
GError *gerror = NULL;
-
+
tmp = g_strdup_printf ("SELECT * FROM %s", (gchar*) list->data);
model = gda_meta_store_extract (store, tmp, &gerror, NULL);
g_free (tmp);
@@ -407,7 +510,6 @@ prov_test_common_check_meta_partial2 (void)
return number_failed;
}
-
/*
*
* CHECK_META_IDENTIFIERS
diff --git a/tests/providers/prov-test-common.h b/tests/providers/prov-test-common.h
index 9fb79fdc2..521d09e9f 100644
--- a/tests/providers/prov-test-common.h
+++ b/tests/providers/prov-test-common.h
@@ -30,6 +30,7 @@ int prov_test_common_load_data (void);
int prov_test_common_check_meta_full (void);
int prov_test_common_check_meta_partial (void);
int prov_test_common_check_meta_partial2 (void);
+int prov_test_common_check_meta_partial3 (void);
int prov_test_common_check_meta_identifiers (gboolean case_sensitive, gboolean update_all);
int prov_test_common_check_cursor_models (void);
int prov_test_common_check_data_select (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]