gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] 11/15: -db tests pass again


From: gnunet
Subject: [taler-exchange] 11/15: -db tests pass again
Date: Sun, 27 Nov 2022 22:14:35 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

commit c86c92200c331f0099ab95edd35b9f73c177b72b
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Nov 27 21:43:55 2022 +0100

    -db tests pass again
---
 src/exchangedb/0002-deposits.sql                   |  8 +--
 src/exchangedb/0002-reserves_out.sql               | 20 +++++++-
 src/exchangedb/exchange-0001.sql                   | 11 ++--
 .../perf_exchangedb_reserves_in_insert.c           | 46 ++++++++---------
 src/exchangedb/test_exchangedb.c                   | 10 ++--
 src/exchangedb/test_exchangedb_by_j.c              | 58 ++++++++++------------
 6 files changed, 77 insertions(+), 76 deletions(-)

diff --git a/src/exchangedb/0002-deposits.sql b/src/exchangedb/0002-deposits.sql
index 679103c4..92210afa 100644
--- a/src/exchangedb/0002-deposits.sql
+++ b/src/exchangedb/0002-deposits.sql
@@ -404,22 +404,22 @@ INSERT INTO exchange_tables
     ,'exchange-0002'
     ,'create'
     ,TRUE
-    ,FALSE),
+    ,TRUE),
     ('deposits_by_ready'
     ,'exchange-0002'
     ,'constrain'
     ,TRUE
-    ,FALSE),
+    ,TRUE),
     ('deposits_for_matching'
     ,'exchange-0002'
     ,'create'
     ,TRUE
-    ,FALSE),
+    ,TRUE),
     ('deposits_for_matching'
     ,'exchange-0002'
     ,'constrain'
     ,TRUE
-    ,FALSE),
+    ,TRUE),
     ('deposits'
     ,'exchange-0002'
     ,'master'
diff --git a/src/exchangedb/0002-reserves_out.sql 
b/src/exchangedb/0002-reserves_out.sql
index 77112f50..25d717a5 100644
--- a/src/exchangedb/0002-reserves_out.sql
+++ b/src/exchangedb/0002-reserves_out.sql
@@ -132,14 +132,25 @@ BEGIN
     ,table_name
     ,partition_suffix
   );
+END $$;
+
+
+CREATE FUNCTION constrain_table_reserves_out_by_reserve(
+  IN partition_suffix VARCHAR DEFAULT NULL
+)
+RETURNS VOID
+LANGUAGE plpgsql
+AS $$
+DECLARE
+  table_name VARCHAR DEFAULT 'reserves_out_by_reserve';
+BEGIN
   table_name = concat_ws('_', table_name, partition_suffix);
   EXECUTE FORMAT (
     'CREATE INDEX ' || table_name || '_main_index '
     'ON ' || table_name || ' '
     '(reserve_uuid);'
   );
-END
-$$;
+END $$;
 
 
 CREATE FUNCTION reserves_out_by_reserve_insert_trigger()
@@ -217,6 +228,11 @@ INSERT INTO exchange_tables
     ,'create'
     ,TRUE
     ,FALSE),
+    ('reserves_out_by_reserve'
+    ,'exchange-0002'
+    ,'constrain'
+    ,TRUE
+    ,FALSE),
     ('reserves_out'
     ,'exchange-0002'
     ,'master'
diff --git a/src/exchangedb/exchange-0001.sql b/src/exchangedb/exchange-0001.sql
index 49b5f8b7..5ce38c28 100644
--- a/src/exchangedb/exchange-0001.sql
+++ b/src/exchangedb/exchange-0001.sql
@@ -177,7 +177,7 @@ BEGIN
           'SELECT exchange.%s_table_%s (%s)'::text
           ,rec.action
           ,rec.name
-          ,0
+          ,quote_literal('0')
         );
         IF (rec.by_range OR
             (num_partitions = 0))
@@ -189,7 +189,7 @@ BEGIN
             EXECUTE FORMAT(
               'CREATE TABLE exchange.%s_default'
               ' PARTITION OF %s'
-              ' FOR DEFAULT'
+              ' DEFAULT'
              ,rec.name
              ,rec.name
             );
@@ -238,14 +238,15 @@ BEGIN
           ,rec.name
         );
       ELSE
-        IF (num_partitions = 0)
+        IF ( (num_partitions = 0) OR
+             (rec.by_range) )
         THEN
           -- Constrain default table
           EXECUTE FORMAT(
              'SELECT exchange.%s_table_%s (%s)'::text
             ,rec.action
             ,rec.name
-            ,'default'
+            ,quote_literal('default')
           );
         ELSE
           -- Constrain each partition
@@ -254,7 +255,7 @@ BEGIN
               'SELECT exchange.%s_table_%s (%s)'::text
               ,rec.action
               ,rec.name
-              ,i
+              ,quote_literal(i)
             );
           END LOOP;
         END IF;
diff --git a/src/exchangedb/perf_exchangedb_reserves_in_insert.c 
b/src/exchangedb/perf_exchangedb_reserves_in_insert.c
index 9a0ec094..fc2a0008 100644
--- a/src/exchangedb/perf_exchangedb_reserves_in_insert.c
+++ b/src/exchangedb/perf_exchangedb_reserves_in_insert.c
@@ -83,21 +83,14 @@ run (void *cls)
   }
   (void) plugin->drop_tables (plugin->cls);
   if (GNUNET_OK !=
-      plugin->create_tables (plugin->cls))
+      plugin->create_tables (plugin->cls,
+                             true,
+                             num_partitions))
   {
     GNUNET_break (0);
     result = 77;
     goto cleanup;
   }
-  if (GNUNET_OK !=
-      plugin->setup_partitions (plugin->cls,
-                                num_partitions))
-  {
-    GNUNET_break (0);
-    result = 77;
-    goto cleanup;
-  }
-
   for (unsigned int i = 0; i< 8; i++)
   {
     static unsigned int batches[] = {1, 1, 0, 2, 4, 16, 64, 256};
@@ -114,23 +107,23 @@ run (void *cls)
                                            &value));
     now = GNUNET_TIME_absolute_get ();
     ts = GNUNET_TIME_timestamp_get ();
-    for (unsigned int r=0;r<10;r++)
-    {
-    plugin->start (plugin->cls,
-                   "test_by_exchange_j");
-    for (unsigned int k = 0; k<batch_size; k++)
+    for (unsigned int r = 0; r<10; r++)
     {
-      RND_BLK (&reserve_pub);
-      FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
-              plugin->reserves_in_insert (plugin->cls,
-                                          &reserve_pub,
-                                          &value,
-                                          ts,
-                                          sndr,
-                                          "section",
-                                          4));
-    }
-    plugin->commit (plugin->cls);
+      plugin->start (plugin->cls,
+                     "test_by_exchange_j");
+      for (unsigned int k = 0; k<batch_size; k++)
+      {
+        RND_BLK (&reserve_pub);
+        FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
+                plugin->reserves_in_insert (plugin->cls,
+                                            &reserve_pub,
+                                            &value,
+                                            ts,
+                                            sndr,
+                                            "section",
+                                            4));
+      }
+      plugin->commit (plugin->cls);
     }
     duration = GNUNET_TIME_absolute_get_duration (now);
     fprintf (stdout,
@@ -196,4 +189,5 @@ main (int argc,
   return result;
 }
 
+
 /* end of test_exchangedb_by_j.c */
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 111ee936..eb258f00 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -1245,13 +1245,9 @@ run (void *cls)
   }
   (void) plugin->drop_tables (plugin->cls);
   if (GNUNET_OK !=
-      plugin->create_tables (plugin->cls))
-  {
-    result = 77;
-    goto cleanup;
-  }
-  if (GNUNET_OK !=
-      plugin->setup_partitions (plugin->cls, num_partitions))
+      plugin->create_tables (plugin->cls,
+                             true,
+                             num_partitions))
   {
     result = 77;
     goto cleanup;
diff --git a/src/exchangedb/test_exchangedb_by_j.c 
b/src/exchangedb/test_exchangedb_by_j.c
index b2f6ddeb..43f47167 100644
--- a/src/exchangedb/test_exchangedb_by_j.c
+++ b/src/exchangedb/test_exchangedb_by_j.c
@@ -33,7 +33,7 @@ static int result;
  */
 #define FAILIF(cond)                            \
   do {                                          \
-      if (! (cond)) {break;}                    \
+    if (! (cond)) {break;}                    \
     GNUNET_break (0);                           \
     goto drop;                                  \
   } while (0)
@@ -83,21 +83,14 @@ run (void *cls)
   }
   (void) plugin->drop_tables (plugin->cls);
   if (GNUNET_OK !=
-      plugin->create_tables (plugin->cls))
+      plugin->create_tables (plugin->cls,
+                             true,
+                             num_partitions))
   {
     GNUNET_break (0);
     result = 77;
     goto cleanup;
   }
-  if (GNUNET_OK !=
-      plugin->setup_partitions (plugin->cls,
-                                num_partitions))
-  {
-    GNUNET_break (0);
-    result = 77;
-    goto cleanup;
-  }
-
   for (unsigned int i = 0; i< 7; i++)
   {
     static unsigned int batches[] = {1, 1, 2, 4, 16, 64, 256};
@@ -114,28 +107,28 @@ run (void *cls)
                                            &value));
     now = GNUNET_TIME_absolute_get ();
     ts = GNUNET_TIME_timestamp_get ();
-    for (unsigned int r=0;r<10;r++)
+    for (unsigned int r = 0; r<10; r++)
     {
-    plugin->start_read_committed (plugin->cls,
-                                  "test_by_j");
-
-    for (unsigned int k = 0; k<batch_size; k++)
-    {
-      RND_BLK (&reserves[k].reserve_pub);
-      reserves[k].balance = value;
-      reserves[k].execution_time = ts;
-      reserves[k].sender_account_details = sndr;
-      reserves[k].exchange_account_name = "name";
-      reserves[k].wire_reference = k;
-
-    }
-    FAILIF (batch_size !=
-            plugin->batch_reserves_in_insert (plugin->cls,
-                                              reserves,
-                                              batch_size,
-                                              results));
-
-    plugin->commit (plugin->cls);
+      plugin->start_read_committed (plugin->cls,
+                                    "test_by_j");
+
+      for (unsigned int k = 0; k<batch_size; k++)
+      {
+        RND_BLK (&reserves[k].reserve_pub);
+        reserves[k].balance = value;
+        reserves[k].execution_time = ts;
+        reserves[k].sender_account_details = sndr;
+        reserves[k].exchange_account_name = "name";
+        reserves[k].wire_reference = k;
+
+      }
+      FAILIF (batch_size !=
+              plugin->batch_reserves_in_insert (plugin->cls,
+                                                reserves,
+                                                batch_size,
+                                                results));
+
+      plugin->commit (plugin->cls);
     }
     duration = GNUNET_TIME_absolute_get_duration (now);
     fprintf (stdout,
@@ -201,4 +194,5 @@ main (int argc,
   return result;
 }
 
+
 /* end of test_exchangedb_by_j.c */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]