@@ -1604,43 +1604,42 @@ public void fcall_binary_with_keys(String prefix) {
16041604 assumeTrue (SERVER_VERSION .isGreaterThanOrEqualTo ("7.0.0" ), "This feature added in version 7" );
16051605
16061606 String key = "{" + prefix + "}-fcall_with_keys-" ;
1607+ GlideString binaryString =
1608+ gs (new byte [] {(byte ) 0xFE , (byte ) 0xEE , (byte ) 0xEF , (byte ) 252 , (byte ) 0 });
16071609 SingleNodeRoute route = new SlotKeyRoute (key , PRIMARY );
1608- String libName = "mylib_with_keys" ;
1609- GlideString funcName = gs ("myfunc_with_keys" );
1610- // function $funcName returns array with first two arguments
1610+ String libName = "mylib_with_keys_" + prefix ;
1611+ GlideString funcName = gs ("myfunc_with_keys_" + prefix );
1612+ // function $funcName returns array with first argument
16111613 String code =
1612- generateLuaLibCode (libName , Map .of (funcName .toString (), "return {keys[1], keys[2 ]}" ), true );
1614+ generateLuaLibCode (libName , Map .of (funcName .toString (), "return {args[1 ]}" ), true );
16131615
16141616 // loading function to the node where key is stored
16151617 assertEquals (libName , clusterClient .functionLoad (code , false , route ).get ());
16161618
1617- // due to common prefix, all keys are mapped to the same hash slot
16181619 var functionResult =
16191620 clusterClient
1620- .fcall (funcName , new GlideString [] {gs (key + 1 ), gs ( key + 2 ) }, new GlideString [0 ] )
1621+ .fcall (funcName , new GlideString [] {gs (key ) }, new GlideString [] { binaryString } )
16211622 .get ();
1622- assertArrayEquals (new Object [] {gs ( key + 1 ), gs ( key + 2 ) }, (Object []) functionResult );
1623+ assertArrayEquals (new Object [] {binaryString }, (Object []) functionResult );
16231624 functionResult =
16241625 clusterClient
1625- .fcallReadOnly (
1626- funcName , new GlideString [] {gs (key + 1 ), gs (key + 2 )}, new GlideString [0 ])
1626+ .fcallReadOnly (funcName , new GlideString [] {gs (key )}, new GlideString [] {binaryString })
16271627 .get ();
1628- assertArrayEquals (new Object [] {gs (key + 1 ), gs (key + 2 )}, (Object []) functionResult );
1629-
1630- // TODO: change to binary transaction version once available:
1631- // var transaction =
1632- // new ClusterTransaction()
1633- // .fcall(funcName, new String[] {key + 1, key + 2}, new String[0])
1634- // .fcallReadOnly(funcName, new String[] {key + 1, key + 2}, new String[0]);
1635-
1636- // // check response from a routed transaction request
1637- // assertDeepEquals(
1638- // new Object[][] {{key + 1, key + 2}, {key + 1, key + 2}},
1639- // clusterClient.exec(transaction, route).get());
1640- // // if no route given, GLIDE should detect it automatically
1641- // assertDeepEquals(
1642- // new Object[][] {{key + 1, key + 2}, {key + 1, key + 2}},
1643- // clusterClient.exec(transaction).get());
1628+ assertArrayEquals (new Object [] {binaryString }, (Object []) functionResult );
1629+
1630+ var transaction =
1631+ new ClusterTransaction ()
1632+ .withBinaryOutput ()
1633+ .fcall (funcName , new GlideString [] {gs (key )}, new GlideString [] {binaryString })
1634+ .fcallReadOnly (funcName , new GlideString [] {gs (key )}, new GlideString [] {binaryString });
1635+
1636+ // check response from a routed transaction request
1637+ assertDeepEquals (
1638+ new Object [][] {{binaryString }, {binaryString }},
1639+ clusterClient .exec (transaction , route ).get ());
1640+ // if no route given, GLIDE should detect it automatically
1641+ assertDeepEquals (
1642+ new Object [][] {{binaryString }, {binaryString }}, clusterClient .exec (transaction ).get ());
16441643
16451644 assertEquals (OK , clusterClient .functionDelete (libName , route ).get ());
16461645 }
@@ -1649,9 +1648,6 @@ public void fcall_binary_with_keys(String prefix) {
16491648 @ Test
16501649 public void fcall_readonly_function () {
16511650 assumeTrue (SERVER_VERSION .isGreaterThanOrEqualTo ("7.0.0" ), "This feature added in version 7" );
1652- assumeTrue (
1653- !SERVER_VERSION .isGreaterThanOrEqualTo ("8.0.0" ),
1654- "Temporary disabeling this test on valkey 8" );
16551651
16561652 String libName = "fcall_readonly_function" ;
16571653 // intentionally using a REPLICA route
@@ -1663,6 +1659,8 @@ public void fcall_readonly_function() {
16631659 String code = generateLuaLibCode (libName , Map .of (funcName , "return 42" ), false );
16641660
16651661 assertEquals (libName , clusterClient .functionLoad (code , false ).get ());
1662+ // let replica sync with the primary node
1663+ assertEquals (1L , clusterClient .wait (1L , 3000L ).get ());
16661664
16671665 // fcall on a replica node should fail, because a function isn't guaranteed to be RO
16681666 var executionException =
0 commit comments