mirror of
https://github.com/valitydev/riak_test.git
synced 2024-11-06 16:45:29 +00:00
Merge pull request #936 from basho/at/ts_encoding_tests
Add tests for utf8 and latin1 in the table definition
This commit is contained in:
commit
f8795caac7
@ -636,9 +636,9 @@ admin(Node, Args, Options) ->
|
||||
N = node_id(Node),
|
||||
Path = relpath(node_version(N)),
|
||||
Cmd = riak_admin_cmd(Path, N, Args),
|
||||
lager:info("Running: ~s", [Cmd]),
|
||||
lager:info("Running: ~ts", [Cmd]),
|
||||
Result = execute_admin_cmd(Cmd, Options),
|
||||
lager:info("~p", [Result]),
|
||||
lager:info("~ts", [Result]),
|
||||
{ok, Result}.
|
||||
|
||||
execute_admin_cmd(Cmd, Options) ->
|
||||
|
45
tests/ts_latin1_create_table_not_allowed.erl
Normal file
45
tests/ts_latin1_create_table_not_allowed.erl
Normal file
@ -0,0 +1,45 @@
|
||||
%% -------------------------------------------------------------------
|
||||
%%
|
||||
%% Copyright (c) 2015 Basho Technologies, Inc.
|
||||
%%
|
||||
%% This file is provided to you under the Apache License,
|
||||
%% Version 2.0 (the "License"); you may not use this file
|
||||
%% except in compliance with the License. You may obtain
|
||||
%% a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
%% -------------------------------------------------------------------
|
||||
|
||||
%% Test for creating a latin1 table name. This should fail
|
||||
%% because of mochijson decoding.
|
||||
|
||||
-module(ts_latin1).
|
||||
|
||||
-behavior(riak_test).
|
||||
|
||||
-export([confirm/0]).
|
||||
|
||||
confirm() ->
|
||||
TableDef =
|
||||
"CREATE TABLE mytãble ("
|
||||
"family VARCHAR NOT NULL, "
|
||||
"series VARCHAR NOT NULL, "
|
||||
"time TIMESTAMP NOT NULL, "
|
||||
"PRIMARY KEY ((family, series, quantum(time, 15, 's')), family, series, time))",
|
||||
[Node | _] = ts_util:build_cluster(single),
|
||||
{[Node|_] = Cluster,_} = ts_util:cluster_and_connect(single),
|
||||
{ok, Out} = ts_util:create_bucket_type(Cluster, TableDef, "mytãble"),
|
||||
case binary:match(list_to_binary(Out), <<"invalid json">>) of
|
||||
nomatch ->
|
||||
{error,"Expecting this to fail, check implications for riak_ql"};
|
||||
_ ->
|
||||
pass
|
||||
end.
|
45
tests/ts_unicode_create_table_not_allowed.erl
Normal file
45
tests/ts_unicode_create_table_not_allowed.erl
Normal file
@ -0,0 +1,45 @@
|
||||
%% -------------------------------------------------------------------
|
||||
%%
|
||||
%% Copyright (c) 2015 Basho Technologies, Inc.
|
||||
%%
|
||||
%% This file is provided to you under the Apache License,
|
||||
%% Version 2.0 (the "License"); you may not use this file
|
||||
%% except in compliance with the License. You may obtain
|
||||
%% a copy of the License at
|
||||
%%
|
||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||
%%
|
||||
%% Unless required by applicable law or agreed to in writing,
|
||||
%% software distributed under the License is distributed on an
|
||||
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
%% KIND, either express or implied. See the License for the
|
||||
%% specific language governing permissions and limitations
|
||||
%% under the License.
|
||||
%%
|
||||
%% -------------------------------------------------------------------
|
||||
|
||||
%% Test for creating a utf8 table name. This should fail
|
||||
%% because of mochijson decoding.
|
||||
|
||||
-module(ts_unicode_2).
|
||||
|
||||
-behavior(riak_test).
|
||||
|
||||
-export([confirm/0]).
|
||||
|
||||
confirm() ->
|
||||
TableDef =
|
||||
"CREATE TABLE Αισθητήρας ("
|
||||
"family VARCHAR NOT NULL, "
|
||||
"series VARCHAR NOT NULL, "
|
||||
"time TIMESTAMP NOT NULL, "
|
||||
"PRIMARY KEY ((family, series, quantum(time, 15, 's')), family, series, time))",
|
||||
[Node | _] = ts_util:build_cluster(single),
|
||||
{[Node|_] = Cluster,_} = ts_util:cluster_and_connect(single),
|
||||
{ok, Out} = ts_util:create_bucket_type(Cluster, TableDef, "Αισθητήρας"),
|
||||
case binary:match(list_to_binary(Out), <<"invalid json">>) of
|
||||
nomatch ->
|
||||
{error,"Expecting this to fail, check implications for riak_ql"};
|
||||
_ ->
|
||||
pass
|
||||
end.
|
@ -50,14 +50,14 @@
|
||||
get_valid_select_data_spanning_quanta/0,
|
||||
get_varchar/0,
|
||||
maybe_stop_a_node/2,
|
||||
ts_query/5,
|
||||
ts_query/6,
|
||||
remove_last/1,
|
||||
single_query/2,
|
||||
ts_get/6,
|
||||
ts_get/7,
|
||||
ts_put/4,
|
||||
ts_put/5,
|
||||
single_query/2
|
||||
ts_query/5,
|
||||
ts_query/6
|
||||
]).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
@ -73,7 +73,7 @@ ts_put(ClusterConn, TestType, DDL, Obj) ->
|
||||
ts_put({Cluster, Conn}, TestType, DDL, Obj, Bucket) ->
|
||||
|
||||
create_table(TestType, Cluster, DDL, Bucket),
|
||||
lager:info("2 - writing to bucket ~p with:~n- ~p", [Bucket, Obj]),
|
||||
lager:info("2 - writing to bucket ~ts with:~n- ~p", [Bucket, Obj]),
|
||||
riakc_ts:put(Conn, Bucket, Obj).
|
||||
|
||||
ts_get(ClusterConn, TestType, DDL, Obj, Key, Options) ->
|
||||
@ -82,10 +82,10 @@ ts_get(ClusterConn, TestType, DDL, Obj, Key, Options) ->
|
||||
ts_get({Cluster, Conn}, TestType, DDL, Obj, Key, Options, Bucket) ->
|
||||
|
||||
create_table(TestType, Cluster, DDL, Bucket),
|
||||
lager:info("2 - writing to bucket ~p with:~n- ~p", [Bucket, Obj]),
|
||||
lager:info("2 - writing to bucket ~ts with:~n- ~p", [Bucket, Obj]),
|
||||
ok = riakc_ts:put(Conn, Bucket, Obj),
|
||||
|
||||
lager:info("3 - reading from bucket ~p with key ~p", [Bucket, Key]),
|
||||
lager:info("3 - reading from bucket ~ts with key ~p", [Bucket, Key]),
|
||||
riakc_ts:get(Conn, Bucket, Key, Options).
|
||||
|
||||
ts_query(ClusterConn, TestType, DDL, Data, Qry) ->
|
||||
@ -95,15 +95,15 @@ ts_query({Cluster, Conn}, TestType, DDL, Data, Qry, Bucket) ->
|
||||
|
||||
create_table(TestType, Cluster, DDL, Bucket),
|
||||
|
||||
lager:info("2 - writing to bucket ~p with:~n- ~p", [Bucket, Data]),
|
||||
lager:info("2 - writing to bucket ~ts with:~n- ~p", [Bucket, Data]),
|
||||
ok = riakc_ts:put(Conn, Bucket, Data),
|
||||
|
||||
single_query(Conn, Qry).
|
||||
|
||||
single_query(Conn, Qry) ->
|
||||
lager:info("3 - Now run the query ~p", [Qry]),
|
||||
lager:info("3 - Now run the query ~ts", [Qry]),
|
||||
Got = riakc_ts:query(Conn, Qry),
|
||||
lager:info("Result is ~p", [Got]),
|
||||
lager:info("Result is ~ts", [Got]),
|
||||
Got.
|
||||
|
||||
%%
|
||||
@ -113,11 +113,11 @@ single_query(Conn, Qry) ->
|
||||
-spec(create_table(normal|n_val_one|no_ddl, [node()], string(), string()) -> ok).
|
||||
create_table(normal, Cluster, DDL, Bucket) ->
|
||||
lager:info("1 - Create and activate the bucket"),
|
||||
lager:debug("DDL = ~p", [DDL]),
|
||||
lager:debug("DDL = ~ts", [DDL]),
|
||||
create_and_activate_bucket_type(Cluster, DDL, Bucket);
|
||||
create_table(n_val_one, Cluster, DDL, Bucket) ->
|
||||
lager:info("1 - Creating and activating bucket"),
|
||||
lager:debug("DDL = ~p", [DDL]),
|
||||
lager:debug("DDL = ~ts", [DDL]),
|
||||
create_and_activate_bucket_type(Cluster, DDL, Bucket);
|
||||
create_table(no_ddl, _Cluster, _DDL, _Bucket) ->
|
||||
lager:info("1 - NOT Creating or activating bucket - failure test"),
|
||||
|
Loading…
Reference in New Issue
Block a user