Skip to content

Permanent Fix for Flaky Unit Test #1690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chayim opened this issue Nov 10, 2021 · 0 comments · Fixed by #1695
Closed

Permanent Fix for Flaky Unit Test #1690

chayim opened this issue Nov 10, 2021 · 0 comments · Fixed by #1695
Labels
maintenance Maintenance (CI, Releases, etc)

Comments

@chayim
Copy link
Contributor

chayim commented Nov 10, 2021

The test_alias unit test for RediSearch has some behaviour that is randomly flaky, specifically with the alias updates. PRs constantly randomly fail because of this. So far, we've attempted to solve these issues by adding sleeps that are specific to GitHub runners, but that isn't correct.

    @pytest.mark.redismod
    @skip_ifmodversion_lt("2.0.0", "search")
    def test_alias():
        index1 = getClient()
        index2 = getClient()
    
        index1.hset("index1:lonestar", mapping={"name": "lonestar"})
        index2.hset("index2:yogurt", mapping={"name": "yogurt"})
    
        if os.environ.get("GITHUB_WORKFLOW", None) is not None:
            time.sleep(2)
        else:
            time.sleep(5)
    
        def1 = IndexDefinition(prefix=["index1:"], score_field="name")
        def2 = IndexDefinition(prefix=["index2:"], score_field="name")
    
        ftindex1 = index1.ft("testAlias")
        ftindex2 = index1.ft("testAlias2")
        ftindex1.create_index((TextField("name"),), definition=def1)
        ftindex2.create_index((TextField("name"),), definition=def2)
    
        # CI is slower
        try:
            res = ftindex1.search("*").docs[0]
        except IndexError:
            time.sleep(5)
            res = ftindex1.search("*").docs[0]
        assert "index1:lonestar" == res.id
    
        # create alias and check for results
        ftindex1.aliasadd("spaceballs")
        alias_client = getClient().ft("spaceballs")
        res = alias_client.search("*").docs[0]
        assert "index1:lonestar" == res.id
    
        # Throw an exception when trying to add an alias that already exists
        with pytest.raises(Exception):
            ftindex2.aliasadd("spaceballs")
    
        # update alias and ensure new results
        ftindex2.aliasupdate("spaceballs")
        alias_client2 = getClient().ft("spaceballs")
    
        if os.environ.get("GITHUB_WORKFLOW", None) is not None:
            time.sleep(5)
    
>       res = alias_client2.search("*").docs[0]
E       IndexError: list index out of range
@chayim chayim added the maintenance Maintenance (CI, Releases, etc) label Nov 10, 2021
@chayim chayim mentioned this issue Nov 10, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Maintenance (CI, Releases, etc)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant