Skip to content

Commit cd146e1

Browse files
committed
Enabled ElasticSearch 6 support
1 parent a4f2fef commit cd146e1

23 files changed

+124
-74
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ after_script:
3737
- sudo kubectl logs -l app=magento -c monolith
3838
- sudo kubectl logs -l app=magento -c nginx
3939
- sudo cat /etc/exports
40+
- sudo cat ./tests/logs/*
41+
- sudo cat ./logs/*

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ If you never used Kubernetes before, read the [Kubernetes Docs](https://kubernet
6363

6464
The software listed below should be available in [PATH](https://en.wikipedia.org/wiki/PATH_\(variable\)) (except for PHP Storm).
6565

66+
- [Docker](https://docs.docker.com/docker-for-mac/install/)
6667
- [Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/)
6768
- [Helm](https://docs.helm.sh/using_helm/#installing-helm)
6869
- [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
@@ -343,14 +344,9 @@ Use the following commands to enable/disable varnish without reinstalling Magent
343344

344345
### Activating ElasticSearch
345346

346-
Not available yet.
347-
<!--
348-
:information_source: Available in Magento EE only.
349-
350347
Set `search_engine: "elasticsearch"` in [config.yaml](etc/config.yaml.dist) to use ElasticSearch as current search engine or `search_engine: "mysql"` to use MySQL. Changes will be applied on `m-reinstall`.
351348

352349
Use the following commands to switch between search engines without reinstalling Magento: `m-search-engine elasticsearch` or `m-search-engine mysql`.
353-
-->
354350

355351
### Redis for caching
356352

etc/.gitignore

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
/*
2-
!/.gitignore
3-
!/docker
4-
!/composer
5-
/composer/*
6-
!/composer/auth.json.dist
7-
!/config.yaml.dist
8-
!/magento2_virtual_host.conf.dist
9-
!/guest
10-
!/kubernetes
11-
!/helm
1+
config.yaml

etc/config.yaml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ environment:
4242
# [To apply changes: m-reinstall OR m-varnish enable/disable]
4343
use_varnish: 0
4444
# [To apply changes: m-reinstall] Possible values: mysql, elasticsearch
45-
search_engine: "mysql"
45+
search_engine: "elasticsearch"
4646

4747
magento:
4848
# [To apply changes: m-switch-to-ce -f OR m-switch-to-ee -f]
9.83 KB
Binary file not shown.

etc/helm/charts/mysql-0.15.0.tgz

9.31 KB
Binary file not shown.

etc/helm/charts/mysql-0.9.2.tgz

-8.62 KB
Binary file not shown.

etc/helm/charts/rabbitmq-3.6.3.tgz

-11.5 KB
Binary file not shown.

etc/helm/charts/rabbitmq-5.5.0.tgz

15.7 KB
Binary file not shown.

etc/helm/charts/redis-5.0.0.tgz

-17.7 KB
Binary file not shown.

etc/helm/charts/redis-6.4.5.tgz

19.7 KB
Binary file not shown.

etc/helm/requirements.lock

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
dependencies:
22
- name: mysql
33
repository: https://kubernetes-charts.storage.googleapis.com
4-
version: 0.9.2
4+
version: 0.15.0
55
- name: redis
66
repository: https://kubernetes-charts.storage.googleapis.com
7-
version: 5.0.0
7+
version: 6.4.5
88
- name: rabbitmq
99
repository: https://kubernetes-charts.storage.googleapis.com
10-
version: 3.6.3
11-
digest: sha256:c75abdd584e0aa2ac7d476f1641aa9fe1f18a9526114a0b5a075266ee62fb47f
12-
generated: 2019-01-31T20:07:53.996726-06:00
10+
version: 5.5.0
11+
- name: elasticsearch
12+
repository: https://helm.elastic.co
13+
version: 6.5.0
14+
digest: sha256:f5f413c09690010e1ed93c9fbc0f268ea869eca6e1d42e83729eeee70cdb1bfb
15+
generated: 2019-05-01T14:43:50.018673-05:00

etc/helm/requirements.yaml

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
dependencies:
22
- name: mysql
3-
version: "0.9.2"
3+
version: "0.15.0"
44
appVersion: 5.7.14
55
repository: "@stable"
66
- name: redis
77
repository: "@stable"
8-
version: "5.0"
8+
appVersion: "4.0.14"
9+
version: "6.4.5"
910
- name: rabbitmq
1011
repository: "@stable"
11-
version: "3.6.3"
12+
appVersion: "3.7.14"
13+
version: "5.5.0"
14+
- name: elasticsearch
15+
repository: "https://helm.elastic.co"
16+
appVersion: "6.7.1"
17+
version: "6.5.0"
1218
- name: checkout
1319
repository: file://./charts/
1420
version: 0.1.0

etc/helm/values.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,33 @@ rabbitmq:
8585
rabbitmq:
8686
username: admin
8787
password: 123123q
88+
89+
elasticsearch:
90+
imageTag: "6.7.1"
91+
esMajorVersion: 6
92+
93+
replicas: 2
94+
minimumMasterNodes: 1
95+
96+
# Permit co-located instances for solitary minikube virtual machines.
97+
antiAffinity: "soft"
98+
99+
# Shrink default JVM heap.
100+
esJavaOpts: "-Xmx128m -Xms128m"
101+
102+
# Allocate smaller chunks of memory per pod.
103+
resources:
104+
requests:
105+
cpu: "100m"
106+
memory: "512M"
107+
limits:
108+
cpu: "1000m"
109+
memory: "512M"
110+
111+
# Request smaller persistent volumes.
112+
volumeClaimTemplate:
113+
accessModes: [ "ReadWriteOnce" ]
114+
storageClassName: "standard"
115+
resources:
116+
requests:
117+
storage: 100M

init_project.sh

+20-20
Original file line numberDiff line numberDiff line change
@@ -173,26 +173,26 @@ if [[ ${force_project_cleaning} -eq 1 ]]; then
173173
# fi
174174

175175

176-
# if [[ $(isMinikubeRunning) -eq 1 ]]; then
177-
# minikube stop 2> >(logError) | {
178-
# while IFS= read -r line
179-
# do
180-
# filterVagrantOutput "${line}"
181-
# lastline="${line}"
182-
# done
183-
# filterVagrantOutput "${lastline}"
184-
# }
185-
# fi
186-
# if [[ $(isMinikubeStopped) -eq 1 ]]; then
187-
# minikube delete 2> >(logError) | {
188-
# while IFS= read -r line
189-
# do
190-
# filterVagrantOutput "${line}"
191-
# lastline="${line}"
192-
# done
193-
# filterVagrantOutput "${lastline}"
194-
# }
195-
# fi
176+
if [[ $(isMinikubeRunning) -eq 1 ]]; then
177+
minikube stop 2> >(logError) | {
178+
while IFS= read -r line
179+
do
180+
filterVagrantOutput "${line}"
181+
lastline="${line}"
182+
done
183+
filterVagrantOutput "${lastline}"
184+
}
185+
fi
186+
if [[ $(isMinikubeStopped) -eq 1 ]]; then
187+
minikube delete 2> >(logError) | {
188+
while IFS= read -r line
189+
do
190+
filterVagrantOutput "${line}"
191+
lastline="${line}"
192+
done
193+
filterVagrantOutput "${lastline}"
194+
}
195+
fi
196196

197197
mv "${vagrant_dir}/etc/guest/.gitignore" "${vagrant_dir}/etc/.gitignore.back"
198198
rm -rf "${vagrant_dir}/.vagrant" "${vagrant_dir}/etc/guest"

m-search-engine

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ if [[ ${debug_vagrant_project} -eq 1 ]]; then
1515
fi
1616

1717
cd "${vagrant_dir}"
18-
vagrant ssh -c "bash /vagrant/scripts/guest/m-search-engine ${@}" 2> >(logError)
18+
19+
executeInMagento2Container -- "${vagrant_dir}/scripts/guest/m-search-engine" ${@} 2> >(logError)
1920

2021
info "$(regular)See details in $(bold)${vagrant_dir}/log/${current_script_name}.log$(regular). For debug output set $(bold)debug:vagrant_project$(regular) to $(bold)1$(regular) in $(bold)etc/config.yaml$(regular)"

scripts/guest/configure_search_engine

+17-21
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,23 @@ if [[ -z "$(grep "search_engine:" ${vagrant_dir}/etc/config.yaml)" ]]; then
1212
sed -i '/environment:/a \ \ search_engine: "mysql"' ${vagrant_dir}/etc/config.yaml
1313
fi
1414

15-
if [[ -f "${MAGENTO_ROOT}/LICENSE_EE.txt" ]]; then
16-
search_engine="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "environment_search_engine")"
17-
if [[ ${search_engine} == "elasticsearch" ]]; then
18-
status "Configuring ElasticSearch search engine"
19-
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/engine' 'elasticsearch'
20-
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/elasticsearch_server_hostname' 'localhost'
21-
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/elasticsearch_server_port' '9200'
22-
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/elasticsearch_index_prefix' 'magento2'
23-
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/elasticsearch_enable_auth' '0'
24-
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/elasticsearch_server_timeout' '15'
25-
elif [[ ${search_engine} == "mysql" ]]; then
26-
status "Configuring MySQL search engine"
27-
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/engine' 'mysql'
28-
fi
29-
30-
bash "${VAGRANT_ROOT}/scripts/guest/m-clear-cache"
31-
32-
status "Rebuilding catalog search index"
33-
php "${MAGENTO_ROOT}/bin/magento" indexer:reindex catalogsearch_fulltext 2> >(logError) > >(log)
34-
else
35-
status "Search engine configuration was not changed (custom search engine is not available in Magento CE)."
15+
search_engine="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "environment_search_engine")"
16+
if [[ ${search_engine} == "elasticsearch" ]]; then
17+
status "Configuring ElasticSearch search engine"
18+
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/engine' 'elasticsearch6'
19+
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/elasticsearch6_server_hostname' 'elasticsearch-master'
20+
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/elasticsearch6_server_port' '9200'
21+
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/elasticsearch6_index_prefix' 'magento2'
22+
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/elasticsearch6_enable_auth' '0'
23+
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/elasticsearch6_server_timeout' '15'
24+
elif [[ ${search_engine} == "mysql" ]]; then
25+
status "Configuring MySQL search engine"
26+
"${VAGRANT_ROOT}/scripts/guest/update_magento_config" 'catalog/search/engine' 'mysql'
3627
fi
3728

29+
bash "${VAGRANT_ROOT}/scripts/guest/m-clear-cache"
30+
31+
status "Rebuilding catalog search index"
32+
php "${MAGENTO_ROOT}/bin/magento" indexer:reindex catalogsearch_fulltext 2> >(logError) > >(log)
33+
3834
decrementNestingLevel

scripts/host/check_requirements.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ source "${vagrant_dir}/scripts/functions.sh"
77
status "Checking requirements"
88
incrementNestingLevel
99

10+
nfs_enabled="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs")"
1011
nfs_exports_record="$(bash "${vagrant_dir}/scripts/host/get_nfs_exports_record.sh")"
11-
if [[ -z "$(grep "${nfs_exports_record}" /etc/exports)" ]]; then
12+
if [[ ${nfs_enabled} -eq 1 ]] && [[ -z "$(grep "${nfs_exports_record}" /etc/exports)" ]]; then
1213
warning "NFS exports configuration required on the host. Please execute 'bash ${vagrant_dir}/scripts/host/configure_nfs_exports.sh' first."
1314
exit 1
1415
fi

scripts/host/configure_nfs_exports.sh

+12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ if [[ ${debug_vagrant_project} -eq 1 ]]; then
1414
set -x
1515
fi
1616

17+
nfs_enabled="$(bash "${vagrant_dir}/scripts/get_config_value.sh" "guest_use_nfs")"
18+
if [[ ${nfs_enabled} -eq 0 ]]; then
19+
status "Skipping NFS configuration per config.yaml"
20+
exit 0
21+
fi
22+
23+
userId=$(id -u)
24+
if [[ ${userId} -eq 0 ]]; then
25+
error "${vagrant_dir}/scripts/host/configure_nfs_exports.sh MUST NOT be run with sudo. Run it from unprivileged user and enter password when prompted."
26+
exit 1
27+
fi
28+
1729
host_os="$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")"
1830
nfs_exports_record="$(bash "${vagrant_dir}/scripts/host/get_nfs_exports_record.sh")"
1931
if [[ ${host_os} == "OSX" ]]; then

scripts/host/k_rebuild_environment.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ helm list -q | xargs helm delete --purge 2>/dev/null
1919
set -e
2020

2121
# TODO: Need to make sure all resources have been successfully deleted before the attempt of recreating them
22-
sleep 7
22+
#sleep 20
2323
enable_nfs="true"
2424
enable_checkout="false"
2525
while getopts 'de' flag; do

tests/include/assertions.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ function executeExtendedCommonAssertions()
3333
# Test search
3434
createSimpleProduct
3535
assertSearchWorks
36+
37+
assertElasticSearchEnabled
38+
assertElasticSearchDisablingWorks
39+
assertElasticSearchEnablingWorks
3640
}
3741

3842
## Assertions
@@ -292,11 +296,13 @@ function assertElasticSearchEnabled()
292296
echo "## assertElasticSearchEnabled" >>${current_log_file_path}
293297

294298
cd "${vagrant_dir}"
295-
elasticSearchHealth="$(vagrant ssh -c 'curl -i http://127.0.0.1:9200/_cluster/health')"
299+
300+
elasticSearchHealth="$(executeInMagento2Container curl -- '-i' 'http://elasticsearch-master:9200/_cluster/health')"
301+
296302
assertTrue "ElasticSearch server is down:
297303
${elasticSearchHealth}" '[[ ${elasticSearchHealth} =~ \"status\":\"(green|yellow)\" ]]'
298304

299-
listOfIndexes="$(vagrant ssh -c 'curl -i http://127.0.0.1:9200/_cat/indices?v')"
305+
listOfIndexes="$(executeInMagento2Container curl -- '-i' 'http://elasticsearch-master:9200/_cat/indices?v')"
300306
assertTrue "Products index is not available in ElasticSearch:
301307
${listOfIndexes}" '[[ ${listOfIndexes} =~ magento2_product ]]'
302308

@@ -309,11 +315,11 @@ function assertElasticSearchDisabled()
309315
echo "## assertElasticSearchDisabled" >>${current_log_file_path}
310316

311317
cd "${vagrant_dir}"
312-
elasticSearchHealth="$(vagrant ssh -c 'curl -i http://127.0.0.1:9200/_cluster/health')"
318+
elasticSearchHealth="$(executeInMagento2Container curl -- '-i' 'http://elasticsearch-master:9200/_cluster/health')"
313319
assertTrue "ElasticSearch server is down:
314320
${elasticSearchHealth}" '[[ ${elasticSearchHealth} =~ \"status\":\"(green|yellow)\" ]]'
315321

316-
listOfIndexes="$(vagrant ssh -c 'curl -i http://127.0.0.1:9200/_cat/indices?v')"
322+
listOfIndexes="$(executeInMagento2Container curl -- '-i' 'http://elasticsearch-master:9200/_cat/indices?v')"
317323
assertTrue "Products index must not be available in ElasticSearch:
318324
${listOfIndexes}" '[[ ! ${listOfIndexes} =~ magento2_product ]]'
319325

tests/include/helpers.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function refreshSearchIndexes()
204204
echo "## deleteElasticSearchIndexes" >>${current_log_file_path}
205205

206206
cd "${vagrant_dir}"
207-
vagrant ssh -c 'curl -X DELETE -i http://127.0.0.1:9200/_all' >>${current_log_file_path} 2>&1
207+
executeInMagento2Container curl -- '-X' 'DELETE' '-i' 'http://elasticsearch-master:9200/_all' >>${current_log_file_path} 2>&1
208208
bash m-bin-magento indexer:reindex catalogsearch_fulltext >>${current_log_file_path} 2>&1
209209
}
210210

tests/testsuite.sh

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ source include/configuration.sh
1111
source include/helpers.sh
1212
source include/assertions.sh
1313

14+
original_vagrant_dir="${vagrant_dir}"
15+
source ./../scripts/functions.sh
16+
vagrant_dir=${original_vagrant_dir}
17+
cd ${tests_dir}
18+
1419
## Setup and tear down
1520

1621
function oneTimeSetUp
@@ -58,6 +63,8 @@ function testNoCustomConfigBasicTest()
5863
assertTestsConfigured
5964
assertDebugConfigurationWork
6065
assertRedisCacheIsEnabled
66+
67+
executeExtendedCommonAssertions
6168
}
6269

6370
## Call and Run all Tests

0 commit comments

Comments
 (0)