Browse Source

Tests: improve back compat tests by adding delete-by-query in the transaction log on upgrade

Closes #10266
Michael McCandless 10 years ago
parent
commit
442f539802
85 changed files with 54 additions and 5 deletions
  1. 35 1
      dev-tools/create-bwc-index.py
  2. 5 1
      dev-tools/get-bwc-version.py
  3. 14 3
      src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java
  4. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.0.Beta1.zip
  5. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.0.RC1.zip
  6. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.0.RC2.zip
  7. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.0.zip
  8. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.1.zip
  9. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.10.zip
  10. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.11.zip
  11. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.12.zip
  12. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.13.zip
  13. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.2.zip
  14. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.3.zip
  15. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.4.zip
  16. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.5.zip
  17. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.6.zip
  18. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.7.zip
  19. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.8.zip
  20. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-0.90.9.zip
  21. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.0.0.Beta1.zip
  22. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.0.0.Beta2.zip
  23. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.0.0.RC1.zip
  24. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.0.0.RC2.zip
  25. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.0.0.zip
  26. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.0.1.zip
  27. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.0.2.zip
  28. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.0.3.zip
  29. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.1.0.zip
  30. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.1.1.zip
  31. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.1.2.zip
  32. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.2.0.zip
  33. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.2.1.zip
  34. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.2.2.zip
  35. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.2.3.zip
  36. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.2.4.zip
  37. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.3.0.zip
  38. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.3.1.zip
  39. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.3.2.zip
  40. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.3.3.zip
  41. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.3.4.zip
  42. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.3.5.zip
  43. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.3.6.zip
  44. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.3.7.zip
  45. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.3.8.zip
  46. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.3.9.zip
  47. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.4.0.Beta1.zip
  48. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.4.0.zip
  49. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.4.1.zip
  50. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.4.2.zip
  51. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.4.3.zip
  52. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.4.4.zip
  53. BIN
      src/test/resources/org/elasticsearch/bwcompat/index-1.5.0.zip
  54. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.0.0.Beta2.zip
  55. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.0.0.RC1.zip
  56. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.0.0.RC2.zip
  57. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.0.0.zip
  58. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.0.1.zip
  59. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.0.2.zip
  60. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.0.3.zip
  61. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.1.0.zip
  62. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.1.1.zip
  63. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.1.2.zip
  64. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.2.0.zip
  65. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.2.1.zip
  66. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.2.2.zip
  67. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.2.3.zip
  68. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.2.4.zip
  69. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.3.0.zip
  70. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.3.1.zip
  71. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.3.2.zip
  72. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.3.3.zip
  73. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.3.4.zip
  74. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.3.5.zip
  75. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.3.6.zip
  76. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.3.7.zip
  77. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.3.8.zip
  78. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.3.9.zip
  79. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.4.0.Beta1.zip
  80. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.4.0.zip
  81. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.4.1.zip
  82. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.4.2.zip
  83. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.4.3.zip
  84. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.4.4.zip
  85. BIN
      src/test/resources/org/elasticsearch/bwcompat/repo-1.5.0.zip

+ 35 - 1
dev-tools/create-bwc-index.py

@@ -69,6 +69,34 @@ def index_documents(es, index_name, type, num_docs):
   logging.info('Flushing index')
   es.indices.flush(index=index_name)
 
+def delete_by_query(es, version, index_name, doc_type):
+
+  logging.info('Deleting long_sort:[10..20] docs')
+
+  query = {'query':
+           {'range':
+            {'long_sort':
+             {'gte': 10,
+              'lte': 20}}}}
+
+  if version.startswith('0.90.') or version in ('1.0.0.Beta1', '1.0.0.Beta2'):
+    # TODO #10262: we can't write DBQ into the translog for these old versions until we fix this back-compat bug:
+
+    # #4074: these versions don't expect to see the top-level 'query' to count/delete_by_query:
+    query = query['query']
+    return
+
+  deleted_count = es.count(index=index_name, doc_type=doc_type, body=query)['count']
+    
+  result = es.delete_by_query(index=index_name,
+                              doc_type=doc_type,
+                              body=query)
+
+  # make sure no shards failed:
+  assert result['_indices'][index_name]['_shards']['failed'] == 0, 'delete by query failed: %s' % result
+
+  logging.info('Deleted %d docs' % deleted_count)
+
 def run_basic_asserts(es, index_name, type, num_docs):
   count = es.count(index=index_name)['count']
   assert count == num_docs, 'Expected %r but got %r documents' % (num_docs, count)
@@ -150,7 +178,7 @@ def generate_index(client, version):
       }
     }
     # completion type was added in 0.90.3
-    if not version in ['0.90.0.Beta1', '0.90.0.RC1', '0.90.0.RC2', '0.90.0', '0.90.1', '0.90.2']:
+    if version not in ['0.90.0.Beta1', '0.90.0.RC1', '0.90.0.RC2', '0.90.0', '0.90.1', '0.90.2']:
       mappings['analyzer_type1']['properties']['completion_with_index_analyzer'] = {
         'type': 'completion',
         'index_analyzer': 'standard'
@@ -312,6 +340,12 @@ def main():
     generate_index(client, cfg.version)
     if cfg.snapshot_supported:
       snapshot_index(client, cfg)
+
+    # 10067: get a delete-by-query into the translog on upgrade.  We must do
+    # this after the snapshot, because it calls flush.  Otherwise the index
+    # will already have the deletions applied on upgrade.
+    delete_by_query(client, cfg.version, 'test', 'doc')
+    
   finally:
     if 'node' in vars():
       logging.info('Shutting down node with pid %d', node.pid)

+ 5 - 1
dev-tools/get-bwc-version.py

@@ -61,7 +61,11 @@ def main():
   else:
     filename = '%s.tar.gz' % version_dir
 
-  url = 'https://download.elasticsearch.org/elasticsearch/elasticsearch/%s' % filename
+  if c.version == '1.2.0':
+    # 1.2.0 was pulled from download.elasticsearch.org because of routing bug:
+    url = 'http://central.maven.org/maven2/org/elasticsearch/elasticsearch/1.2.0/%s' % filename
+  else:
+    url = 'https://download.elasticsearch.org/elasticsearch/elasticsearch/%s' % filename
   print('Downloading %s' % url)
   urllib.request.urlretrieve(url, filename)
 

+ 14 - 3
src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java

@@ -116,7 +116,9 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
         assertBasicSearchWorks();
         assertRealtimeGetWorks();
         assertNewReplicasWork();
-        assertUpgradeWorks(isLatestLuceneVersion(index));
+        Version version = extractVersion(index);
+        assertUpgradeWorks(isLatestLuceneVersion(version));
+        assertDeleteByQueryWorked(version);
         unloadIndex();
     }
     
@@ -124,8 +126,7 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
         return Version.fromString(index.substring(index.indexOf('-') + 1, index.lastIndexOf('.')));
     }
     
-    boolean isLatestLuceneVersion(String index) {
-        Version version = extractVersion(index);
+    boolean isLatestLuceneVersion(Version version) {
         return version.luceneVersion.major == Version.CURRENT.luceneVersion.major &&
                version.luceneVersion.minor == Version.CURRENT.luceneVersion.minor;
     }
@@ -186,6 +187,16 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
             .execute().actionGet());
         waitNoPendingTasksOnAll(); // make sure the replicas are removed before going on
     }
+
+    // #10067: create-bwc-index.py deleted any doc with long_sort:[10-20]
+    void assertDeleteByQueryWorked(Version version) throws Exception {
+        if (version.onOrBefore(Version.V_1_0_0_Beta2)) {
+            // TODO: remove this once #10262 is fixed
+            return;
+        }
+        SearchRequestBuilder searchReq = client().prepareSearch("test").setQuery(QueryBuilders.queryStringQuery("long_sort:[10 TO 20]"));
+        assertEquals(0, searchReq.get().getHits().getTotalHits());
+    }
     
     void assertUpgradeWorks(boolean alreadyLatest) throws Exception {
         HttpRequestBuilder httpClient = httpClient();

BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.0.Beta1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.0.RC1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.0.RC2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.0.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.10.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.11.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.12.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.13.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.3.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.4.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.5.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.6.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.7.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.8.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-0.90.9.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.0.0.Beta1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.0.0.Beta2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.0.0.RC1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.0.0.RC2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.0.0.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.0.1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.0.2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.0.3.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.1.0.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.1.1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.1.2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.2.0.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.2.1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.2.2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.2.3.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.2.4.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.3.0.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.3.1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.3.2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.3.3.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.3.4.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.3.5.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.3.6.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.3.7.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.3.8.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.3.9.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.4.0.Beta1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.4.0.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.4.1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.4.2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.4.3.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.4.4.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/index-1.5.0.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.0.0.Beta2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.0.0.RC1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.0.0.RC2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.0.0.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.0.1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.0.2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.0.3.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.1.0.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.1.1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.1.2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.2.0.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.2.1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.2.2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.2.3.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.2.4.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.3.0.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.3.1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.3.2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.3.3.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.3.4.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.3.5.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.3.6.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.3.7.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.3.8.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.3.9.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.4.0.Beta1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.4.0.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.4.1.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.4.2.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.4.3.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.4.4.zip


BIN
src/test/resources/org/elasticsearch/bwcompat/repo-1.5.0.zip