Debian Codegraph @

mysql-test/suite/x/t/flow_resultset_admin_create_coll.test

raw
1 ## Test of general functionality of create_collection admin command.
2
3 ## Preamble
4 --source include/xplugin_preamble.inc
5 --source include/xplugin_create_user.inc
6 ## Test starts here
7
8 --write_file $MYSQL_TMP_DIR/resultset.xpl
9 -->import assert_messages.macro
10 -->import assert_notices.macro
11 -->import validation_schema.macro
12
13 varlet %SIMPLE_SCHEMA% type:SCALAR scalar{
14 type:V_STRING v_string{value: "{\"type\":\"object\"}"}};
15
16 varlet %SCHEMA% type:SCALAR scalar{
17 type:V_STRING v_string{value:
18 "{\"type\": \"object\", \"properties\":
19 {\"latitude\": {\"type\": \"number\", \"minimum\": -90, \"maximum\": 90}},
20 \"required\": [\"latitude\"]}"}};
21
22 -->echo
23 -->echo
24 -->echo ## Check command flow when using a create_collection or
25 -->echo ## ensure_collection admin commands.
26 -->echo #
27 -->echo # 1. Create valid collection.
28 -->echo # 2. Create collection and insert valid value.
29 -->echo # 3. Create collection and insert invalid value.
30 -->echo # 4. Create collection, insert valid value and update to valid value.
31 -->echo # 5. Create collection, insert valid value and update to invalid value.
32 -->echo # 6. Create collection which is already created in the system.
33 -->echo # a) use create_collection command
34 -->echo # b) use ensure_collection command
35
36 -->echo
37 -->echo #
38 -->echo # -.1
39 callmacro Execute_admin_cmd_with_validation %COMMAND%
40 test_coll
41 %SIMPLE_SCHEMA%
42 "strict";
43 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
44 -->callmacro Drop_collection test_coll
45
46 -->echo
47 -->echo #
48 -->echo # -.2
49 callmacro Execute_admin_cmd_with_validation %COMMAND%
50 test_coll
51 %SCHEMA%
52 "strict";
53 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
54 -->callmacro Insert_value_to_collection test_coll '{"_id": "one", "latitude": 82}'
55 -->callmacro Assert_notice_session_state ROWS_AFFECTED v_unsigned_int:1
56 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
57 -->callmacro Drop_collection test_coll
58
59 -->echo
60 -->echo #
61 -->echo # -.3
62 callmacro Execute_admin_cmd_with_validation %COMMAND%
63 test_coll
64 %SCHEMA%
65 "strict";
66 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
67 -->callmacro Insert_value_to_collection test_coll '{"_id": "one", "latitude": 97}'
68 -->callmacro Assert_message Mysqlx.Error
69 -->callmacro Drop_collection test_coll
70
71 -->echo
72 -->echo #
73 -->echo # -.4
74 callmacro Execute_admin_cmd_with_validation %COMMAND%
75 test_coll
76 %SCHEMA%
77 "strict";
78 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
79 -->callmacro Insert_value_to_collection test_coll '{"_id": "one", "latitude": 82}'
80 -->callmacro Assert_notice_session_state ROWS_AFFECTED v_unsigned_int:1
81 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
82 callmacro Update_item test_coll
83 latitude
84 {type: V_SINT v_signed_int: 82}
85 {type: V_SINT v_signed_int: 80};
86 -->callmacro Assert_notice_session_state PRODUCED_MESSAGE type: V_STRING
87 -->callmacro Assert_notice_session_state ROWS_AFFECTED v_unsigned_int:1
88 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
89 -->callmacro Drop_collection test_coll
90
91 -->echo
92 -->echo #
93 -->echo # -.5
94 callmacro Execute_admin_cmd_with_validation %COMMAND%
95 test_coll
96 %SCHEMA%
97 "strict";
98 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
99 -->callmacro Insert_value_to_collection test_coll '{"_id": "one", "latitude": 82}'
100 -->callmacro Assert_notice_session_state ROWS_AFFECTED v_unsigned_int:1
101 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
102 callmacro Update_item test_coll
103 latitude
104 {type: V_SINT v_signed_int: 82}
105 {type: V_SINT v_signed_int: 123};
106 -->callmacro Assert_message Mysqlx.Error
107 -->callmacro Drop_collection test_coll
108
109 -->echo
110 -->echo #
111 -->echo # -.6.a
112 callmacro Execute_admin_cmd_with_validation create_collection
113 test_coll
114 %SCHEMA%
115 "strict";
116 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
117 callmacro Execute_admin_cmd_with_validation create_collection
118 test_coll
119 %SCHEMA%
120 "strict";
121 -->callmacro Assert_message Mysqlx.Error
122 -->callmacro Drop_collection test_coll
123
124 -->echo
125 -->echo #
126 -->echo # -.6.b
127 callmacro Execute_admin_cmd_with_validation create_collection
128 test_coll
129 %SCHEMA%
130 "strict";
131 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
132 callmacro Execute_admin_cmd_with_validation ensure_collection
133 test_coll
134 %SCHEMA%
135 "strict";
136 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
137 -->callmacro Drop_collection test_coll
138
139 EOF
140
141
142 CREATE SCHEMA IF NOT EXISTS xtest;
143 USE xtest;
144
145 exec $MYSQLXTEST
146 -ux_root --password=''
147 --schema=xtest
148 --file=$MYSQL_TMP_DIR/resultset.xpl -v%COMMAND%=create_collection 2>&1;
149
150 exec $MYSQLXTEST
151 -ux_root --password=''
152 --schema=xtest
153 --file=$MYSQL_TMP_DIR/resultset.xpl -v%COMMAND%=ensure_collection 2>&1;
154
155 ## Cleanup
156 --source ../include/xplugin_cleanup.inc