Skip to content

Commit d8e65ec

Browse files
committed
Stop wiping component templates
It's slow and verbose, and maybe not actually useful?
1 parent ee2dae7 commit d8e65ec

File tree

1 file changed

+0
-68
lines changed

1 file changed

+0
-68
lines changed

test_elasticsearch_serverless/utils.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ def wipe_cluster(client, elasticsearch_api_key):
7373
wipe_data_streams(client)
7474
wipe_indices(client)
7575

76-
if is_xpack:
77-
wipe_xpack_templates(client)
78-
else:
79-
client.indices.delete_template(name="*")
80-
client.indices.delete_index_template(name="*")
81-
client.cluster.delete_component_template(name="*")
82-
8376
if is_xpack:
8477
wipe_transforms(client)
8578

@@ -104,29 +97,6 @@ def wipe_indices(client):
10497
)
10598

10699

107-
def wipe_xpack_templates(client):
108-
# Delete component templates, need to retry because sometimes
109-
# indices aren't cleaned up in time before we issue the delete.
110-
templates = client.cluster.get_component_template()["component_templates"]
111-
templates_to_delete = [
112-
template for template in templates if not is_xpack_template(template["name"])
113-
]
114-
for _ in range(3):
115-
for template in list(templates_to_delete):
116-
try:
117-
client.cluster.delete_component_template(
118-
name=template["name"],
119-
)
120-
except RequestError:
121-
pass
122-
else:
123-
templates_to_delete.remove(template)
124-
125-
if not templates_to_delete:
126-
break
127-
time.sleep(0.01)
128-
129-
130100
def wipe_transforms(client: Elasticsearch, timeout=30):
131101
end_time = time.time() + timeout
132102
while time.time() < end_time:
@@ -142,44 +112,6 @@ def wipe_transforms(client: Elasticsearch, timeout=30):
142112
)
143113

144114

145-
def is_xpack_template(name):
146-
if name.startswith(".monitoring-"):
147-
return True
148-
elif name.startswith(".watch") or name.startswith(".triggered_watches"):
149-
return True
150-
elif name.startswith(".data-frame-"):
151-
return True
152-
elif name.startswith(".ml-"):
153-
return True
154-
elif name.startswith(".transform-"):
155-
return True
156-
elif name.startswith(".deprecation-"):
157-
return True
158-
if name in {
159-
".watches",
160-
"security_audit_log",
161-
".slm-history",
162-
".async-search",
163-
"saml-service-provider",
164-
"logs",
165-
"logs-settings",
166-
"logs-mappings",
167-
"metrics",
168-
"metrics-settings",
169-
"metrics-mappings",
170-
"synthetics",
171-
"synthetics-settings",
172-
"synthetics-mappings",
173-
".snapshot-blob-cache",
174-
"ilm-history",
175-
"logstash-index-template",
176-
"security-index-template",
177-
"data-streams-mappings",
178-
}:
179-
return True
180-
return False
181-
182-
183115
def es_api_key() -> str:
184116
"""
185117
Gets Elasticsearch API key ID and secret from environment variables, raises ValueError if none found

0 commit comments

Comments
 (0)