@@ -547,3 +547,43 @@ pgroup.test_delete_secondary_idx = function(g)
547
547
" Sharding key for space \" customers_secondary_idx_name_key\" is missed in primary index, specify bucket_id" )
548
548
t .assert_equals (result , nil )
549
549
end
550
+
551
+ pgroup .test_update_sharding_keys_cache = function (g )
552
+ local space_name = ' customers_name_key'
553
+ local sharding_key = helpers .update_sharding_keys_cache (g .cluster , space_name )
554
+ t .assert_equals (sharding_key , {' name' })
555
+
556
+ helpers .call_on_servers (g .cluster , {' s1-master' , ' s2-master' }, function (server )
557
+ server .net_box :call (' set_sharding_key' , {space_name , {' age' }})
558
+ end )
559
+ sharding_key = helpers .update_sharding_keys_cache (g .cluster , space_name )
560
+ t .assert_equals (sharding_key , {' age' })
561
+
562
+ -- Recover sharding key.
563
+ helpers .call_on_servers (g .cluster , {' s1-master' , ' s2-master' }, function (server )
564
+ server .net_box :call (' set_sharding_key' , {space_name , {' name' }})
565
+ end )
566
+ sharding_key = helpers .update_sharding_keys_cache (g .cluster , space_name )
567
+ t .assert_equals (sharding_key , {' name' })
568
+ end
569
+
570
+ pgroup .test_non_unique_index = function (g )
571
+ local space_name = ' customers_name_key_non_uniq_index'
572
+ local tuple = {6 , box .NULL , ' Victor' , 58 }
573
+
574
+ -- insert tuple
575
+ local result , err = g .cluster .main_server .net_box :call (' crud.insert' , {
576
+ space_name , tuple
577
+ })
578
+
579
+ t .assert_equals (err , nil )
580
+ t .assert_not_equals (result , nil )
581
+ t .assert_equals (# result .rows , 1 )
582
+
583
+ local result , err = g .cluster .main_server .net_box :call (' crud.select' , {
584
+ space_name , {{' ==' , ' name' , ' Victor' }}
585
+ })
586
+ t .assert_equals (err , nil )
587
+ t .assert_not_equals (result , nil )
588
+ t .assert_equals (# result .rows , 1 )
589
+ end
0 commit comments