Skip to content
Snippets Groups Projects
Commit 579cd3bf authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

Replace disabled replication/status.test with a working one

This test was disabled by me during 1.6 async-master-master development.
Since Tarantool doesn't use proc_title for replication status anymore,
I added a new test that check box.info.replication.
parent ef45ecb9
No related branches found
No related tags found
No related merge requests found
box.schema.user.grant('guest', 'read,write,execute', 'universe')
--# set connection default
box.schema.user.grant('guest', 'replication')
---
...
-- box.cfg { custom_proc_title = "master" }
--# create server replica with rpl_master=default, script='replication/replica.lua'
--# start server replica
--# set connection replica
while box.space['_priv']:len() < 1 do fiber.sleep(0.001) end
---
...
r = box.info.replication
---
...
r.status == "follow"
---
- true
...
r.lag < 1
---
- true
...
r.idle < 1
---
- true
...
box.space._schema:insert({'dup'})
---
- ['dup']
...
--# set connection default
box.space._schema:insert({'dup'})
---
- ['dup']
...
--# set connection replica
r = box.info.replication
---
...
r.status == "stopped"
---
- true
...
r.message:match('Duplicate') ~= nil
---
- true
...
box.cfg { replication_source = "" }
---
...
box.info.replication.status == "off"
---
- true
...
-- Simulate a slow server to test replication info
control_ch = require('fiber').channel(1)
---
...
--# setopt delimiter ';'
local digest = require('digest')
slowpoke = require('socket').tcp_server('127.0.0.1', 0, function(s, peer)
control_ch:get()
local seed = digest.urandom(20)
local handshake = string.format("Tarantool %-20s %-32s\n%-63s\n",
"1.6.3-slowpoke", "@megastorage", digest.base64_encode(seed))
s:write(handshake)
s:readable()
control_ch:get()
s:shutdown()
s:close()
end);
---
...
--# setopt delimiter ''
uri = slowpoke:name()
---
...
box.cfg { replication_source = 'user:pass@'..uri.host..':'..uri.port }
---
...
r = box.info.replication
---
...
r.status == "connect"
---
- true
...
control_ch:put(true)
---
- true
...
r = box.info.replication
---
...
r.status == "auth"
---
- true
...
r.lag < 1
---
- true
...
-- r.idle < 1 -- broken
slowpoke:close()
---
- true
...
control_ch:put("goodbye")
---
- true
...
r = box.info.replication
---
...
r.status == "disconnected"
---
- true
...
--# stop server replica
--# cleanup server replica
--# set connection default
box.schema.user.revoke('guest', 'replication')
---
...
True
True
--# set connection default
box.schema.user.grant('guest', 'replication')
-- box.cfg { custom_proc_title = "master" }
--# create server replica with rpl_master=default, script='replication/replica.lua'
--# start server replica
--# set connection replica
while box.space['_priv']:len() < 1 do fiber.sleep(0.001) end
r = box.info.replication
r.status == "follow"
r.lag < 1
r.idle < 1
box.space._schema:insert({'dup'})
--# set connection default
box.space._schema:insert({'dup'})
--# set connection replica
r = box.info.replication
r.status == "stopped"
r.message:match('Duplicate') ~= nil
box.cfg { replication_source = "" }
box.info.replication.status == "off"
-- Simulate a slow server to test replication info
control_ch = require('fiber').channel(1)
--# setopt delimiter ';'
local digest = require('digest')
slowpoke = require('socket').tcp_server('127.0.0.1', 0, function(s, peer)
control_ch:get()
local seed = digest.urandom(20)
local handshake = string.format("Tarantool %-20s %-32s\n%-63s\n",
"1.6.3-slowpoke", "@megastorage", digest.base64_encode(seed))
s:write(handshake)
s:readable()
control_ch:get()
s:shutdown()
s:close()
end);
--# setopt delimiter ''
uri = slowpoke:name()
box.cfg { replication_source = 'user:pass@'..uri.host..':'..uri.port }
r = box.info.replication
r.status == "connect"
control_ch:put(true)
r = box.info.replication
r.status == "auth"
r.lag < 1
-- r.idle < 1 -- broken
slowpoke:close()
control_ch:put("goodbye")
r = box.info.replication
r.status == "disconnected"
--# stop server replica
--# cleanup server replica
--# set connection default
box.schema.user.revoke('guest', 'replication')
import os
import re
import time
from lib.tarantool_server import TarantoolServer
# master server
master = server
master.admin("box.schema.user.grant('guest', 'read,write,execute', 'universe')")
# replica server
replica = TarantoolServer()
replica.script = "replication/replica.lua"
replica.rpl_master = master
replica.vardir = os.path.join(master.vardir, 'replica')
replica.deploy()
replica.get_param('node')
cycles = 0
status = replica.admin.execute_no_reconnect("box.info.status", True)
while (re.search(r'replica/.*/(connecting|connected)\n', status) == None and cycles < 500):
time.sleep(0.01)
status = replica.admin.execute_no_reconnect("box.info.status", True)
cycles += 1
print(re.search(r'replica/.*/(connecting|connected)\n', status) != None)
master.stop()
cycles = 0
while (re.search(r'replica/.*/(connecting|failed)\n', status) == None and cycles < 500):
time.sleep(0.01)
status = replica.admin.execute_no_reconnect("box.info.status", True)
cycles += 1
print(re.search(r'replica/.*/(connecting|failed)\n', status) != None)
# Cleanup.
replica.stop()
replica.cleanup(True)
master.deploy()
......@@ -2,5 +2,5 @@
core = tarantool
script = master.lua
description = tarantool/box, replication
disabled = consistent.test.lua status.test.py
disabled = consistent.test.lua
release_disabled = catch.test.lua
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment