Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace hadoop minicluster tests with testcontainers (#3082)
* Fix CI continue on test failure * Increase timeout in postgis test to reduce CI failures
- Loading branch information
1 parent
46efa9c
commit 4ae4192
Showing
14 changed files
with
142 additions
and
104 deletions.
There are no files selected for viewing
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
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
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
59 changes: 59 additions & 0 deletions
59
...geomesa-fs-datastore/src/test/scala/org/locationtech/geomesa/fs/HadoopSharedCluster.scala
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,59 @@ | ||
/*********************************************************************** | ||
* Copyright (c) 2013-2024 Commonwealth Computer Research, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Apache License, Version 2.0 | ||
* which accompanies this distribution and is available at | ||
* http://www.opensource.org/licenses/apache2.0.php. | ||
***********************************************************************/ | ||
|
||
package org.locationtech.geomesa.fs | ||
|
||
import com.typesafe.scalalogging.StrictLogging | ||
import org.apache.hadoop.conf.Configuration | ||
import org.geomesa.testcontainers.HadoopContainer | ||
import org.testcontainers.utility.DockerImageName | ||
|
||
import java.io.{ByteArrayInputStream, StringWriter} | ||
import java.nio.charset.StandardCharsets | ||
import java.util.concurrent.atomic.AtomicBoolean | ||
import scala.util.Try | ||
|
||
/** | ||
* Hadoop cluster for testing. Singleton object that is shared between all test classes in the jvm. | ||
*/ | ||
object HadoopSharedCluster extends StrictLogging { | ||
|
||
val ImageName = | ||
DockerImageName.parse("ghcr.io/geomesa/accumulo-uno") | ||
.withTag(sys.props.getOrElse("accumulo.docker.tag", "2.1.2")) | ||
|
||
lazy val Container: HadoopContainer = tryContainer.get | ||
|
||
lazy val ContainerConfig: String = { | ||
val conf = new Configuration(false) | ||
conf.addResource(new ByteArrayInputStream(Container.getConfigurationXml.getBytes(StandardCharsets.UTF_8)), "") | ||
conf.set("parquet.compression", "GZIP", "") // default is snappy which is not on our classpath | ||
val writer = new StringWriter() | ||
conf.writeXml(writer) | ||
writer.toString | ||
} | ||
|
||
private lazy val tryContainer: Try[HadoopContainer] = Try { | ||
logger.info("Starting Hadoop container") | ||
val container = new HadoopContainer(ImageName) | ||
initialized.getAndSet(true) | ||
container.start() | ||
logger.info("Started Hadoop container") | ||
container | ||
} | ||
|
||
private val initialized = new AtomicBoolean(false) | ||
|
||
sys.addShutdownHook({ | ||
if (initialized.get) { | ||
logger.info("Stopping Hadoop container") | ||
tryContainer.foreach(_.stop()) | ||
logger.info("Stopped Hadoop container") | ||
} | ||
}) | ||
} |
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
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
Oops, something went wrong.