emptyMap(),
new NStringEntity(new ObjectMapper().writeValueAsString(data), ContentType.APPLICATION_JSON));
- if(response.getStatusLine().getStatusCode() == 200) {
- return Status.OK;
- }
+ return Status.OK;
} catch (Exception e) {
e.printStackTrace();
+ return Status.ERROR;
}
- return Status.ERROR;
}
@Override
@@ -136,13 +134,11 @@ public class ElasticsearchRestClient extends DB {
HttpDelete.METHOD_NAME,
"/" + indexKey + "/" + table + "/" + key);
- if(response.getStatusLine().getStatusCode() == 200) {
- return Status.OK;
- }
+ return Status.OK;
} catch (Exception e) {
e.printStackTrace();
+ return Status.ERROR;
}
- return Status.ERROR;
}
@Override
@@ -150,13 +146,11 @@ public class ElasticsearchRestClient extends DB {
try {
Response response = restClient.performRequest(HttpGet.METHOD_NAME, "/");
- if(response.getStatusLine().getStatusCode() == 200) {
- return Status.OK;
- }
+ return Status.OK;
} catch (Exception e) {
e.printStackTrace();
+ return Status.ERROR;
}
- return Status.ERROR;
// try {
// final GetResponse response = client.prepareGet(indexKey, table, key).execute().actionGet();
diff --git a/elasticsearch5/src/test/ant/integration-tests.xml b/elasticsearch5/src/test/ant/integration-tests.xml
new file mode 100644
index 00000000..59675cce
--- /dev/null
+++ b/elasticsearch5/src/test/ant/integration-tests.xml
@@ -0,0 +1,282 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Waiting for elasticsearch to become available on port @{port}...
+
+
+
+
+
+
+
+
+
+ 0);
+ s = true;
+ break;
+ }
+ }
+
+ if(!s){
+ d = a.length - b.length;
+ project.setProperty("compare-result", d >= 0);
+ }
+
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Starting up external cluster...
+
+
+ running Elasticsearch 5.0.0 or superior
+ running Elasticsearch < 5.0.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ External node started PID ${integ.pid}
+
+
+
+
+
+
+
+
+
+ Shutting down external node PID ${integ.pid}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Installing plugin @{name}...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/elasticsearch5/src/test/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchRestClientTestIT.java b/elasticsearch5/src/test/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchRestClientTestIT.java
new file mode 100644
index 00000000..fac85fd7
--- /dev/null
+++ b/elasticsearch5/src/test/java/com/yahoo/ycsb/db/elasticsearch5/ElasticsearchRestClientTestIT.java
@@ -0,0 +1,124 @@
+/**
+ * Copyright (c) 2017 YCSB contributors. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you
+ * may not use this file except in compliance with the License. You
+ * may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License. See accompanying
+ * LICENSE file.
+ */
+
+package com.yahoo.ycsb.db.elasticsearch5;
+
+import com.yahoo.ycsb.ByteIterator;
+import com.yahoo.ycsb.DBException;
+import com.yahoo.ycsb.Status;
+import com.yahoo.ycsb.StringByteIterator;
+import org.junit.*;
+
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Vector;
+
+import static org.junit.Assert.assertEquals;
+
+public class ElasticsearchRestClientTestIT {
+ private final static String TEST_HOST = "localhost:9400";
+ private final static ElasticsearchRestClient instance = new ElasticsearchRestClient();
+ private final static HashMap MOCK_DATA;
+ private final static String MOCK_TABLE = "MOCK_TABLE";
+ private final static String MOCK_KEY0 = "0";
+ private final static String MOCK_KEY1 = "1";
+ private final static String MOCK_KEY2 = "2";
+
+ static {
+ MOCK_DATA = new HashMap<>(10);
+ for (int i = 1; i <= 10; i++) {
+ MOCK_DATA.put("field" + i, new StringByteIterator("value" + i));
+ }
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws DBException {
+ final Properties props = new Properties();
+ props.setProperty("es.hosts.list", TEST_HOST);
+ instance.setProperties(props);
+ instance.init();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws DBException {
+ instance.cleanup();
+ }
+
+ @Before
+ public void setUp() {
+ instance.insert(MOCK_TABLE, MOCK_KEY1, MOCK_DATA);
+ instance.insert(MOCK_TABLE, MOCK_KEY2, MOCK_DATA);
+ }
+
+ @After
+ public void tearDown() {
+ instance.delete(MOCK_TABLE, MOCK_KEY1);
+ instance.delete(MOCK_TABLE, MOCK_KEY2);
+ }
+
+ @Test
+ public void testInsert() {
+ Status result = instance.insert(MOCK_TABLE, MOCK_KEY0, MOCK_DATA);
+ assertEquals(Status.OK, result);
+ }
+
+ @Test
+ public void testDelete() {
+ Status result = instance.delete(MOCK_TABLE, MOCK_KEY1);
+ assertEquals(Status.OK, result);
+ }
+
+ @Test
+ public void testRead() {
+ Set fields = MOCK_DATA.keySet();
+ HashMap resultParam = new HashMap<>(10);
+ Status result = instance.read(MOCK_TABLE, MOCK_KEY1, fields, resultParam);
+ assertEquals(Status.OK, result);
+ }
+
+ @Test
+ public void testUpdate() {
+ int i;
+ HashMap newValues = new HashMap<>(10);
+
+ for (i = 1; i <= 10; i++) {
+ newValues.put("field" + i, new StringByteIterator("newvalue" + i));
+ }
+
+ Status result = instance.update(MOCK_TABLE, MOCK_KEY1, newValues);
+ assertEquals(Status.OK, result);
+
+ //validate that the values changed
+ HashMap resultParam = new HashMap<>(10);
+ instance.read(MOCK_TABLE, MOCK_KEY1, MOCK_DATA.keySet(), resultParam);
+
+ for (i = 1; i <= 10; i++) {
+ assertEquals("newvalue" + i, resultParam.get("field" + i).toString());
+ }
+
+ }
+
+ @Test
+ public void testScan() {
+ int recordcount = 10;
+ Set fields = MOCK_DATA.keySet();
+ Vector> resultParam = new Vector<>(10);
+ Status result = instance.scan(MOCK_TABLE, MOCK_KEY1, recordcount, fields, resultParam);
+ assertEquals(Status.NOT_IMPLEMENTED, result);
+ }
+}