mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
fix: memcached VERSION is now parseable by php-memcached client (#2220)
The DF version is being unparseable by Memcached::getVersion() that expects n.n.n string. Change the version to emulate the old memcached server. The DF version can still be fetched via Memcached::getStats() function. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
3f7e42b099
commit
b853b2ab00
2 changed files with 14 additions and 1 deletions
|
@ -1335,7 +1335,7 @@ void Service::DispatchMC(const MemcacheParser::Command& cmd, std::string_view va
|
|||
server_family_.StatsMC(cmd.key, cntx);
|
||||
return;
|
||||
case MemcacheParser::VERSION:
|
||||
mc_builder->SendSimpleString(StrCat("VERSION ", kGitTag));
|
||||
mc_builder->SendSimpleString("VERSION 1.5.0 DF");
|
||||
return;
|
||||
default:
|
||||
mc_builder->SendClientError("bad command line format");
|
||||
|
|
|
@ -37,6 +37,19 @@ def test_mixed_reply(memcached_connection):
|
|||
assert memcached_connection.get(b"key") == b"data"
|
||||
|
||||
|
||||
@dfly_args({"memcached_port": 11211})
|
||||
def test_version(memcached_connection: pymemcache.Client):
|
||||
"""
|
||||
php-memcached client expects version to be in the format of "n.n.n",
|
||||
so we return 1.5.0 emulating an old memcached server. Our real version is being returned in the stats command. Also verified manually that php client parses correctly the version string
|
||||
that ends with "DF".
|
||||
"""
|
||||
assert b"1.5.0 DF" == memcached_connection.version()
|
||||
stats = memcached_connection.stats()
|
||||
version = stats[b"version"].decode("utf-8")
|
||||
assert version.startswith("v") or version == "dev"
|
||||
|
||||
|
||||
@dfly_args({"memcached_port": 11211})
|
||||
def test_length_in_set_command(df_server: DflyInstance):
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue