Skip to content
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

[improve][Redis]Redis scan command supports versions 5, 6, 7 #7666

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

FuYouJ
Copy link
Contributor

@FuYouJ FuYouJ commented Sep 14, 2024

Purpose of this pull request

related bug issue #7664

  • Prior to version Redis6, Redis had different implementations of the SCAN command. This PR ensures compatibility with the SCAN command across multiple versions of Redis, including versions 5, 6, and 7.in order to ensure the running time of CI, only tests for redis5,7 are added to the code, because 6 and 7 are the same.
    QQ_1726300195428
    QQ_1726674610976
    QQ_1726300252807

Does this PR introduce any user-facing change?

How was this patch tested?

Check list

Copy link
Member

@Hisoka-X Hisoka-X left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why each redis test case keep the same config file?
image

import java.util.Collections;
import java.util.List;

public class Redis3IT extends RedisTestCaseTemplateIT {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just put all IT like Redis3IT, Redis4IT into same moudle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just put all IT like Redis3IT, Redis4IT into same moudle.

The initial version was like this, but CI would run out of time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I didn't think of a great way to run so many versions of tests and ensure that CI runs without timeout

@Hisoka-X
Copy link
Member

I checked redis version EOL. Maybe we should only keep test case 5, 6, 7? https://redis.io/docs/latest/operate/rs/installing-upgrading/product-lifecycle/

@FuYouJ
Copy link
Contributor Author

FuYouJ commented Sep 18, 2024

I checked redis version EOL. Maybe we should only keep test case 5, 6, 7? https://redis.io/docs/latest/operate/rs/installing-upgrading/product-lifecycle/

After my testing, the syntax of versions 3, 4, and 5 is consistent, and the features of versions 6 and 7 are consistent. So I only need to keep two versions of 5 and 7 for testing.which may avoid CI timeout

@FuYouJ
Copy link
Contributor Author

FuYouJ commented Sep 19, 2024

I checked redis version EOL. Maybe we should only keep test case 5, 6, 7? https://redis.io/docs/latest/operate/rs/installing-upgrading/product-lifecycle/

As the conclusion of yesterday, the command of scan are different between redis5 and 6,7, and redis 6,7 are the same, so I wrote the test code in one module, and only reserved the two tests 5 and 7.

@FuYouJ FuYouJ changed the title [improve][Redis]Redis scan command supports versions 3, 4, 5, 6, 7 Sep 19, 2024
public static final Option<RedisVersion> REDIS_VERSION =
Options.key("redis_version")
.enumType(RedisVersion.class)
.noDefaultValue()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please set default version to version 7.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the next commit, this configuration is removed because we get the version through the client.

@@ -40,14 +44,42 @@ protected RedisClient(RedisParameters redisParameters, Jedis jedis) {
this.redisParameters = redisParameters;
this.batchSize = redisParameters.getBatchSize();
this.jedis = jedis;
this.redisVersion = redisParameters.getRedisVersion();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get the version by use redis client api instead of get from users?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,good idea. We can get the redis information through jedis.info(), so we can remove the configuration option for redis_version.

private int extractRedisVersion(Jedis jedis) {
        log.info("Try to get redis version information from the jedis.info() method");
        // # Server
        // redis_version:5.0.14
        // redis_git_sha1:00000000
        // redis_git_dirty:0
        String info = jedis.info();
        try {
            for (String line : info.split("\n")) {
                if (line.startsWith("redis_version:")) {
                    // 5.0.14
                    String versionInfo = line.split(":")[1].trim();
                    log.info("The version of Redis is :{}", versionInfo);
                    String[] parts = versionInfo.split("\\.");
                    return Integer.parseInt(parts[0]);
                }
            }
        } catch (Exception e) {
            throw new RedisConnectorException(
                    GET_REDIS_VERSION_INFO_FAILED,
                    GET_REDIS_VERSION_INFO_FAILED.getErrorMessage(),
                    e);
        }
        throw new RedisConnectorException(
                GET_REDIS_VERSION_INFO_FAILED,
                "Did not get the expected redis_version from the jedis.info() method");
    }
Comment on lines +267 to +272
#spark config
spark.app.name = "SeaTunnel"
spark.executor.instances = 2
spark.executor.cores = 1
spark.executor.memory = "1g"
spark.master = local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#spark config
spark.app.name = "SeaTunnel"
spark.executor.instances = 2
spark.executor.cores = 1
spark.executor.memory = "1g"
spark.master = local
Assertions.assertEquals(0, execResult.getExitCode());
jedis.select(3);
Assertions.assertEquals(2, jedis.llen("key_multi_list"));
jedis.del("key_multi_list");
jedis.select(0);
}

///// need different redis version test override
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do need this any more?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment