Skip to content

Commit 0c5c5fe

Browse files
authored
Add a script to upgrade the version of Elasticsearch (#84)
1 parent c1cc2bd commit 0c5c5fe

File tree

5 files changed

+58
-4
lines changed

5 files changed

+58
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ buildNumber.properties
1010

1111
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
1212
!/.mvn/wrapper/maven-wrapper.jar
13+
14+
# vim
15+
*.swp

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ unexpected.
99

1010
The fastest way to test any basic Elasticsearch feature is to start a Docker image with the desired Elasticsearch version:
1111

12+
<!-- MANAGED_BLOCK_RUN_ES_START -->
13+
1214
```sh
1315
docker run \
1416
--rm \
@@ -17,6 +19,8 @@ docker run \
1719
docker.elastic.co/elasticsearch/elasticsearch:7.8.0
1820
```
1921

22+
<!-- MANAGED_BLOCK_RUN_ES_END -->
23+
2024
## Articles
2125

2226
Articles wrote using code of this repository:
@@ -77,3 +81,14 @@ Articles:
7781
<https://blog.twitter.com/engineering/en_us/topics/infrastructure/2020/reducing-search-indexing-latency-to-one-second.html>
7882
- Prabin Meitei M, "Garbage Collection in Elasticsearch and the G1GC", _Medium_, 2018.<br>
7983
<https://medium.com/naukri-engineering/garbage-collection-in-elasticsearch-and-the-g1gc-16b79a447181>
84+
85+
## Development
86+
87+
Upgrade Elasticsearch version, e.g 7.8.0 -> 7.10.0:
88+
89+
```sh
90+
> scripts/upgrade-es-version.sh 7.8.0 7.10.0
91+
✅ pom.xml
92+
✅ cluster/src/test/resources/docker-compose.yml
93+
Finished.
94+
```

cluster/src/test/resources/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
version: '2.2'
66
services:
77
es01:
8-
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0
8+
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0 # CURRENT_ES_VERSION
99
container_name: es01
1010
environment:
1111
- node.name=es01
@@ -25,7 +25,7 @@ services:
2525
networks:
2626
- elastic
2727
es02:
28-
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0
28+
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0 # CURRENT_ES_VERSION
2929
container_name: es02
3030
environment:
3131
- node.name=es02
@@ -43,7 +43,7 @@ services:
4343
networks:
4444
- elastic
4545
es03:
46-
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0
46+
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0 # CURRENT_ES_VERSION
4747
container_name: es03
4848
environment:
4949
- node.name=es03

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Elasticsearch/Lucene Version Mapping:
2020
https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/Version.java#L58-L76
2121
-->
22-
<elasticsearch.version>7.8.0</elasticsearch.version>
22+
<elasticsearch.version>7.8.0</elasticsearch.version><!-- CURRENT_ES_VERSION -->
2323
<!--
2424
Dependencies should be aligned with Elasticsearch Testing Framework's
2525
requirement. Inspect Maven dependency tree to find out the right version:

scripts/upgrade-es-version.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
#
3+
# Usage:
4+
#
5+
# scripts/upgrade-es-version.sh <old_version> <new_version>
6+
#
7+
# Sample upgrading from 7.8.0 to 7.10.0:
8+
#
9+
# scripts/upgrade-es-version.sh 7.8.0 7.10.0
10+
#
11+
old_version="$1"
12+
new_version="$2"
13+
14+
if [[ -z $old_version || -z $new_version ]]
15+
then
16+
echo "Missing argument(s). Usage:"
17+
echo
18+
echo " upgrade-es-version.sh 7.8.0 7.10.0"
19+
echo
20+
exit 1
21+
fi
22+
23+
# Update configuration files
24+
filepaths=($(rg --files-with-matches --glob "**/*.{xml,yml}" CURRENT_ES_VERSION))
25+
for filepath in "${filepaths[@]}"
26+
do
27+
sed -i '' -e "s/${old_version}/${new_version}/g" $filepath
28+
echo "${filepath}"
29+
done
30+
31+
# Update README
32+
start=$(grep -n MANAGED_BLOCK_RUN_ES_START README.md | cut -f 1 -d :)
33+
end=$(grep -n MANAGED_BLOCK_RUN_ES_END README.md | cut -f 1 -d :)
34+
sed -i '' "${start},${end}s/${old_version}/${new_version}/g" README.md
35+
36+
echo "Finished."

0 commit comments

Comments
 (0)