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

Test with 8.0-M04-pre #4069

Merged
merged 12 commits into from
Jan 30, 2025
1 change: 1 addition & 0 deletions .github/workflows/test-on-docker.yml
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ jobs:
fail-fast: false
matrix:
redis_version:
- "8.0-M04-pre"
- "8.0-M02"
ggivo marked this conversation as resolved.
Show resolved Hide resolved
- "7.4.1"
- "7.2.6"
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PATH := ./redis-git/src:${PATH}

# Supported test env versions
SUPPORTED_TEST_ENV_VERSIONS := 8.0-M02 7.4.1 7.2.6 6.2.16
DEFAULT_TEST_ENV_VERSION := 8.0-M02
SUPPORTED_TEST_ENV_VERSIONS := 8.0-M04-pre, 8.0-M02 7.4.1 7.2.6 6.2.16
DEFAULT_TEST_ENV_VERSION := 8.0-M04-pre
REDIS_ENV_WORK_DIR := $(or ${REDIS_ENV_WORK_DIR},/tmp/redis-env-work)

define REDIS1_CONF
ggivo marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
package redis.clients.jedis.modules.search;

import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.emptyString;
ggivo marked this conversation as resolved.
Show resolved Hide resolved
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
ggivo marked this conversation as resolved.
Show resolved Hide resolved
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
import static org.junit.Assert.fail;
ggivo marked this conversation as resolved.
Show resolved Hide resolved
import static redis.clients.jedis.util.AssertUtil.assertOK;

import java.util.*;

import org.hamcrest.MatcherAssert;
ggivo marked this conversation as resolved.
Show resolved Hide resolved
import org.hamcrest.Matchers;
ggivo marked this conversation as resolved.
Show resolved Hide resolved
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import redis.clients.jedis.RedisProtocol;
import redis.clients.jedis.UnifiedJedis;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.search.*;
import redis.clients.jedis.search.schemafields.NumericField;
@@ -107,62 +115,35 @@ public void testDialectsWithFTExplain() throws Exception {

String q = "(*)";
Query query = new Query(q).dialect(1);
try {
client.ftExplain(INDEX, query);
fail();
} catch (JedisDataException e) {
assertTrue("Should contain 'Syntax error'", e.getMessage().contains("Syntax error"));
}
query = new Query(q); // dialect=default=2
assertSyntaxError(query, client); // dialect=1 throws syntax error
query = new Query(q); // dialect=default=2 should return execution plan
assertTrue("Should contain 'WILDCARD'", client.ftExplain(INDEX, query).contains("WILDCARD"));

q = "$hello";
query = new Query(q).dialect(1);
try {
client.ftExplain(INDEX, query);
fail();
} catch (JedisDataException e) {
assertTrue("Should contain 'Syntax error'", e.getMessage().contains("Syntax error"));
}
query = new Query(q).addParam("hello", "hello"); // dialect=default=2
assertTrue("Should contain 'UNION {\n hello\n +hello(expanded)\n}\n'",
client.ftExplain(INDEX, query).contains("UNION {\n hello\n +hello(expanded)\n}\n"));
assertSyntaxError(query, client); // dialect=1 throws syntax error
query = new Query(q).addParam("hello", "hello"); // dialect=default=2 should return execution plan
assertThat(client.ftExplain(INDEX, query), not(emptyString()));


q = "@title:(@num:[0 10])";
query = new Query(q).dialect(1);
assertTrue("Should contain 'NUMERIC {0.000000 <= @num <= 10.000000}'",
client.ftExplain(INDEX, query).contains("NUMERIC {0.000000 <= @num <= 10.000000}"));
query = new Query(q).dialect(1); //dialect=1 should return execution plan
ggivo marked this conversation as resolved.
Show resolved Hide resolved
assertThat(client.ftExplain(INDEX, query), not(emptyString()));
query = new Query(q); // dialect=default=2
try {
client.ftExplain(INDEX, query);
fail();
} catch (JedisDataException e) {
assertTrue("Should contain 'Syntax error'", e.getMessage().contains("Syntax error"));
}
assertSyntaxError(query, client); // dialect=2 throws syntax error

q = "@t1:@t2:@t3:hello";
query = new Query(q).dialect(1);
assertTrue("Should contain '@NULL:UNION {\n @NULL:hello\n @NULL:+hello(expanded)\n}\n'",
client.ftExplain(INDEX, query).contains("@NULL:UNION {\n @NULL:hello\n @NULL:+hello(expanded)\n}\n"));
query = new Query(q).dialect(1);//dialect=1 should return execution plan
ggivo marked this conversation as resolved.
Show resolved Hide resolved
assertThat(client.ftExplain(INDEX, query), not(emptyString()));
query = new Query(q); // dialect=default=2
try {
client.ftExplain(INDEX, query);
fail();
} catch (JedisDataException e) {
assertTrue("Should contain 'Syntax error'", e.getMessage().contains("Syntax error"));
}
assertSyntaxError(query, client); // dialect=2 throws syntax error


q = "@title:{foo}}}}}";
query = new Query(q).dialect(1);
assertTrue("Should contain 'TAG:@title {\n foo\n}\n'",
client.ftExplain(INDEX, query).contains("TAG:@title {\n foo\n}\n"));
query = new Query(q).dialect(1);//dialect=1 should return execution plan
ggivo marked this conversation as resolved.
Show resolved Hide resolved
assertThat(client.ftExplain(INDEX, query), not(emptyString()));
query = new Query(q); // dialect=default=2
try {
client.ftExplain(INDEX, query);
fail();
} catch (JedisDataException e) {
assertTrue("Should contain 'Syntax error'", e.getMessage().contains("Syntax error"));
}
assertSyntaxError(query, client); // dialect=2 throws syntax error
}

@Test
@@ -194,9 +175,15 @@ public void testAggregationBuilderParamsDialect() {
@Test
public void dialectBoundSpellCheck() {
client.ftCreate(INDEX, TextField.of("t"));
JedisDataException error = Assert.assertThrows(JedisDataException.class,
JedisDataException error = assertThrows(JedisDataException.class,
() -> client.ftSpellCheck(INDEX, "Tooni toque kerfuffle",
FTSpellCheckParams.spellCheckParams().dialect(0)));
MatcherAssert.assertThat(error.getMessage(), Matchers.containsString("DIALECT requires a non negative integer"));
ggivo marked this conversation as resolved.
Show resolved Hide resolved
}

void assertSyntaxError(Query query, UnifiedJedis client) {
JedisDataException error = assertThrows(JedisDataException.class,
() -> client.ftExplain(INDEX, query));
assertThat(error.getMessage(), containsString("Syntax error"));
}
}