File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed
distribution/packages/src
qa/vagrant/src/test/resources/packaging/tests Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ case "$1" in
122122 ulimit -l $MAX_LOCKED_MEMORY
123123 fi
124124
125- if [ -n " $MAX_MAP_COUNT " -a -f /proc/sys/vm/max_map_count ]; then
125+ if [ -n " $MAX_MAP_COUNT " -a -f /proc/sys/vm/max_map_count -a " $MAX_MAP_COUNT " -ge $( cat /proc/sys/vm/max_map_count ) ]; then
126126 sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
127127 fi
128128
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ start() {
9090 if [ -n " $MAX_LOCKED_MEMORY " ]; then
9191 ulimit -l $MAX_LOCKED_MEMORY
9292 fi
93- if [ -n " $MAX_MAP_COUNT " -a -f /proc/sys/vm/max_map_count ]; then
93+ if [ -n " $MAX_MAP_COUNT " -a -f /proc/sys/vm/max_map_count -a " $MAX_MAP_COUNT " -ge $( cat /proc/sys/vm/max_map_count ) ]; then
9494 sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
9595 fi
9696
Original file line number Diff line number Diff line change @@ -163,3 +163,31 @@ setup() {
163163 assert_file_exist /var/log/elasticsearch/gc.log.0.current
164164 stop_elasticsearch_service
165165}
166+
167+ # Ensures that if $MAX_MAP_COUNT is less than the set value on the OS
168+ # it will be updated
169+ @test " [INIT.D] sysctl is run when the value set is too small" {
170+ # intentionally a ridiculously low number
171+ sysctl -q -w vm.max_map_count=100
172+ start_elasticsearch_service
173+ max_map_count=$( sysctl -n vm.max_map_count)
174+ stop_elasticsearch_service
175+
176+ [ $max_map_count = 262144 ]
177+
178+ }
179+
180+ # Ensures that if $MAX_MAP_COUNT is greater than the set vaule on the OS
181+ # we do not attempt to update it this should cover equality as well as I think
182+ # we can trust that equality operators work as intended.
183+ @test " [INIT.D] sysctl is not run when it already has a larger or equal value set" {
184+ # intentionally set to the default +1
185+ sysctl -q -w vm.max_map_count=262145
186+ start_elasticsearch_service
187+ max_map_count=$( sysctl -n vm.max_map_count)
188+ stop_elasticsearch_service
189+
190+ # default value +1
191+ [ $max_map_count = 262145 ]
192+
193+ }
You can’t perform that action at this time.
0 commit comments