1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
env = require('test_run')
---
...
test_run = env.new()
---
...
-- gh-3159: on_schema_init triggers
-- the replica has set an on_schema_init trigger, which will set
-- _space:before_replace triggers to change 'test_engine' space engine
-- and 'test_local' space is_local flag when replication starts.
test_run:cmd('create server replica with rpl_master=default, script="replication/replica_on_schema_init.lua"')
---
- true
...
test_engine = box.schema.space.create('test_engine', {engine='memtx'})
---
...
-- Make sure that space.before_replace trigger is invoked for rows
-- received during both initial and final join stages.
box.snapshot()
---
- ok
...
test_local = box.schema.space.create('test_local', {is_local=false})
---
...
test_engine.engine
---
- memtx
...
test_local.is_local
---
- false
...
_ = test_engine:create_index("pk")
---
...
_ = test_local:create_index("pk")
---
...
test_engine:insert{1}
---
- [1]
...
test_local:insert{2}
---
- [2]
...
box.schema.user.grant('guest', 'replication')
---
...
test_run:cmd('start server replica')
---
- true
...
test_run:cmd('switch replica')
---
- true
...
box.space.test_engine.engine
---
- vinyl
...
box.space.test_local.is_local
---
- true
...
box.space.test_engine:insert{3}
---
- [3]
...
box.space.test_local:insert{4}
---
- [4]
...
box.space.test_engine:select{}
---
- - [1]
- [3]
...
box.space.test_local:select{}
---
- - [2]
- [4]
...
test_run:cmd('switch default')
---
- true
...
test_run:cmd('set variable replica_port to "replica.listen"')
---
- true
...
box.cfg{replication=replica_port}
---
...
test_engine:select{}
---
- - [1]
- [3]
...
-- the space truly became local on replica
test_local:select{}
---
- - [2]
...
box.cfg{replication=nil}
---
...
test_run:cmd('stop server replica with cleanup=1')
---
- true
...
test_run:cleanup_cluster()
---
...
box.schema.user.revoke('guest', 'replication')
---
...
test_engine:drop()
---
...
test_local:drop()
---
...
|