You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@age.apache.org by de...@apache.org on 2022/10/25 19:02:43 UTC

[age] branch master updated: add regression tests for delete_global_graphs (#336)

This is an automated email from the ASF dual-hosted git repository.

dehowef pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/age.git


The following commit(s) were added to refs/heads/master by this push:
     new 04fd148  add regression tests for delete_global_graphs (#336)
04fd148 is described below

commit 04fd1481adbab6e9bff181bb3f135d8e07a53482
Author: Rafsun Masud <ra...@gmail.com>
AuthorDate: Tue Oct 25 15:02:38 2022 -0400

    add regression tests for delete_global_graphs (#336)
---
 Makefile                              |   1 +
 regress/expected/age_global_graph.out | 196 ++++++++++++++++++++++++++++++++++
 regress/sql/age_global_graph.sql      |  68 ++++++++++++
 3 files changed, 265 insertions(+)

diff --git a/Makefile b/Makefile
index da0553b..8c685a3 100644
--- a/Makefile
+++ b/Makefile
@@ -90,6 +90,7 @@ REGRESS = scan \
           cypher_union \
 	  cypher_call \
           cypher_merge \
+	  age_global_graph \
           age_load \
           index \
           drop
diff --git a/regress/expected/age_global_graph.out b/regress/expected/age_global_graph.out
new file mode 100644
index 0000000..171ec1b
--- /dev/null
+++ b/regress/expected/age_global_graph.out
@@ -0,0 +1,196 @@
+LOAD 'age';
+SET search_path TO ag_catalog;
+--
+-- test delete_specific_GRAPH_global_contexts function 
+--
+-- create 3 graphs 
+SELECT * FROM create_graph('age_global_graph_1');
+NOTICE:  graph "age_global_graph_1" has been created
+ create_graph 
+--------------
+ 
+(1 row)
+
+SELECT * FROM cypher('age_global_graph_1', $$ CREATE (v:vertex_from_graph_1) RETURN v  $$) AS (v agtype);
+                                         v                                         
+-----------------------------------------------------------------------------------
+ {"id": 844424930131969, "label": "vertex_from_graph_1", "properties": {}}::vertex
+(1 row)
+
+SELECT * FROM create_graph('age_global_graph_2');
+NOTICE:  graph "age_global_graph_2" has been created
+ create_graph 
+--------------
+ 
+(1 row)
+
+SELECT * FROM cypher('age_global_graph_2', $$ CREATE (v:vertex_from_graph_2) RETURN v  $$) AS (v agtype);
+                                         v                                         
+-----------------------------------------------------------------------------------
+ {"id": 844424930131969, "label": "vertex_from_graph_2", "properties": {}}::vertex
+(1 row)
+
+SELECT * FROM create_graph('age_global_graph_3');
+NOTICE:  graph "age_global_graph_3" has been created
+ create_graph 
+--------------
+ 
+(1 row)
+
+SELECT * FROM cypher('age_global_graph_3', $$ CREATE (v:vertex_from_graph_3) RETURN v  $$) AS (v agtype);
+                                         v                                         
+-----------------------------------------------------------------------------------
+ {"id": 844424930131969, "label": "vertex_from_graph_3", "properties": {}}::vertex
+(1 row)
+
+-- load contexts using the vertex_stats command 
+SELECT * FROM cypher('age_global_graph_3', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
+                                                  result                                                   
+-----------------------------------------------------------------------------------------------------------
+ {"id": 844424930131969, "label": "vertex_from_graph_3", "in_degree": 0, "out_degree": 0, "self_loops": 0}
+(1 row)
+
+SELECT * FROM cypher('age_global_graph_2', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
+                                                  result                                                   
+-----------------------------------------------------------------------------------------------------------
+ {"id": 844424930131969, "label": "vertex_from_graph_2", "in_degree": 0, "out_degree": 0, "self_loops": 0}
+(1 row)
+
+SELECT * FROM cypher('age_global_graph_1', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
+                                                  result                                                   
+-----------------------------------------------------------------------------------------------------------
+ {"id": 844424930131969, "label": "vertex_from_graph_1", "in_degree": 0, "out_degree": 0, "self_loops": 0}
+(1 row)
+
+-- delete age_global_graph_2's context
+-- should return true (succeeded)
+SELECT * FROM cypher('age_global_graph_2', $$ RETURN delete_global_graphs('age_global_graph_2') $$) AS (result agtype);
+ result 
+--------
+ true
+(1 row)
+
+-- delete age_global_graph_1's context
+-- should return true (succeed) because previous command should not delete the 1st graph's context
+SELECT * FROM cypher('age_global_graph_1', $$ RETURN delete_global_graphs('age_global_graph_1') $$) AS (result agtype);
+ result 
+--------
+ true
+(1 row)
+
+-- delete age_global_graph_3's context
+-- should return true (succeed) because previous commands should not delete the 3rd graph's context
+SELECT * FROM cypher('age_global_graph_3', $$ RETURN delete_global_graphs('age_global_graph_3') $$) AS (result agtype);
+ result 
+--------
+ true
+(1 row)
+
+-- delete all graphs' context again
+-- should return false (did not succeed) for all of them because already removed
+SELECT * FROM cypher('age_global_graph_2', $$ RETURN delete_global_graphs('age_global_graph_2') $$) AS (result agtype);
+ result 
+--------
+ false
+(1 row)
+
+SELECT * FROM cypher('age_global_graph_1', $$ RETURN delete_global_graphs('age_global_graph_1') $$) AS (result agtype);
+ result 
+--------
+ false
+(1 row)
+
+SELECT * FROM cypher('age_global_graph_3', $$ RETURN delete_global_graphs('age_global_graph_3') $$) AS (result agtype);
+ result 
+--------
+ false
+(1 row)
+
+    
+--
+-- test delete_GRAPH_global_contexts function 
+--
+-- load contexts again 
+SELECT * FROM cypher('age_global_graph_3', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
+                                                  result                                                   
+-----------------------------------------------------------------------------------------------------------
+ {"id": 844424930131969, "label": "vertex_from_graph_3", "in_degree": 0, "out_degree": 0, "self_loops": 0}
+(1 row)
+
+SELECT * FROM cypher('age_global_graph_2', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
+                                                  result                                                   
+-----------------------------------------------------------------------------------------------------------
+ {"id": 844424930131969, "label": "vertex_from_graph_2", "in_degree": 0, "out_degree": 0, "self_loops": 0}
+(1 row)
+
+SELECT * FROM cypher('age_global_graph_1', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
+                                                  result                                                   
+-----------------------------------------------------------------------------------------------------------
+ {"id": 844424930131969, "label": "vertex_from_graph_1", "in_degree": 0, "out_degree": 0, "self_loops": 0}
+(1 row)
+
+-- delete all graph contexts
+-- should return true
+SELECT * FROM cypher('age_global_graph_1', $$ RETURN delete_global_graphs(NULL) $$) AS (result agtype);
+ result 
+--------
+ true
+(1 row)
+
+-- delete all graphs' context individually
+-- should return false for all of them because already removed
+SELECT * FROM cypher('age_global_graph_1', $$ RETURN delete_global_graphs('age_global_graph_1') $$) AS (result agtype);
+ result 
+--------
+ false
+(1 row)
+
+SELECT * FROM cypher('age_global_graph_2', $$ RETURN delete_global_graphs('age_global_graph_2') $$) AS (result agtype);
+ result 
+--------
+ false
+(1 row)
+
+SELECT * FROM cypher('age_global_graph_3', $$ RETURN delete_global_graphs('age_global_graph_3') $$) AS (result agtype);
+ result 
+--------
+ false
+(1 row)
+
+-- drop graphs
+SELECT * FROM drop_graph('age_global_graph_1', true);
+NOTICE:  drop cascades to 3 other objects
+DETAIL:  drop cascades to table age_global_graph_1._ag_label_vertex
+drop cascades to table age_global_graph_1._ag_label_edge
+drop cascades to table age_global_graph_1.vertex_from_graph_1
+NOTICE:  graph "age_global_graph_1" has been dropped
+ drop_graph 
+------------
+ 
+(1 row)
+
+SELECT * FROM drop_graph('age_global_graph_2', true);
+NOTICE:  drop cascades to 3 other objects
+DETAIL:  drop cascades to table age_global_graph_2._ag_label_vertex
+drop cascades to table age_global_graph_2._ag_label_edge
+drop cascades to table age_global_graph_2.vertex_from_graph_2
+NOTICE:  graph "age_global_graph_2" has been dropped
+ drop_graph 
+------------
+ 
+(1 row)
+
+SELECT * FROM drop_graph('age_global_graph_3', true);
+NOTICE:  drop cascades to 3 other objects
+DETAIL:  drop cascades to table age_global_graph_3._ag_label_vertex
+drop cascades to table age_global_graph_3._ag_label_edge
+drop cascades to table age_global_graph_3.vertex_from_graph_3
+NOTICE:  graph "age_global_graph_3" has been dropped
+ drop_graph 
+------------
+ 
+(1 row)
+
+--
+-- End of tests
+--
diff --git a/regress/sql/age_global_graph.sql b/regress/sql/age_global_graph.sql
new file mode 100644
index 0000000..a62d335
--- /dev/null
+++ b/regress/sql/age_global_graph.sql
@@ -0,0 +1,68 @@
+LOAD 'age';
+SET search_path TO ag_catalog;
+
+--
+-- test delete_specific_GRAPH_global_contexts function 
+--
+
+-- create 3 graphs 
+SELECT * FROM create_graph('age_global_graph_1');
+SELECT * FROM cypher('age_global_graph_1', $$ CREATE (v:vertex_from_graph_1) RETURN v  $$) AS (v agtype);
+
+SELECT * FROM create_graph('age_global_graph_2');
+SELECT * FROM cypher('age_global_graph_2', $$ CREATE (v:vertex_from_graph_2) RETURN v  $$) AS (v agtype);
+
+SELECT * FROM create_graph('age_global_graph_3');
+SELECT * FROM cypher('age_global_graph_3', $$ CREATE (v:vertex_from_graph_3) RETURN v  $$) AS (v agtype);
+
+-- load contexts using the vertex_stats command 
+SELECT * FROM cypher('age_global_graph_3', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
+SELECT * FROM cypher('age_global_graph_2', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
+SELECT * FROM cypher('age_global_graph_1', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
+
+-- delete age_global_graph_2's context
+-- should return true (succeeded)
+SELECT * FROM cypher('age_global_graph_2', $$ RETURN delete_global_graphs('age_global_graph_2') $$) AS (result agtype);
+
+-- delete age_global_graph_1's context
+-- should return true (succeed) because previous command should not delete the 1st graph's context
+SELECT * FROM cypher('age_global_graph_1', $$ RETURN delete_global_graphs('age_global_graph_1') $$) AS (result agtype);
+
+-- delete age_global_graph_3's context
+-- should return true (succeed) because previous commands should not delete the 3rd graph's context
+SELECT * FROM cypher('age_global_graph_3', $$ RETURN delete_global_graphs('age_global_graph_3') $$) AS (result agtype);
+
+-- delete all graphs' context again
+-- should return false (did not succeed) for all of them because already removed
+SELECT * FROM cypher('age_global_graph_2', $$ RETURN delete_global_graphs('age_global_graph_2') $$) AS (result agtype);
+SELECT * FROM cypher('age_global_graph_1', $$ RETURN delete_global_graphs('age_global_graph_1') $$) AS (result agtype);
+SELECT * FROM cypher('age_global_graph_3', $$ RETURN delete_global_graphs('age_global_graph_3') $$) AS (result agtype);
+
+    
+--
+-- test delete_GRAPH_global_contexts function 
+--
+
+-- load contexts again 
+SELECT * FROM cypher('age_global_graph_3', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
+SELECT * FROM cypher('age_global_graph_2', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
+SELECT * FROM cypher('age_global_graph_1', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
+
+-- delete all graph contexts
+-- should return true
+SELECT * FROM cypher('age_global_graph_1', $$ RETURN delete_global_graphs(NULL) $$) AS (result agtype);
+
+-- delete all graphs' context individually
+-- should return false for all of them because already removed
+SELECT * FROM cypher('age_global_graph_1', $$ RETURN delete_global_graphs('age_global_graph_1') $$) AS (result agtype);
+SELECT * FROM cypher('age_global_graph_2', $$ RETURN delete_global_graphs('age_global_graph_2') $$) AS (result agtype);
+SELECT * FROM cypher('age_global_graph_3', $$ RETURN delete_global_graphs('age_global_graph_3') $$) AS (result agtype);
+
+-- drop graphs
+SELECT * FROM drop_graph('age_global_graph_1', true);
+SELECT * FROM drop_graph('age_global_graph_2', true);
+SELECT * FROM drop_graph('age_global_graph_3', true);
+
+--
+-- End of tests
+--