File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed
deb/src/main/packaging/init.d
rpm/src/main/packaging/init.d
qa/vagrant/src/test/resources/packaging/tests Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ case "$1" in
147147 ulimit -l $MAX_LOCKED_MEMORY
148148 fi
149149
150- if [ -n " $MAX_MAP_COUNT " -a -f /proc/sys/vm/max_map_count ]; then
150+ 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
151151 sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
152152 fi
153153
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ start() {
114114 if [ -n " $MAX_LOCKED_MEMORY " ]; then
115115 ulimit -l $MAX_LOCKED_MEMORY
116116 fi
117- if [ -n " $MAX_MAP_COUNT " -a -f /proc/sys/vm/max_map_count ]; then
117+ 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
118118 sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
119119 fi
120120
Original file line number Diff line number Diff line change @@ -182,3 +182,32 @@ setup() {
182182
183183 service elasticsearch stop
184184}
185+
186+ # Ensures that if $MAX_MAP_COUNT is less than the set value on the OS
187+ # it will be updated
188+ @test " [INIT.D] sysctl is run when the value set is too small" {
189+ # intentionally a ridiculously low number
190+ sysctl -q -w vm.max_map_count=100
191+ start_elasticsearch_service
192+ max_map_count=$( sysctl -n vm.max_map_count)
193+ stop_elasticsearch_service
194+
195+ [ $max_map_count = 262144 ]
196+
197+ }
198+
199+ # Ensures that if $MAX_MAP_COUNT is greater than the set vaule on the OS
200+ # we do not attempt to update it this should cover equality as well as I think
201+ # we can trust that equality operators work as intended.
202+ @test " [INIT.D] sysctl is not run when it already has a larger or equal value set" {
203+ # intentionally set to the default +1
204+ sysctl -q -w vm.max_map_count=262145
205+ start_elasticsearch_service
206+ max_map_count=$( sysctl -n vm.max_map_count)
207+ stop_elasticsearch_service
208+
209+ # default value +1
210+ [ $max_map_count = 262145 ]
211+
212+ }
213+
You can’t perform that action at this time.
0 commit comments