mirror of https://github.com/apache/lucene.git
LTR Test Hardening:
1) use per-method state isolation in several tests... This helps prevent failures in one test to allow persisted date to leak into other test methods, as well as ensuring that these tests play nicely with -Dtests.iters > 1 2) TestRerankBase cleanup to eliminate unnecessary extra SolrCore (that was being leaked)
This commit is contained in:
parent
0ce635ec01
commit
3ed96026d3
|
@ -18,20 +18,20 @@ package org.apache.solr.ltr;
|
|||
|
||||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestLTRQParserExplain extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws Exception {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
setuptest(true);
|
||||
loadFeatures("features-store-test-model.json");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,14 +20,14 @@ package org.apache.solr.ltr;
|
|||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.ltr.feature.SolrFeature;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestLTRWithFacet extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "a1", "description", "E", "popularity",
|
||||
|
@ -48,6 +48,12 @@ public class TestLTRWithFacet extends TestRerankBase {
|
|||
"D", "popularity", "8"));
|
||||
assertU(commit());
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRankingSolrFacet() throws Exception {
|
||||
|
@ -91,13 +97,6 @@ public class TestLTRWithFacet extends TestRerankBase {
|
|||
assertJQ("/query" + query.toQueryString(), ""
|
||||
+ "/facet_counts/facet_fields/description=="
|
||||
+ "['b', 4, 'e', 2, 'c', 1, 'd', 1]");
|
||||
// aftertest();
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@ package org.apache.solr.ltr;
|
|||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.ltr.feature.SolrFeature;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestLTRWithSort extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
assertU(adoc("id", "1", "title", "a1", "description", "E", "popularity",
|
||||
"1"));
|
||||
|
@ -47,6 +47,11 @@ public class TestLTRWithSort extends TestRerankBase {
|
|||
"D", "popularity", "8"));
|
||||
assertU(commit());
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRankingSolrSort() throws Exception {
|
||||
|
@ -90,13 +95,6 @@ public class TestLTRWithSort extends TestRerankBase {
|
|||
assertJQ("/query" + query.toQueryString(), "/response/docs/[3]/id=='1'");
|
||||
assertJQ("/query" + query.toQueryString(), "/response/docs/[3]/score==1.0");
|
||||
|
||||
// aftertest();
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.solr.common.params.CommonParams;
|
|||
import org.apache.solr.common.util.ContentStream;
|
||||
import org.apache.solr.common.util.ContentStreamBase;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.core.SolrResourceLoader;
|
||||
import org.apache.solr.ltr.feature.Feature;
|
||||
import org.apache.solr.ltr.feature.FeatureException;
|
||||
|
@ -129,11 +130,15 @@ public class TestRerankBase extends RestTestBase {
|
|||
}
|
||||
|
||||
public static ManagedFeatureStore getManagedFeatureStore() {
|
||||
return ManagedFeatureStore.getManagedFeatureStore(h.getCore());
|
||||
try (SolrCore core = jetty.getCoreContainer().getCore(DEFAULT_TEST_CORENAME)) {
|
||||
return ManagedFeatureStore.getManagedFeatureStore(core);
|
||||
}
|
||||
}
|
||||
|
||||
public static ManagedModelStore getManagedModelStore() {
|
||||
return ManagedModelStore.getManagedModelStore(h.getCore());
|
||||
try (SolrCore core = jetty.getCoreContainer().getCore(DEFAULT_TEST_CORENAME)) {
|
||||
return ManagedModelStore.getManagedModelStore(core);
|
||||
}
|
||||
}
|
||||
|
||||
protected static SortedMap<ServletHolder,String> setupTestInit(
|
||||
|
@ -192,7 +197,6 @@ public class TestRerankBase extends RestTestBase {
|
|||
|
||||
public static void setuptest(String solrconfig, String schema)
|
||||
throws Exception {
|
||||
initCore(solrconfig, schema);
|
||||
|
||||
SortedMap<ServletHolder,String> extraServlets =
|
||||
setupTestInit(solrconfig,schema,false);
|
||||
|
@ -204,7 +208,6 @@ public class TestRerankBase extends RestTestBase {
|
|||
|
||||
public static void setupPersistentTest(String solrconfig, String schema)
|
||||
throws Exception {
|
||||
initCore(solrconfig, schema);
|
||||
|
||||
SortedMap<ServletHolder,String> extraServlets =
|
||||
setupTestInit(solrconfig,schema,true);
|
||||
|
|
|
@ -19,14 +19,14 @@ package org.apache.solr.ltr.feature;
|
|||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestEdisMaxSolrFeature extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "w1", "description", "w1", "popularity",
|
||||
|
@ -48,8 +48,8 @@ public class TestEdisMaxSolrFeature extends TestRerankBase {
|
|||
assertU(commit());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,19 +21,19 @@ import org.apache.solr.ltr.FeatureLoggerTestUtils;
|
|||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.apache.solr.ltr.store.FeatureStore;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestFeatureLogging extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws Exception {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
setuptest(true);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,14 +21,14 @@ import java.util.LinkedHashMap;
|
|||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestFieldLengthFeature extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "w1", "description", "w1"));
|
||||
|
@ -45,8 +45,8 @@ public class TestFieldLengthFeature extends TestRerankBase {
|
|||
assertU(commit());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,16 +22,16 @@ import org.apache.solr.client.solrj.SolrQuery;
|
|||
import org.apache.solr.ltr.FeatureLoggerTestUtils;
|
||||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestFieldValueFeature extends TestRerankBase {
|
||||
|
||||
private static final float FIELD_VALUE_FEATURE_DEFAULT_VAL = 0.0f;
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "w1", "description", "w1", "popularity",
|
||||
|
@ -63,8 +63,8 @@ public class TestFieldValueFeature extends TestRerankBase {
|
|||
new String[] {"popularity"}, "{\"weights\":{\"popularity\":1.0}}");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@ import org.apache.solr.ltr.FeatureLoggerTestUtils;
|
|||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.apache.solr.ltr.store.rest.ManagedFeatureStore;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestFilterSolrFeature extends TestRerankBase {
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "w1", "description", "w1", "popularity",
|
||||
|
@ -49,8 +49,8 @@ public class TestFilterSolrFeature extends TestRerankBase {
|
|||
assertU(commit());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,14 +25,14 @@ import org.apache.solr.ltr.FeatureLoggerTestUtils;
|
|||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.apache.solr.ltr.model.MultipleAdditiveTreesModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestNoMatchSolrFeature extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "w1", "description", "w1", "popularity",
|
||||
|
@ -78,8 +78,8 @@ public class TestNoMatchSolrFeature extends TestRerankBase {
|
|||
"{\"weights\":{\"nomatchfeature4\":1.0}}");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,14 +26,14 @@ import org.apache.solr.common.util.Utils;
|
|||
import org.apache.solr.ltr.FeatureLoggerTestUtils;
|
||||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestOriginalScoreFeature extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "w1"));
|
||||
|
@ -47,8 +47,8 @@ public class TestOriginalScoreFeature extends TestRerankBase {
|
|||
assertU(commit());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,15 +21,15 @@ import java.util.LinkedHashMap;
|
|||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class TestRankingFeature extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "w1", "description", "w1", "popularity",
|
||||
|
@ -51,8 +51,8 @@ public class TestRankingFeature extends TestRerankBase {
|
|||
assertU(commit());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,6 @@ public class TestRankingFeature extends TestRerankBase {
|
|||
"/error/msg/=='"+FeatureException.class.getName()+": " +
|
||||
"java.lang.UnsupportedOperationException: " +
|
||||
"Unable to extract feature for powdesS'");
|
||||
// aftertest();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,14 @@ package org.apache.solr.ltr.feature;
|
|||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestUserTermScoreWithQ extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "w1", "description", "w1", "popularity",
|
||||
|
@ -48,8 +48,8 @@ public class TestUserTermScoreWithQ extends TestRerankBase {
|
|||
assertU(commit());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,14 @@ package org.apache.solr.ltr.feature;
|
|||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestUserTermScorerQuery extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "w1", "description", "w1", "popularity",
|
||||
|
@ -48,8 +48,8 @@ public class TestUserTermScorerQuery extends TestRerankBase {
|
|||
assertU(commit());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,14 @@ package org.apache.solr.ltr.feature;
|
|||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestUserTermScorereQDF extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "w1", "description", "w1", "popularity",
|
||||
|
@ -48,8 +48,8 @@ public class TestUserTermScorereQDF extends TestRerankBase {
|
|||
assertU(commit());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,14 +21,14 @@ import java.util.LinkedHashMap;
|
|||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestValueFeature extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "w1"));
|
||||
|
@ -42,8 +42,8 @@ public class TestValueFeature extends TestRerankBase {
|
|||
assertU(commit());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@ import org.apache.solr.ltr.feature.Feature;
|
|||
import org.apache.solr.ltr.feature.FieldValueFeature;
|
||||
import org.apache.solr.ltr.norm.Normalizer;
|
||||
import org.apache.solr.ltr.store.rest.ManagedModelStore;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestAdapterModel extends TestRerankBase {
|
||||
|
@ -46,15 +47,15 @@ public class TestAdapterModel extends TestRerankBase {
|
|||
private static int numDocs = 0;
|
||||
private static float scoreValue;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupBeforeClass() throws Exception {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
|
||||
setuptest(false);
|
||||
|
||||
for (int ii=1; ii<=random().nextInt(10); ++ii) {
|
||||
numDocs = random().nextInt(10);
|
||||
for (int ii=1; ii <= numDocs; ++ii) {
|
||||
String id = Integer.toString(ii);
|
||||
assertU(adoc("id", id, "popularity", ii+"00"));
|
||||
++numDocs;
|
||||
}
|
||||
assertU(commit());
|
||||
|
||||
|
@ -76,6 +77,10 @@ public class TestAdapterModel extends TestRerankBase {
|
|||
"{\"answerFileName\":\"" + scoreValueFile.getName() + "\"}");
|
||||
assertJPut(ManagedModelStore.REST_END_POINT, modelJson, "/responseHeader/status==0");
|
||||
}
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
|
|
|
@ -31,19 +31,19 @@ import org.apache.solr.ltr.feature.Feature;
|
|||
import org.apache.solr.ltr.feature.FieldValueFeature;
|
||||
import org.apache.solr.ltr.feature.ValueFeature;
|
||||
import org.apache.solr.ltr.store.rest.ManagedModelStore;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestDefaultWrapperModel extends TestRerankBase {
|
||||
|
||||
final private static String featureStoreName = "test";
|
||||
private static String baseModelJson = null;
|
||||
private static File baseModelFile = null;
|
||||
|
||||
static List<Feature> features = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupBeforeClass() throws Exception {
|
||||
@Before
|
||||
public void setupBeforeClass() throws Exception {
|
||||
setuptest(false);
|
||||
assertU(adoc("id", "1", "title", "w1", "description", "w1", "popularity", "1"));
|
||||
assertU(adoc("id", "2", "title", "w2", "description", "w2", "popularity", "2"));
|
||||
|
@ -58,7 +58,7 @@ public class TestDefaultWrapperModel extends TestRerankBase {
|
|||
features.add(getManagedFeatureStore().getFeatureStore("test").get("popularity"));
|
||||
features.add(getManagedFeatureStore().getFeatureStore("test").get("const"));
|
||||
|
||||
baseModelJson = getModelInJson("linear", LinearModel.class.getName(),
|
||||
final String baseModelJson = getModelInJson("linear", LinearModel.class.getName(),
|
||||
new String[] {"popularity", "const"},
|
||||
featureStoreName,
|
||||
"{\"weights\":{\"popularity\":-1.0, \"const\":1.0}}");
|
||||
|
@ -70,6 +70,13 @@ public class TestDefaultWrapperModel extends TestRerankBase {
|
|||
}
|
||||
baseModelFile.deleteOnExit();
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
features = null;
|
||||
baseModelFile = null;
|
||||
aftertest();
|
||||
}
|
||||
|
||||
private static String getDefaultWrapperModelInJson(String wrapperModelName, String[] features, String params) {
|
||||
return getModelInJson(wrapperModelName, DefaultWrapperModel.class.getName(),
|
||||
|
|
|
@ -29,7 +29,8 @@ import org.apache.solr.ltr.norm.IdentityNormalizer;
|
|||
import org.apache.solr.ltr.norm.Normalizer;
|
||||
import org.apache.solr.ltr.store.FeatureStore;
|
||||
import org.apache.solr.ltr.store.rest.ManagedModelStore;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestLinearModel extends TestRerankBase {
|
||||
|
@ -58,15 +59,21 @@ public class TestLinearModel extends TestRerankBase {
|
|||
static ManagedModelStore store = null;
|
||||
static FeatureStore fstore = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws Exception {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
setuptest(true);
|
||||
// loadFeatures("features-store-test-model.json");
|
||||
store = getManagedModelStore();
|
||||
fstore = getManagedFeatureStore().getFeatureStore("test");
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
store = null;
|
||||
fstore = null;
|
||||
aftertest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getInstanceTest() {
|
||||
final Map<String,Object> weights = new HashMap<>();
|
||||
|
|
|
@ -18,17 +18,16 @@ package org.apache.solr.ltr.model;
|
|||
|
||||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.ltr.TestRerankBase;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.core.StringContains.containsString;
|
||||
|
||||
public class TestMultipleAdditiveTreesModel extends TestRerankBase {
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void before() throws Exception {
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
setuptest(false);
|
||||
|
||||
assertU(adoc("id", "1", "title", "w1", "description", "w1", "popularity","1"));
|
||||
|
@ -39,8 +38,8 @@ public class TestMultipleAdditiveTreesModel extends TestRerankBase {
|
|||
assertU(commit());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ import org.apache.solr.ltr.feature.Feature;
|
|||
import org.apache.solr.ltr.norm.IdentityNormalizer;
|
||||
import org.apache.solr.ltr.norm.Normalizer;
|
||||
import org.apache.solr.util.SolrPluginUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestNeuralNetworkModel extends TestRerankBase {
|
||||
|
@ -44,13 +44,13 @@ public class TestNeuralNetworkModel extends TestRerankBase {
|
|||
features, norms, featureStoreName, allFeatures, params);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws Exception {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
setuptest(false);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void after() throws Exception {
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,18 +25,25 @@ import org.apache.solr.ltr.feature.FeatureException;
|
|||
import org.apache.solr.ltr.feature.OriginalScoreFeature;
|
||||
import org.apache.solr.ltr.feature.ValueFeature;
|
||||
import org.apache.solr.ltr.store.FeatureStore;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestManagedFeatureStore extends SolrTestCaseJ4 {
|
||||
|
||||
private static ManagedFeatureStore fstore = null;
|
||||
private ManagedFeatureStore fstore = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws Exception {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
initCore("solrconfig-ltr.xml", "schema.xml");
|
||||
fstore = ManagedFeatureStore.getManagedFeatureStore(h.getCore());
|
||||
}
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
fstore = null;
|
||||
deleteCore();
|
||||
}
|
||||
|
||||
|
||||
private static Map<String,Object> createMap(String name, String className, Map<String,Object> params) {
|
||||
final Map<String,Object> map = new HashMap<String,Object>();
|
||||
|
|
|
@ -35,15 +35,20 @@ import org.apache.solr.ltr.model.DefaultWrapperModel;
|
|||
import org.apache.solr.ltr.model.LinearModel;
|
||||
import org.apache.solr.ltr.norm.Normalizer;
|
||||
import org.apache.solr.ltr.store.FeatureStore;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestModelManagerPersistence extends TestRerankBase {
|
||||
|
||||
@BeforeClass
|
||||
public static void init() throws Exception {
|
||||
@Before
|
||||
public void init() throws Exception {
|
||||
setupPersistenttest(true);
|
||||
}
|
||||
@After
|
||||
public void cleanup() throws Exception {
|
||||
aftertest();
|
||||
}
|
||||
|
||||
// executed first
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue