Skip to content

Flaky test test_acl_from_snapshot

https://git.picodata.io/core/picodata/-/pipelines/60287/test_report?job_name=test-linux%3A+%5Bdev%2C+debug%5D

cluster = Cluster("127.0.0.1", n=5)

    def test_acl_from_snapshot(cluster: Cluster):
        i1 = cluster.add_instance(wait_online=True, replicaset_name="R1")
        i2 = cluster.add_instance(wait_online=True, replicaset_name="R1")
        i3 = cluster.add_instance(wait_online=True, replicaset_name="R1")
        i4 = cluster.add_instance(wait_online=True, replicaset_name="R2")
        i5 = cluster.add_instance(wait_online=True, replicaset_name="R2")
    
        #
        # Initial state.
        #
        i1.sql(f"CREATE USER \"Sam\" WITH PASSWORD '{VALID_PASSWORD}'")
        index = i1.call(".proc_get_index")
        cluster.raft_wait_index(index)
    
        i1.sql('CREATE ROLE "Captain"')
        index = i1.call(".proc_get_index")
        cluster.raft_wait_index(index)
    
        i1.grant_privilege("Sam", "read", "table", "_pico_property")
        index = i1.call(".proc_get_index")
        cluster.raft_wait_index(index)
    
        i1.grant_privilege("Captain", "read", "table", "_pico_table")
        index = i1.call(".proc_get_index")
        cluster.raft_wait_index(index)
    
        #
        # Before:
        #
        for i in [i4, i5]:
            assert to_set_of_tuples(i.call("box.schema.user.info", "Sam")) == {
                ("execute", "role", "public"),
                ("read", "space", "_pico_property"),
                ("session,usage", "universe", ""),
                ("alter", "user", "Sam"),
            }
    
            with pytest.raises(TarantoolError, match="User 'Blam' is not found"):
                i.call("box.schema.user.info", "Blam")
    
            assert to_set_of_tuples(i.call("box.schema.role.info", "Captain")) == {
                ("read", "space", "_pico_table"),
            }
    
            with pytest.raises(TarantoolError, match="Role 'Writer' is not found"):
                i.call("box.schema.role.info", "Writer")
    
        #
        # These will be catching up by snapshot.
        #
        i5.terminate()
        i4.terminate()
    
        #
        # These changes will arive by snapshot.
        #
        i1.sql('DROP USER "Sam"')
        index = i1.call(".proc_get_index")
        cluster.raft_wait_index(index)
    
        i1.sql(f"CREATE USER \"Blam\" WITH PASSWORD '{VALID_PASSWORD}'")
        index = i1.call(".proc_get_index")
        cluster.raft_wait_index(index)
    
        i1.revoke_privilege("Captain", "read", "table", "_pico_table")
        index = i1.call(".proc_get_index")
        cluster.raft_wait_index(index)
    
        i1.grant_privilege("Captain", "read", "table", "_pico_instance")
        index = i1.call(".proc_get_index")
        cluster.raft_wait_index(index)
    
        i1.sql('CREATE ROLE "Writer"')
        index = i1.call(".proc_get_index")
        cluster.raft_wait_index(index)
    
        i1.grant_privilege("Writer", "write", "table")
        index = i1.call(".proc_get_index")
        cluster.raft_wait_index(index)
    
        i1.grant_privilege("Blam", "execute", "role", "Writer")
        index = i1.call(".proc_get_index")
        cluster.raft_wait_index(index)
    
        # Compact log to trigger snapshot generation.
        i1.raft_compact_log()
        i2.raft_compact_log()
        i3.raft_compact_log()
    
        #
        # Catchup by snapshot.
        #
        i4.start()
        i5.start()
>       i4.wait_online()

cluster    = Cluster("127.0.0.1", n=5)
i          = Instance(i5, listen=127.0.0.1:3342 cluster=cluster-0-6, process.pid=51219)
i1         = Instance(i1, listen=127.0.0.1:3334 cluster=cluster-0-6, process.pid=49745)
i2         = Instance(i2, listen=127.0.0.1:3336 cluster=cluster-0-6, process.pid=49842)
i3         = Instance(i3, listen=127.0.0.1:3338 cluster=cluster-0-6, process.pid=50038)
i4         = Instance(i4, listen=127.0.0.1:3340 cluster=cluster-0-6, process.pid=51216)
i5         = Instance(i5, listen=127.0.0.1:3342 cluster=cluster-0-6, process.pid=51219)
index      = 61

test/int/test_acl.py:475: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Instance(i4, listen=127.0.0.1:3340 cluster=cluster-0-6, process.pid=51216)
timeout = 30, rps = 5, expected_incarnation = None

    def wait_online(
        self, timeout: int | float = 30, rps: int | float = 5, expected_incarnation=None
    ):
        """Wait until instance attains Online grade.
    
        This function will periodically check the current instance's grade and
        reset the timeout each time the grade changes.
    
        Args:
            timeout (int | float, default=6): time limit since last grade change
            rps (int | float, default=5): retries per second
    
        Raises:
            AssertionError: if doesn't succeed
        """
    
        if self.process is None:
            raise ProcessDead("process was not started")
    
        def fetch_current_state() -> Tuple[str, int]:
            myself = self.instance_info()
    
            assert isinstance(myself["current_state"], dict)
            return (
                myself["current_state"]["variant"],
                myself["current_state"]["incarnation"],
            )
    
        start = time.monotonic()
        deadline = start + timeout
        next_retry = start
        last_state = None
        while True:
            now = time.monotonic()
>           assert now < deadline, "timeout"
E           AssertionError: timeout
E           assert < failed. [pytest-clarity diff shown]
E             #x1B[0m
E             #x1B[0m#x1B[32mLHS#x1B[0m vs #x1B[31mRHS#x1B[0m shown below
E             #x1B[0m
E             #x1B[0m#x1B[32m6385558.919179226#x1B[0m
E             #x1B[0m#x1B[31m6385558.890868736#x1B[0m
E             #x1B[0m

deadline   = 6385558.890868736
expected_incarnation = None
fetch_current_state = <function Instance.wait_online.<locals>.fetch_current_state at 0x7dba9f79bce0>
incarnation = 1
last_state = ('Offline', 1)
next_retry = 6385559.1170599675
now        = 6385558.919179226
rps        = 5
self       = Instance(i4, listen=127.0.0.1:3340 cluster=cluster-0-6, process.pid=51216)
start      = 6385526.887313479
state      = ('Offline', 1)
timeout    = 30
variant    = 'Offline'

test/conftest.py:1364: AssertionError
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information