Skip to content

Commit

Permalink
storage: Embedded solr should be optional in tests. #TASK-6515
Browse files Browse the repository at this point in the history
  • Loading branch information
j-coll committed Aug 13, 2024
1 parent d321044 commit 8c1cde1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.opencb.opencga.storage.core.variant;

import org.junit.Assume;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test;
import org.opencb.biodata.formats.variant.io.VariantReader;
Expand All @@ -25,7 +25,6 @@
import org.opencb.opencga.storage.core.variant.query.VariantQueryResult;
import org.opencb.opencga.storage.core.variant.query.executors.VariantQueryExecutor;
import org.opencb.opencga.storage.core.variant.search.SearchIndexVariantQueryExecutor;
import org.opencb.opencga.storage.core.variant.solr.VariantSolrExternalResource;

import java.net.URI;
import java.nio.file.Paths;
Expand Down Expand Up @@ -55,9 +54,6 @@ public abstract class VariantStorageEngineSVTest extends VariantStorageBaseTest
protected static URI input2;
protected static URI input3;

@ClassRule
public static VariantSolrExternalResource solr = new VariantSolrExternalResource();

@Before
public void before() throws Exception {
if (!loaded) {
Expand All @@ -68,7 +64,7 @@ public void before() throws Exception {
variantStorageEngine.getConfiguration().getCellbase().setDataRelease(ParamConstants.CELLBASE_DATA_RELEASE_GRCH38);
variantStorageEngine.getOptions().put(VariantStorageOptions.ASSEMBLY.key(), "grch38");
variantStorageEngine.reloadCellbaseConfiguration();
solr.configure(variantStorageEngine);

if (!loaded) {
loadFiles();
loaded = true;
Expand Down Expand Up @@ -97,7 +93,6 @@ protected void loadFiles() throws Exception {
.append(VariantStorageOptions.STATS_CALCULATE.key(), true)
.append(VariantStorageOptions.ASSEMBLY.key(), "grch38"));

variantStorageEngine.secondaryIndex();
}

@Test
Expand All @@ -120,6 +115,7 @@ public void checkCount() throws Exception {

@Test
public void checkSecondaryAnnotationIndex() throws Exception {
Assume.assumeTrue(variantStorageEngine.secondaryAnnotationIndexActiveAndAlive());
VariantQueryExecutor variantQueryExecutor = variantStorageEngine.getVariantQueryExecutor(SearchIndexVariantQueryExecutor.class);
for (Variant variant : variantStorageEngine) {
ParsedVariantQuery query = variantStorageEngine
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.opencb.opencga.storage.hadoop.variant;

import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.*;
import org.junit.experimental.categories.Category;
import org.opencb.biodata.models.variant.StudyEntry;
import org.opencb.biodata.models.variant.Variant;
Expand All @@ -12,13 +10,15 @@
import org.opencb.opencga.storage.core.variant.adaptors.GenotypeClass;
import org.opencb.opencga.storage.core.variant.adaptors.VariantQuery;
import org.opencb.opencga.storage.core.variant.query.VariantQueryResult;
import org.opencb.opencga.storage.core.variant.solr.VariantSolrExternalResource;
import org.opencb.opencga.storage.hadoop.HBaseCompat;
import org.opencb.opencga.storage.hadoop.variant.adaptors.VariantHadoopDBAdaptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
import static org.opencb.opencga.core.api.ParamConstants.OVERWRITE;

/**
Expand All @@ -33,9 +33,46 @@ public class HadoopVariantStorageEngineSVTest extends VariantStorageEngineSVTest
public static HadoopExternalResource externalResource = new HadoopExternalResource();
private Logger logger = LoggerFactory.getLogger(getClass());

public static VariantSolrExternalResource solr = new VariantSolrExternalResource();

@BeforeClass
public static void beforeClass() throws Exception {
if (HBaseCompat.getInstance().isSolrTestingAvailable()) {
solr.before();
solr.configure(externalResource.getVariantStorageEngine());
System.out.println("Start embedded solr");
} else {
System.out.println("Skip embedded solr tests");
}
}

@AfterClass
public static void afterClass() throws Exception {
if (HBaseCompat.getInstance().isSolrTestingAvailable()) {
solr.after();
}
}

@Override
public void before() throws Exception {
super.before();
if (HBaseCompat.getInstance().isSolrTestingAvailable()) {
solr.configure(variantStorageEngine);
}
}

@Override
protected void loadFiles() throws Exception {
if (HBaseCompat.getInstance().isSolrTestingAvailable()) {
solr.configure(variantStorageEngine);
}
super.loadFiles();
if (HBaseCompat.getInstance().isSolrTestingAvailable()) {
variantStorageEngine.secondaryIndex();
assertTrue(variantStorageEngine.secondaryAnnotationIndexActiveAndAlive());
} else {
assertFalse(variantStorageEngine.secondaryAnnotationIndexActiveAndAlive());
}
VariantHbaseTestUtils.printVariants(getVariantStorageEngine().getDBAdaptor(), newOutputUri(getTestName().getMethodName()));
}

Expand Down

0 comments on commit 8c1cde1

Please sign in to comment.