Skip to content

Commit a4f2fef

Browse files
authored
Merge pull request #29 from magento/build-improvements
Automatic NFS configuration and validation
2 parents 7fd0028 + 256a45b commit a4f2fef

8 files changed

+64
-29
lines changed

.travis.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ before_script:
1919
- sudo apt-get update && sudo apt-get install -y socat
2020
# TODO Install sudo apt install nfs-kernel-server
2121
- sudo apt install -y nfs-kernel-server
22-
- sudo ./scripts/host/configure_nfs_exports.sh
23-
- cp ./tests/include/configuration.sh.dist ./tests/include/configuration.sh
24-
- sed -i "s|[email protected]:|https://github.com/|g" ./etc/config.yaml.dist
25-
- sed -i "s|minikube start --cpus=2 --memory=4096|sudo minikube start --cpus=2 --memory=4096 --vm-driver=none --bootstrapper=kubeadm --kubernetes-version=v1.13.0|g" ./init_project.sh
26-
- sed -i "s|&& eval \$(minikube docker-env) ||g" ./scripts/host/k_rebuild_environment.sh
27-
- sed -i "s/use_nfs:\ 1/use_nfs:\ 0/g" ./etc/config.yaml.dist
28-
- sed -i "s/nfs_server_ip:\ \"0\.0\.0\.0\"/nfs_server_ip:\ \"$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')\"/g" ./etc/config.yaml.dist
29-
- sed -i "s/enabled:\ true \# NFS Status/enabled:\ false \# NFS Status/g" ./etc/helm/values.yaml
22+
- sudo bash ./scripts/host/configure_ubuntu_travis.sh
3023
- cat ./tests/include/configuration.sh
3124
- cat ./scripts/host/k_rebuild_environment.sh
3225
- cat ./init_project.sh
@@ -35,3 +28,12 @@ before_script:
3528
script:
3629
# Run DevBox tests
3730
- cd ./tests && sudo bash ./testsuite.sh && cd ..
31+
32+
after_script:
33+
- sudo kubectl describe pods
34+
- sudo kubectl describe deployments
35+
- sudo kubectl get pv,pvc
36+
- sudo kubectl logs -l app=magento -c monolith-xdebug
37+
- sudo kubectl logs -l app=magento -c monolith
38+
- sudo kubectl logs -l app=magento -c nginx
39+
- sudo cat /etc/exports

scripts/host/check_requirements.sh

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ source "${vagrant_dir}/scripts/functions.sh"
77
status "Checking requirements"
88
incrementNestingLevel
99

10-
# TODO: Fix NFS requirements check
11-
#nfs_exports_record="\"${vagrant_dir}\" -alldirs -mapall=$(id -u):$(id -g) -mask 255.0.0.0 -network 192.0.0.0"
12-
#if [[ -z "$(grep "${nfs_exports_record}" /etc/exports)" ]]; then
13-
# warning "NFS exports configuration required on the host. Please execute 'bash ${vagrant_dir}/scripts/host/configure_nfs_exports.sh' first."
14-
# exit 1
15-
#fi
10+
nfs_exports_record="$(bash "${vagrant_dir}/scripts/host/get_nfs_exports_record.sh")"
11+
if [[ -z "$(grep "${nfs_exports_record}" /etc/exports)" ]]; then
12+
warning "NFS exports configuration required on the host. Please execute 'bash ${vagrant_dir}/scripts/host/configure_nfs_exports.sh' first."
13+
exit 1
14+
fi
1615

1716
decrementNestingLevel

scripts/host/configure_nfs_exports.sh

+3-8
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ if [[ ${debug_vagrant_project} -eq 1 ]]; then
1515
fi
1616

1717
host_os="$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")"
18-
19-
# TODO: Calculate network IP
18+
nfs_exports_record="$(bash "${vagrant_dir}/scripts/host/get_nfs_exports_record.sh")"
2019
if [[ ${host_os} == "OSX" ]]; then
21-
# TODO: Detect network IP dynamically
22-
nfs_exports_record="\"${vagrant_dir}\" -alldirs -mapall=$(id -u):$(id -g) -mask 255.0.0.0 -network 192.0.0.0"
2320
if [[ -z "$(grep "${nfs_exports_record}" /etc/exports)" ]]; then
24-
status "Updating /etc/exports to enable codebase sharing with containers via NFS"
21+
status "Updating /etc/exports to enable codebase sharing with containers via NFS (${nfs_exports_record})"
2522
echo "${nfs_exports_record}" | sudo tee -a "/etc/exports" 2> >(logError) > >(log)
2623
sudo nfsd restart
2724
# TODO: Implement NFS exports clean up on project removal to prevent NFS mounting errors
@@ -31,10 +28,8 @@ if [[ ${host_os} == "OSX" ]]; then
3128
fi
3229

3330
if [[ ${host_os} == "Linux" ]]; then
34-
# TODO: Detect network IP dynamically
35-
nfs_exports_record="\"${vagrant_dir}\" 172.17.0.0/255.255.0.0(rw,no_subtree_check,all_squash,anonuid=$(id -u),anongid=$(id -g))"
3631
if [[ -z "$(grep "${nfs_exports_record}" /etc/exports)" ]]; then
37-
status "Updating /etc/exports to enable codebase sharing with containers via NFS"
32+
status "Updating /etc/exports to enable codebase sharing with containers via NFS (${nfs_exports_record})"
3833
echo "${nfs_exports_record}" | sudo tee -a "/etc/exports" 2> >(logError) > >(log)
3934
sudo service nfs-kernel-server restart
4035
# TODO: Implement NFS exports clean up on project removal to prevent NFS mounting errors
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
cd "$(dirname "${BASH_SOURCE[0]}")/../.." && vagrant_dir=$PWD
4+
5+
cd "${vagrant_dir}"
6+
sudo ./scripts/host/configure_nfs_exports.sh
7+
cp ./tests/include/configuration.sh.dist ./tests/include/configuration.sh
8+
sed -i "s|[email protected]:|https://github.com/|g" ./etc/config.yaml.dist
9+
sed -i "s|minikube start --cpus=2 --memory=4096|sudo minikube start --cpus=2 --memory=4096 --vm-driver=none --bootstrapper=kubeadm --kubernetes-version=v1.13.0|g" ./init_project.sh
10+
sed -i "s|git clone|git clone --depth 1 |g" ./init_project.sh
11+
sed -i "s|&& eval \$(minikube docker-env) ||g" ./scripts/host/k_rebuild_environment.sh
12+
sed -i "s/use_nfs:\ 1/use_nfs:\ 0/g" ./etc/config.yaml.dist
13+
sed -i "s/enabled:\ true \# NFS Status/enabled:\ false \# NFS Status/g" ./etc/helm/values.yaml
14+
sed -i "s/nfs_server_ip:\ \"0\.0\.0\.0\"/nfs_server_ip:\ \"$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')\"/g" ./etc/config.yaml.dist
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
cd "$(dirname "${BASH_SOURCE[0]}")/../.." && vagrant_dir=$PWD
4+
5+
source "${vagrant_dir}/scripts/functions.sh"
6+
incrementNestingLevel
7+
8+
# TODO: Calculate network IP
9+
host_os="$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")"
10+
if [[ ${host_os} == "OSX" ]]; then
11+
nfs_exports_record="\"${vagrant_dir}\" -alldirs -mapall=$(id -u):$(id -g) -mask 255.0.0.0 -network 192.0.0.0"
12+
elif [[ ${host_os} == "Linux" ]]; then
13+
nfs_exports_record="\"${vagrant_dir}\" 172.17.0.0/255.255.0.0(rw,no_subtree_check,all_squash,anonuid=$(id -u),anongid=$(id -g))"
14+
else
15+
error "Host OS is not supported"
16+
exit 1
17+
fi
18+
19+
echo "${nfs_exports_record}"
20+
21+
decrementNestingLevel

tests/include/assertions.sh

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33
## Assertion groups
44

5-
function executeCommonAssertions()
5+
function executeBasicCommonAssertions()
66
{
7-
# TODO: Implement functionality and uncomment assertions
8-
# assertPhpStormConfigured
9-
107
# Make sure Magento was installed and is accessible
118
assertMagentoInstalledSuccessfully
129
assertMagentoFrontendAccessible
1310
assertMagentoCliWorks
11+
}
12+
13+
function executeExtendedCommonAssertions()
14+
{
15+
# TODO: Implement functionality and uncomment assertions
16+
# assertPhpStormConfigured
1417

1518
# # Make sure Magento is still accessible after restarting services
1619
# assertMysqlRestartWorks
1720
# assertApacheRestartWorks
1821
# assertMagentoFrontendAccessible
19-
#
22+
2023
# Make sure Magento reinstall script works
2124
assertMagentoReinstallWorks
2225
assertMagentoFrontendAccessible

tests/include/helpers.sh

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ function deployVagrantProject()
9595
echo "${grey}## deployVagrantProject${regular}"
9696
echo "## deployVagrantProject" >>${current_log_file_path}
9797
cd "${vagrant_dir}"
98+
sudo bash "${vagrant_dir}/scripts/host/configure_nfs_exports.sh"
9899
bash init_project.sh -fcd 2> >(logAndEcho) | {
99100
while IFS= read -r line
100101
do

tests/testsuite.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ See logs in ${logs_dir}"
4646

4747
## Tests
4848

49-
function testNoCustomConfig()
49+
function testNoCustomConfigBasicTest()
5050
{
5151
current_config_name="no_custom_config"
5252
current_codebase="ce"
5353
installEnvironment
5454
# assertVarnishDisabled
55-
executeCommonAssertions
55+
executeBasicCommonAssertions
5656
assertMagentoEditionIsCE
5757
assertCeSampleDataNotInstalled
5858
assertTestsConfigured

0 commit comments

Comments
 (0)