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

Try again to solve remaining TeamCity errors #4206

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,6 @@ ext {
neo4jVersion = "5.24.1"
// instead we apply the override logic here
neo4jVersionEffective = project.hasProperty("neo4jVersionOverride") ? project.getProperty("neo4jVersionOverride") : neo4jVersion
testContainersVersion = '1.18.3'
testContainersVersion = '1.19.1'
apacheArrowVersion = '15.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.testcontainers.couchbase.BucketDefinition;
import org.testcontainers.couchbase.CouchbaseContainer;

import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -64,6 +65,7 @@ public class CouchbaseTestUtils {

public static boolean fillDB(Cluster cluster) {
Bucket couchbaseBucket = cluster.bucket(BUCKET_NAME);
couchbaseBucket.waitUntilReady(Duration.ofMinutes(1));
Collection collection = couchbaseBucket.defaultCollection();
collection.insert("artist:vincent_van_gogh", VINCENT_VAN_GOGH);
QueryResult queryResult = cluster.query(String.format(QUERY, BUCKET_NAME),
Expand Down
31 changes: 18 additions & 13 deletions extended-it/src/test/java/apoc/load/PostgresJdbcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@

import java.sql.SQLException;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import static apoc.util.TestUtil.testCall;
import static apoc.util.TestUtil.testResult;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.neo4j.test.assertion.Assert.assertEventually;

public class PostgresJdbcTest extends AbstractJdbcTest {

Expand Down Expand Up @@ -132,19 +134,22 @@ public void testIssue4141PeriodicIterateWithJdbc() throws Exception {
assertPgStatActivityHasOnlyActiveState();
}

private static void assertPgStatActivityHasOnlyActiveState() throws Exception {
// connect to postgres and execute the query `select state from pg_stat_activity`
String psql = postgress.execInContainer(
"psql", "postgresql://test:test@localhost/test", "-c", "select state from pg_stat_activity;")
.toString();

assertTrue("Current pg_stat_activity is: " + psql, psql.contains("active"));

// the result without the https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/4141 change
// is not deterministic, can be `too many clients already` or (not very often) `idle`
assertFalse("Current pg_stat_activity is: " + psql,
psql.contains("too many clients already") || psql.contains("idle"));

private static void assertPgStatActivityHasOnlyActiveState() {
assertEventually(() -> {
// connect to postgres and execute the query `select state from pg_stat_activity`
String psql = postgress.execInContainer(
"psql", "postgresql://test:test@localhost/test", "-c", "select state from pg_stat_activity;")
.toString();

assertTrue("Current pg_stat_activity is: " + psql, psql.contains("active"));

// the result without the https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/4141 change
// is not deterministic, can be `too many clients already` or (not very often) `idle`
assertFalse("Current pg_stat_activity is: " + psql,
psql.contains("too many clients already") || psql.contains("idle"));

return true;
}, v -> v, 20L, TimeUnit.SECONDS);
}

private void assertPeriodicIterate(Result result) {
Expand Down
5 changes: 4 additions & 1 deletion extended/src/test/java/apoc/export/csv/ExportCsvTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public class ExportCsvTest {
@ClassRule
public static TemporaryFolder storeDir = new TemporaryFolder();

@ClassRule
public static TemporaryFolder hdfsDir = new TemporaryFolder();

private static GraphDatabaseService db;
private static DatabaseManagementService dbms;

Expand All @@ -64,7 +67,7 @@ public static void setUp() throws Exception {
apocConfig().setProperty(APOC_EXPORT_FILE_ENABLED, true);
db.executeTransactionally("CREATE (f:User1:User {name:'foo',age:42,male:true,kids:['a','b','c']})-[:KNOWS]->(b:User {name:'bar',age:42}),(c:User {age:12})");
db.executeTransactionally("CREATE (f:Address1:Address {name:'Andrea', city: 'Milano', street:'Via Garibaldi, 7'})-[:NEXT_DELIVERY]->(a:Address {name: 'Bar Sport'}), (b:Address {street: 'via Benni'})");
miniDFSCluster = HdfsTestUtils.getLocalHDFSCluster();
miniDFSCluster = HdfsTestUtils.getLocalHDFSCluster(hdfsDir.getRoot());
}

@AfterClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.neo4j.configuration.GraphDatabaseSettings;
import org.neo4j.test.rule.DbmsRule;
import org.neo4j.test.rule.ImpermanentDbmsRule;
Expand All @@ -28,6 +29,9 @@ public class ParquetHdfsTest {
directory.mkdirs();
}

@ClassRule
public static TemporaryFolder hdfsDir = new TemporaryFolder();

@ClassRule
public static DbmsRule db = new ImpermanentDbmsRule()
.withSetting(GraphDatabaseSettings.load_csv_file_url_root, directory.toPath().toAbsolutePath());
Expand All @@ -37,7 +41,7 @@ public class ParquetHdfsTest {
@BeforeClass
public static void setUp() throws Exception {
beforeClassCommon(db);
miniDFSCluster = HdfsTestUtils.getLocalHDFSCluster();
miniDFSCluster = HdfsTestUtils.getLocalHDFSCluster(hdfsDir.getRoot());
}

@Before
Expand Down
7 changes: 6 additions & 1 deletion extended/src/test/java/apoc/load/LoadHdfsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;

import org.junit.rules.TemporaryFolder;
import org.neo4j.test.rule.DbmsRule;
import org.neo4j.test.rule.ImpermanentDbmsRule;

Expand All @@ -28,6 +30,9 @@

public class LoadHdfsTest {

@ClassRule
public static TemporaryFolder hdfsDir = new TemporaryFolder();

@Rule
public DbmsRule db = new ImpermanentDbmsRule();

Expand All @@ -36,7 +41,7 @@ public class LoadHdfsTest {
@Before public void setUp() throws Exception {
TestUtil.registerProcedure(db, LoadCsv.class);
apocConfig().setProperty(APOC_IMPORT_FILE_ENABLED, true);
miniDFSCluster = HdfsTestUtils.getLocalHDFSCluster();
miniDFSCluster = HdfsTestUtils.getLocalHDFSCluster(hdfsDir.getRoot());
FileSystem fs = miniDFSCluster.getFileSystem();
String fileName = "test.csv";
Path file = new Path(fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testLoadLDAPWithDefaultPort() {
}

private static void testLoadLDAPCommon(int port, boolean ssl) {
Map<String, Object> conn = Map.of("ldapHost", "localhost:" + port,
Map<String, Object> conn = Map.of("ldapHost", ldap.getHost() + ":" + port,
"loginDN", "cn=admin,dc=example,dc=org",
"loginPW", "admin",
"ssl", ssl);
Expand Down
3 changes: 1 addition & 2 deletions extended/src/test/java/apoc/util/HdfsTestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ private static int getFreePort() throws IOException {
}
}

public static MiniDFSCluster getLocalHDFSCluster() throws Exception {
public static MiniDFSCluster getLocalHDFSCluster(File hdfsPath) throws Exception {
setHadoopHomeWindows();
Configuration conf = new HdfsConfiguration();
conf.set("fs.defaultFS", "hdfs://localhost");
File hdfsPath = new File(System.getProperty("user.dir") + File.separator + "hadoop" + File.separator + "hdfs");
hdfsPath.setWritable(true);
conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, hdfsPath.getAbsolutePath());
MiniDFSCluster miniDFSCluster = new MiniDFSCluster.Builder(conf)
Expand Down
Loading