Skip to content

Commit

Permalink
chore: update shopware and magento install
Browse files Browse the repository at this point in the history
  • Loading branch information
janosmiko committed Jan 3, 2025
1 parent ca26de1 commit c24cf6f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 48 deletions.
10 changes: 5 additions & 5 deletions images/_php-fpm-common/magento2-web/bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ magento_args_db() {

magento_args_redis() {
# Configure Redis
if [[ "${MAGENTO_REDIS_ENABLED:-true}" != "true" ]]; then
if [[ "${MAGENTO_REDIS_ENABLED:-false}" != "true" ]]; then
ARGS+=(
"--session-save=files"
)
Expand Down Expand Up @@ -246,7 +246,7 @@ magento_args_redis() {

magento_args_varnish() {
# Configure Varnish
if [[ "${MAGENTO_VARNISH_ENABLED:-true}" != "true" ]]; then
if [[ "${MAGENTO_VARNISH_ENABLED:-false}" != "true" ]]; then
return 0
fi

Expand All @@ -257,7 +257,7 @@ magento_args_varnish() {

magento_args_rabbitmq() {
# Configure RabbitMQ
if [[ "${MAGENTO_RABBITMQ_ENABLED:-true}" != "true" ]]; then
if [[ "${MAGENTO_RABBITMQ_ENABLED:-false}" != "true" ]]; then
return 0
fi

Expand All @@ -277,7 +277,7 @@ magento_args_rabbitmq() {
}

magento_args_search() {
if [[ "${MAGENTO_ELASTICSEARCH_ENABLED:-true}" != "true" ]] && [[ "${MAGENTO_OPENSEARCH_ENABLED:-false}" != "true" ]]; then
if [[ "${MAGENTO_ELASTICSEARCH_ENABLED:-false}" != "true" ]] && [[ "${MAGENTO_OPENSEARCH_ENABLED:-false}" != "true" ]]; then
return 0
fi

Expand Down Expand Up @@ -410,7 +410,7 @@ magento_configure_search() {
return 0
fi

if [[ "${MAGENTO_ELASTICSEARCH_ENABLED:-true}" != "true" ]] && [[ "${MAGENTO_OPENSEARCH_ENABLED:-false}" != "true" ]]; then
if [[ "${MAGENTO_ELASTICSEARCH_ENABLED:-false}" != "true" ]] && [[ "${MAGENTO_OPENSEARCH_ENABLED:-false}" != "true" ]]; then
return 0
fi

Expand Down
40 changes: 17 additions & 23 deletions images/_php-fpm-common/magento2-web/bin/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,14 @@ function test_magento_args_db() {
}

function test_magento_args_redis() {
# Redis is disabled
# Default
local ARGS=("")
local MAGENTO_REDIS_ENABLED="false"
magento_args_redis
assert_array_contains "--session-save=files" "${ARGS[@]}"
unset MAGENTO_REDIS_ENABLED

# Default
# Redis is enabled
local ARGS=("")
local MAGENTO_REDIS_ENABLED="true"
magento_args_redis

assert_array_contains "--session-save=redis" "${ARGS[@]}"
Expand Down Expand Up @@ -133,15 +132,14 @@ function test_magento_args_redis() {
}

function test_magento_args_varnish() {
# Varnish is disabled
# Default
local ARGS=("")
local MAGENTO_VARNISH_ENABLED="false"
magento_args_varnish
assert_equals "" "${ARGS[@]}"
unset MAGENTO_VARNISH_ENABLED

# Default
# Varnish is disabled
local ARGS=("")
local MAGENTO_VARNISH_ENABLED="true"
magento_args_varnish
assert_array_contains "--http-cache-hosts=varnish:80" "${ARGS[@]}"

Expand All @@ -158,24 +156,22 @@ function test_magento_args_search() {
local ARGS=("")
spy search_configured
magento_args_search
assert_equals "" "${ARGS[@]}"
assert_have_been_called_times 0 search_configured

# Elasticsearch enabled
local ARGS=("")
local MAGENTO_ELASTICSEARCH_ENABLED="true"
spy search_configured
magento_args_search
assert_array_contains "--search-engine=elasticsearch7" "${ARGS[@]}"
assert_array_contains "--elasticsearch-host=elasticsearch" "${ARGS[@]}"
assert_array_contains "--elasticsearch-port=9200" "${ARGS[@]}"
assert_array_contains "--elasticsearch-index-prefix=magento2" "${ARGS[@]}"
assert_array_contains "--elasticsearch-enable-auth=0" "${ARGS[@]}"
assert_array_contains "--elasticsearch-timeout=15" "${ARGS[@]}"
assert_have_been_called search_configured

# Search is disabled
local ARGS=("")
local MAGENTO_ELASTICSEARCH_ENABLED="false"
local MAGENTO_OPENSEARCH_ENABLED="false"
spy search_configured
magento_args_search
assert_equals "" "${ARGS[@]}"
assert_have_been_called_times 0 search_configured
unset MAGENTO_ELASTICSEARCH_ENABLED
unset MAGENTO_OPENSEARCH_ENABLED

# Opensearch enabled
local ARGS=("")
Expand All @@ -197,7 +193,6 @@ function test_magento_args_search() {
spy search_configured
magento_args_search
assert_array_not_contains "--search-engine" "${ARGS[@]}"
assert_have_been_called search_configured
unset MAGENTO_VERSION

# Default behaviour
Expand All @@ -216,15 +211,14 @@ function test_magento_args_search() {
}

function test_magento_args_rabbitmq() {
# RabbitMQ is disabled
# Default
local ARGS=("")
local MAGENTO_RABBITMQ_ENABLED="false"
magento_args_rabbitmq
assert_equals "" "${ARGS[@]}"
unset MAGENTO_RABBITMQ_ENABLED

# Default
# RabbitMQ is enabled
local ARGS=("")
local MAGENTO_RABBITMQ_ENABLED="true"
magento_args_rabbitmq

assert_array_contains "--amqp-host=rabbitmq" "${ARGS[@]}"
Expand Down
6 changes: 3 additions & 3 deletions images/_php-fpm-common/shopware-web/bin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ shopware_args_elasticsearch() {

shopware_args_opensearch() {
# Configure Opensearch
if [[ "${SHOPWARE_OPENSEARCH_ENABLED:-true}" != "true" ]]; then
if [[ "${SHOPWARE_OPENSEARCH_ENABLED:-false}" != "true" ]]; then
return 0
fi

Expand Down Expand Up @@ -411,7 +411,7 @@ shopware_admin_user() {
}

shopware_configure_redis() {
if [[ "${SHOPWARE_REDIS_ENABLED:-true}" != "true" ]]; then
if [[ "${SHOPWARE_REDIS_ENABLED:-false}" != "true" ]]; then
return 0
fi

Expand Down Expand Up @@ -539,7 +539,7 @@ shopware_reindex() {
return 0
fi

if [[ "${SHOPWARE_OPENSEARCH_ENABLED:-true}" != "true" ]] && [[ "${SHOPWARE_ELASTICSEARCH_ENABLED:-false}" != "true" ]]; then
if [[ "${SHOPWARE_OPENSEARCH_ENABLED:-false}" != "true" ]] && [[ "${SHOPWARE_ELASTICSEARCH_ENABLED:-false}" != "true" ]]; then
return 0
fi

Expand Down
44 changes: 27 additions & 17 deletions images/_php-fpm-common/shopware-web/bin/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,17 @@ function test_shopware_args_opensearch() {
# Default
local ARGS=("")
shopware_args_opensearch
assert_array_contains "--es-enabled=1" "${ARGS[@]}"
assert_array_contains "--es-hosts" "${ARGS[@]}"
assert_array_contains "--es-indexing-enabled=1" "${ARGS[@]}"

# Custom values - opensearch disabled
local ARGS=("")
local SHOPWARE_OPENSEARCH_ENABLED="false"
shopware_args_opensearch
assert_array_not_contains "--es-enabled=1" "${ARGS[@]}"
assert_array_not_contains "--es-hosts=opensearch:9200" "${ARGS[@]}"
assert_array_not_contains "--es-indexing-enabled=1" "${ARGS[@]}"

# Custom values - opensearch enabled
local ARGS=("")
local SHOPWARE_OPENSEARCH_ENABLED="true"
shopware_args_opensearch
assert_array_contains "--es-enabled=1" "${ARGS[@]}"
assert_array_contains "--es-hosts" "${ARGS[@]}"
assert_array_contains "--es-indexing-enabled=1" "${ARGS[@]}"
unset SHOPWARE_OPENSEARCH_ENABLED

# Custom values - opensearch indexing disabled
Expand Down Expand Up @@ -660,33 +660,43 @@ function test_shopware_reindex() {
shopware_reindex
assert_have_been_called_times 0 console

# Opensearch enabled but by default it doesn't run reindex (if shopware_dont_skip_reindex is not called)
local SHOPWARE_OPENSEARCH_ENABLED="true"
spy console
shopware_reindex
assert_have_been_called_times 0 console
unset SHOPWARE_OPENSEARCH_ENABLED

# Opensearch enabled
local SHOPWARE_OPENSEARCH_ENABLED="true"
spy console
shopware_dont_skip_reindex
shopware_reindex
assert_have_been_called_times 3 console
unset SHOPWARE_OPENSEARCH_ENABLED

# Opensearch and elasticsearch are disabled
local SHOPWARE_OPENSEARCH_ENABLED="false"
local SHOPWARE_ELASTICSEARCH_ENABLED="false"
# Elasticsearch enabled
local SHOPWARE_ELASTICSEARCH_ENABLED="true"
spy console
shopware_dont_skip_reindex
shopware_reindex
assert_have_been_called_times 0 console
assert_have_been_called_times 3 console
unset SHOPWARE_ELASTICSEARCH_ENABLED
}

function test_shopware_configure_redis() {
# Default
local APP_PATH="./test-data/app"

# Default
shopware_configure_redis
assert_file_contains "${APP_PATH}/config/packages/zz-redis.yml" "app: cache.adapter.redis"
assert_file_not_exists "${APP_PATH}/config/packages/zz-redis.yml"
rm -fr './test-data'

# Custom values
local SHOPWARE_REDIS_ENABLED=false
local SHOPWARE_REDIS_ENABLED=true
shopware_configure_redis
assert_file_not_exists "${APP_PATH}/config/packages/zz-redis.yml"
assert_file_contains "${APP_PATH}/config/packages/zz-redis.yml" "app: cache.adapter.redis"
rm -fr './test-data'
unset SHOPWARE_REDIS_ENABLED

mock shopware_version echo "v6.4.0.0"
shopware_configure_redis
Expand Down

0 comments on commit c24cf6f

Please sign in to comment.