-
Notifications
You must be signed in to change notification settings - Fork 975
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
Remove not readonly commands #2832 #2871
Merged
Merged
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
10ebbf4
Remove not readonly commands #2832
thachlp e3080fd
Fix comment
thachlp 36dc55a
Update test
thachlp 1dcef97
Update cicd.yaml
atakavci 430945e
GitHub issue template polishing and stale issues action (#2833)
tishun c1d213c
Implement HEXPIRE, HEXPIREAT, HEXPIRETIME and HPERSIST (#2836)
tishun 9781769
MAke sure we wait for the check so it does not fail on the slower pip…
tishun 53050ea
Add support for `SPUBLISH` (#2838)
atakavci e8ae914
Applying code formatter each time we run a Maven build (#2841)
tishun c0c5782
Update cicd.yaml
atakavci 4eac609
Add support CLIENT KILL [MAXAGE] (#2782)
dengliming 2899770
Add support for `SUNSUBSCRIBE` #2759 (#2851)
atakavci 7a5f988
Mark dnsResolver(DnsResolver) as deprecated. (#2855)
yfwz100 11e5ee6
Implement HPEXPIRE, HPEXPIREAT, HPEXPIRETIME, HTTL and HPTTL (#2857)
tishun 5612e29
XREAD support for reading last message from stream (#2863)
tishun 7d5087e
Add a `evalReadOnly` overload that accepts the script as a `String` (…
BalmungSan 9832f90
Add release drafter workflow (#2820)
tishun 3c44012
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.3 to 3.7.…
dependabot[bot] 1c272ec
Bump org.codehaus.mojo:flatten-maven-plugin from 1.5.0 to 1.6.0 (#2874)
dependabot[bot] eb07932
Bump org.apache.maven.plugins:maven-jar-plugin from 3.3.0 to 3.4.1 (#…
dependabot[bot] a5e535c
Bump org.openjdk.jmh:jmh-generator-annprocess from 1.21 to 1.37 (#2876)
dependabot[bot] d3b6214
Bump org.apache.commons:commons-pool2 from 2.11.1 to 2.12.0 (#2877)
dependabot[bot] 544ec67
Setting the next release to be 6.4.x as part of #2880 (#2881)
tishun caadbfe
Modify the release acrtion to call the proper maven target for releas…
tishun 74ec22f
Format file
thachlp 8fdbd97
Using interface method from java 8 instead of java 9
thachlp a1ab7ef
Fix test
thachlp fe2f247
Revert readwrite command to the list
thachlp 2f54211
Merge branch 'main' into remove-not-read-only-command
thachlp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
72 changes: 0 additions & 72 deletions
72
src/main/java/io/lettuce/core/masterreplica/ReadOnlyCommands.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/test/java/io/lettuce/core/commands/ReadOnlyCommandIntegrationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package io.lettuce.core.commands; | ||
|
||
import io.lettuce.core.TestSupport; | ||
import io.lettuce.core.api.sync.RedisCommands; | ||
import io.lettuce.core.cluster.ClusterReadOnlyCommands; | ||
import io.lettuce.core.cluster.ClusterTestUtil; | ||
import io.lettuce.core.cluster.api.StatefulRedisClusterConnection; | ||
import io.lettuce.core.cluster.api.sync.RedisClusterCommands; | ||
import io.lettuce.core.protocol.CommandType; | ||
import io.lettuce.core.protocol.ProtocolKeyword; | ||
import io.lettuce.core.protocol.ReadOnlyCommands; | ||
import io.lettuce.test.KeyValueStreamingAdapter; | ||
import io.lettuce.test.LettuceExtension; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import javax.inject.Inject; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Thach Le | ||
*/ | ||
@ExtendWith(LettuceExtension.class) | ||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
class ReadOnlyCommandIntegrationTests extends TestSupport { | ||
|
||
private final RedisCommands<String, String> redis; | ||
|
||
@Inject | ||
protected ReadOnlyCommandIntegrationTests(RedisCommands<String, String> redis) { | ||
this.redis = redis; | ||
} | ||
|
||
@BeforeEach | ||
void setUp() { | ||
redis.flushall(); | ||
} | ||
|
||
@Test | ||
void testReadOnlyCommands() { | ||
for (ProtocolKeyword readOnlyCommand : ClusterReadOnlyCommands.getReadOnlyCommands()) { | ||
assertThat(isCommandReadOnly(readOnlyCommand.name())).isTrue(); | ||
} | ||
} | ||
|
||
private boolean isCommandReadOnly(String commandName) { | ||
List<Object> commandInfo = redis.commandInfo(commandName); | ||
if (commandInfo == null || commandInfo.isEmpty()) { | ||
throw new IllegalArgumentException("Command not found: " + commandName); | ||
} | ||
|
||
List<Object> flags = (List<Object>) commandInfo.get(2); // Index 2 is the flags list | ||
return flags.contains("readonly") && !flags.contains("write"); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! This is exactly what I wanted to see and it would help us keep this list up-to-date.
Two notes:
ServerCommandIntegrationTest
- no need to create a whole new class for itCommandDetailParser
to parse the result, instead of parsing it yourself (would also mean that if something changes in the result API you would not have to modify the test and we will keep the change locally to the parser)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tishun, thanks for the notes.
I updated the test, please help check 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, If anything need to pass the CI check, please suggest.
On local, I got this message: