diff options
author | Lee Hinman <lee@writequit.org> | 2016-09-07 11:00:09 -0600 |
---|---|---|
committer | Lee Hinman <lee@writequit.org> | 2016-09-08 15:29:47 -0600 |
commit | 49695af2ac8dd52d461b10a12b9c826e3f6691e7 (patch) | |
tree | 25c800fc993894702d034da08812e523db0e6bdd /core/src/test/java/org/elasticsearch | |
parent | 3713d7994de030dda5ef6aadd87bb44bb8308ee8 (diff) |
Remove FORCE version_type
This was an error-prone version type that allowed overriding previous
version semantics. It could cause primaries and replicas to be out of
sync however, so it has been removed.
Resolves #19769
Diffstat (limited to 'core/src/test/java/org/elasticsearch')
4 files changed, 3 insertions, 82 deletions
diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java index 03cf86397c..3b88efca20 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java @@ -235,14 +235,11 @@ public class BulkWithUpdatesIT extends ESIntegTestCase { .add(client().prepareUpdate("test", "type", "e1") .setDoc("field", "2").setVersion(10)) // INTERNAL .add(client().prepareUpdate("test", "type", "e1") - .setDoc("field", "3").setVersion(20).setVersionType(VersionType.FORCE)) - .add(client().prepareUpdate("test", "type", "e1") - .setDoc("field", "4").setVersion(20).setVersionType(VersionType.INTERNAL)) + .setDoc("field", "3").setVersion(13).setVersionType(VersionType.INTERNAL)) .get(); assertThat(bulkResponse.getItems()[0].getFailureMessage(), containsString("version conflict")); - assertThat(bulkResponse.getItems()[1].getResponse().getVersion(), equalTo(20L)); - assertThat(bulkResponse.getItems()[2].getResponse().getVersion(), equalTo(21L)); + assertThat(bulkResponse.getItems()[1].getFailureMessage(), containsString("version conflict")); } public void testBulkUpdateMalformedScripts() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/index/VersionTypeTests.java b/core/src/test/java/org/elasticsearch/index/VersionTypeTests.java index 4c79ce1b49..2afe0b7fea 100644 --- a/core/src/test/java/org/elasticsearch/index/VersionTypeTests.java +++ b/core/src/test/java/org/elasticsearch/index/VersionTypeTests.java @@ -77,13 +77,6 @@ public class VersionTypeTests extends ESTestCase { assertTrue(VersionType.EXTERNAL_GTE.validateVersionForReads(randomIntBetween(1, Integer.MAX_VALUE))); assertFalse(VersionType.EXTERNAL_GTE.validateVersionForReads(randomIntBetween(Integer.MIN_VALUE, -1))); - assertTrue(VersionType.FORCE.validateVersionForWrites(randomIntBetween(1, Integer.MAX_VALUE))); - assertFalse(VersionType.FORCE.validateVersionForWrites(Versions.MATCH_ANY)); - assertFalse(VersionType.FORCE.validateVersionForWrites(randomIntBetween(Integer.MIN_VALUE, 0))); - assertTrue(VersionType.FORCE.validateVersionForReads(Versions.MATCH_ANY)); - assertTrue(VersionType.FORCE.validateVersionForReads(randomIntBetween(1, Integer.MAX_VALUE))); - assertFalse(VersionType.FORCE.validateVersionForReads(randomIntBetween(Integer.MIN_VALUE, -1))); - assertTrue(VersionType.INTERNAL.validateVersionForWrites(randomIntBetween(1, Integer.MAX_VALUE))); assertTrue(VersionType.INTERNAL.validateVersionForWrites(Versions.MATCH_ANY)); assertFalse(VersionType.INTERNAL.validateVersionForWrites(randomIntBetween(Integer.MIN_VALUE, 0))); @@ -153,36 +146,6 @@ public class VersionTypeTests extends ESTestCase { } - public void testForceVersionConflict() throws Exception { - assertFalse(VersionType.FORCE.isVersionConflictForWrites(Versions.NOT_FOUND, 10, randomBoolean())); - - // MATCH_ANY must throw an exception in the case of force version, as the version must be set! it used as the new value - try { - VersionType.FORCE.isVersionConflictForWrites(10, Versions.MATCH_ANY, randomBoolean()); - fail(); - } catch (IllegalStateException e) { - //yes!! - } - - // if we didn't find a version (but the index does support it), we always accept - assertFalse(VersionType.FORCE.isVersionConflictForWrites(Versions.NOT_FOUND, Versions.NOT_FOUND, randomBoolean())); - assertFalse(VersionType.FORCE.isVersionConflictForWrites(Versions.NOT_FOUND, 10, randomBoolean())); - - assertFalse(VersionType.FORCE.isVersionConflictForReads(Versions.NOT_FOUND, Versions.NOT_FOUND)); - assertFalse(VersionType.FORCE.isVersionConflictForReads(Versions.NOT_FOUND, 10)); - assertFalse(VersionType.FORCE.isVersionConflictForReads(Versions.NOT_FOUND, Versions.MATCH_ANY)); - - - // and the standard behavior - assertFalse(VersionType.FORCE.isVersionConflictForWrites(10, 10, randomBoolean())); - assertFalse(VersionType.FORCE.isVersionConflictForWrites(9, 10, randomBoolean())); - assertFalse(VersionType.FORCE.isVersionConflictForWrites(10, 9, randomBoolean())); - assertFalse(VersionType.FORCE.isVersionConflictForReads(10, 10)); - assertFalse(VersionType.FORCE.isVersionConflictForReads(9, 10)); - assertFalse(VersionType.FORCE.isVersionConflictForReads(10, 9)); - assertFalse(VersionType.FORCE.isVersionConflictForReads(10, Versions.MATCH_ANY)); - } - public void testUpdateVersion() { assertThat(VersionType.INTERNAL.updateVersion(Versions.NOT_FOUND, 10), equalTo(1L)); assertThat(VersionType.INTERNAL.updateVersion(1, 1), equalTo(2L)); @@ -196,9 +159,6 @@ public class VersionTypeTests extends ESTestCase { assertThat(VersionType.EXTERNAL_GTE.updateVersion(1, 10), equalTo(10L)); assertThat(VersionType.EXTERNAL_GTE.updateVersion(10, 10), equalTo(10L)); - assertThat(VersionType.FORCE.updateVersion(Versions.NOT_FOUND, 10), equalTo(10L)); - assertThat(VersionType.FORCE.updateVersion(11, 10), equalTo(10L)); - // Old indexing code // if (index.versionType() == VersionType.INTERNAL) { // internal version type // updatedVersion = (currentVersion == Versions.NOT_SET || currentVersion == Versions.NOT_FOUND) ? 1 : currentVersion + 1; diff --git a/core/src/test/java/org/elasticsearch/update/UpdateIT.java b/core/src/test/java/org/elasticsearch/update/UpdateIT.java index a71bd466ad..7ea68dc10f 100644 --- a/core/src/test/java/org/elasticsearch/update/UpdateIT.java +++ b/core/src/test/java/org/elasticsearch/update/UpdateIT.java @@ -527,15 +527,9 @@ public class UpdateIT extends ESIntegTestCase { .setVersionType(VersionType.EXTERNAL).execute(), ActionRequestValidationException.class); - - // With force version - client().prepareUpdate(indexOrAlias(), "type", "2") - .setScript(new Script("", ScriptService.ScriptType.INLINE, "put_values", Collections.singletonMap("text", "v10"))) - .setVersion(10).setVersionType(VersionType.FORCE).get(); - GetResponse get = get("test", "type", "2"); assertThat(get.getVersion(), equalTo(10L)); - assertThat((String) get.getSource().get("text"), equalTo("v10")); + assertThat((String) get.getSource().get("text"), equalTo("value")); // upserts - the combination with versions is a bit weird. Test are here to ensure we do not change our behavior unintentionally diff --git a/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java b/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java index 67e7d528e5..b80c5bd8e2 100644 --- a/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java +++ b/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java @@ -72,36 +72,6 @@ public class SimpleVersioningIT extends ESIntegTestCase { assertThat(indexResponse.getVersion(), equalTo(18L)); } - public void testForce() throws Exception { - createIndex("test"); - ensureGreen("test"); // we are testing force here which doesn't work if we are recovering at the same time - zzzzz... - IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(12).setVersionType(VersionType.FORCE).get(); - assertThat(indexResponse.getVersion(), equalTo(12L)); - - indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").setVersion(12).setVersionType(VersionType.FORCE).get(); - assertThat(indexResponse.getVersion(), equalTo(12L)); - - indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").setVersion(14).setVersionType(VersionType.FORCE).get(); - assertThat(indexResponse.getVersion(), equalTo(14L)); - - indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(13).setVersionType(VersionType.FORCE).get(); - assertThat(indexResponse.getVersion(), equalTo(13L)); - - client().admin().indices().prepareRefresh().execute().actionGet(); - if (randomBoolean()) { - refresh(); - } - for (int i = 0; i < 10; i++) { - assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(13L)); - } - - // deleting with a lower version works. - long v = randomIntBetween(12, 14); - DeleteResponse deleteResponse = client().prepareDelete("test", "type", "1").setVersion(v).setVersionType(VersionType.FORCE).get(); - assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult()); - assertThat(deleteResponse.getVersion(), equalTo(v)); - } - public void testExternalGTE() throws Exception { createIndex("test"); |