Changeset: 83da5226b63d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=83da5226b63d
Added Files:
        sql/test/configurable_rss/Tests/cap_rss_32.py.src
Removed Files:
        sql/test/configurable_rss/Tests/cap_rss_32.py
        sql/test/configurable_rss/Tests/push_and_check_rss.sql
        sql/test/configurable_rss/Tests/push_and_check_rss_32.sql
Modified Files:
        sql/test/configurable_rss/Tests/cap_rss.py
Branch: config_rss
Log Message:

The cap_rss tests use a single python script and embedded sql template.


diffs (196 lines):

diff --git a/sql/test/configurable_rss/Tests/cap_rss.py 
b/sql/test/configurable_rss/Tests/cap_rss.py
--- a/sql/test/configurable_rss/Tests/cap_rss.py
+++ b/sql/test/configurable_rss/Tests/cap_rss.py
@@ -4,6 +4,57 @@ try:
 except ImportError:
     import process
 
+class RSSTestConfig:
+
+    # CAUTION: switch implementation without default.
+    test_2_gdk_mem_maxsize = {
+        "cap_rss_64" : 20000000,
+        "cap_rss_32" : 10000000
+    }
+
+    sql_template = \
+"""
+create function getrss()
+returns bigint external name status.rss_cursize;
+
+create table test(a int, b int, c double);
+
+insert into test values (1, 0, 1);
+
+create procedure loop_insert(maximum_size bigint)
+begin
+    declare size bigint;
+    set size = (select count(*) from test);
+
+    while size < maximum_size do
+        insert into test (select a+1, b+2, rand()*c from test);
+
+        set size = (select count(*) from test);
+    end while;
+end;
+
+call loop_insert(1000000);
+
+-- it seems that it requires an analytical query to keep memory in ram.
+select getrss() < {0} as resident_set_size_is_less_then_{0}_kB, quantile(c/a, 
0.8) * 0  from test;
+
+drop table test cascade;
+drop function getrss;
+"""
+
+    def __init__(self, test):
+        self.rss_max_in_Bytes = RSSTestConfig.test_2_gdk_mem_maxsize[test]
+
+    def prepare_server_options(self):
+        return ["--set", "gdk_mem_maxsize={}".format(self.rss_max_in_Bytes)]
+
+    def prepare_sql_script(self):
+            return RSSTestConfig.sql_template.format(self.rss_max_in_Bytes / 
1000)
+
+def build_test_config():
+        test = sys.argv[1]
+        return RSSTestConfig(test)
+
 def server_start(args):
     sys.stderr.write('#mserver: "%s"\n' % ' '.join(args))
     sys.stderr.flush()
@@ -11,19 +62,22 @@ def server_start(args):
                          stdout = process.PIPE, stderr = process.PIPE)
     return srv
 
-def client(lang, file):
-    sys.stderr.write('#client: "%s"\n' % file)
-    sys.stderr.flush()
-    clt = process.client(lang.lower(), stdin = open(file),
+def client(lang, query):
+    clt = process.client(lang.lower(), stdin = process.PIPE,
                          stdout = process.PIPE, stderr = process.PIPE)
-    return clt.communicate()
+    return clt.communicate(input = query)
 
 def main():
-    srv = server_start(["--set", "gdk_mem_maxsize=20000000"])
+
+    test_config = build_test_config()
+
+    options = test_config.prepare_server_options()
 
-    out, err = client('SQL',
-                      os.path.join(os.getenv('RELSRCDIR'),
-                                   'push_and_check_rss.sql'))
+    srv = server_start(options)
+
+    script = test_config.prepare_sql_script()
+
+    out, err = client('SQL', script)
     sys.stdout.write(out)
     sys.stderr.write(err)
     out, err = srv.communicate()
diff --git a/sql/test/configurable_rss/Tests/cap_rss_32.py 
b/sql/test/configurable_rss/Tests/cap_rss_32.py
deleted file mode 100644
--- a/sql/test/configurable_rss/Tests/cap_rss_32.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import os, sys
-try:
-    from MonetDBtesting import process
-except ImportError:
-    import process
-
-def server_start(args):
-    sys.stderr.write('#mserver: "%s"\n' % ' '.join(args))
-    sys.stderr.flush()
-    srv = process.server(args = args, stdin = process.PIPE,
-                         stdout = process.PIPE, stderr = process.PIPE)
-    return srv
-
-def client(lang, file):
-    sys.stderr.write('#client: "%s"\n' % file)
-    sys.stderr.flush()
-    clt = process.client(lang.lower(), stdin = open(file),
-                         stdout = process.PIPE, stderr = process.PIPE)
-    return clt.communicate()
-
-def main():
-    srv = server_start(["--set", "gdk_mem_maxsize=20000000"])
-
-    out, err = client('SQL',
-                      os.path.join(os.getenv('RELSRCDIR'),
-                                   'push_and_check_rss_32.sql'))
-    sys.stdout.write(out)
-    sys.stderr.write(err)
-    out, err = srv.communicate()
-    sys.stdout.write(out)
-    sys.stderr.write(err)
-
-main()
diff --git a/sql/test/configurable_rss/Tests/cap_rss_64.py.src 
b/sql/test/configurable_rss/Tests/cap_rss_32.py.src
copy from sql/test/configurable_rss/Tests/cap_rss_64.py.src
copy to sql/test/configurable_rss/Tests/cap_rss_32.py.src
diff --git a/sql/test/configurable_rss/Tests/push_and_check_rss.sql 
b/sql/test/configurable_rss/Tests/push_and_check_rss.sql
deleted file mode 100644
--- a/sql/test/configurable_rss/Tests/push_and_check_rss.sql
+++ /dev/null
@@ -1,26 +0,0 @@
-create function getrss() 
-returns bigint external name status.rss_cursize;
-
-create table test(a int, b int, c double);
-
-insert into test values (1, 0, 1);
-
-create procedure loop_insert(maximum_size bigint)
-begin
-    declare size bigint;
-    set size = (select count(*) from test);
-
-    while size < maximum_size do
-        insert into test (select a+1, b+2, rand()*c from test);
-
-        set size = (select count(*) from test);
-    end while;
-end;
-
-call loop_insert(1000000);
-
--- it seems that it requires an analytical query to keep memory in ram.
-select getrss() < 20000 as resident_set_size_is_less_then_20kbytes, 
quantile(c/a, 0.8) * 0  from test;
-
-drop table test cascade;
-drop function getrss;
diff --git a/sql/test/configurable_rss/Tests/push_and_check_rss_32.sql 
b/sql/test/configurable_rss/Tests/push_and_check_rss_32.sql
deleted file mode 100644
--- a/sql/test/configurable_rss/Tests/push_and_check_rss_32.sql
+++ /dev/null
@@ -1,26 +0,0 @@
-create function getrss() 
-returns bigint external name status.rss_cursize;
-
-create table test(a int, b int, c double);
-
-insert into test values (1, 0, 1);
-
-create procedure loop_insert(maximum_size bigint)
-begin
-    declare size bigint;
-    set size = (select count(*) from test);
-
-    while size < maximum_size do
-        insert into test (select a+1, b+2, rand()*c from test);
-
-        set size = (select count(*) from test);
-    end while;
-end;
-
-call loop_insert(1000000);
-
--- it seems that it requires an analytical query to keep memory in ram.
-select getrss() as resident_set_size, quantile(c/a, 0.8) * 0  from test;
-
-drop table test cascade;
-drop function getrss;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to