Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neo4j start once again prints correct address on startup #8916

Merged
merged 3 commits into from
Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 27 additions & 3 deletions packaging/standalone/src/main/distribution/shell-scripts/bin/neo4j
Expand Up @@ -52,10 +52,34 @@ setup_arbiter_options() {
MAIN_CLASS="#{neo4j.mainClass}"

print_start_message() {
port="${org_neo4j_server_webserver_port:-7474}"
NEO4J_SERVER_ADDRESS="${org_neo4j_server_webserver_address:-localhost}"
# Global default
NEO4J_DEFAULT_ADDRESS="${dbms_connectors_default_listen_address:-localhost}"

if [[ "${dbms_connector_http_enabled:-true}" == "false" ]]; then
# Only HTTPS connector enabled
# First read deprecated 'address' setting
NEO4J_SERVER_ADDRESS="${dbms_connector_https_address:-:7473}"
# Overridden by newer 'listen_address' if specified
NEO4J_SERVER_ADDRESS="${dbms_connector_https_listen_address:-${NEO4J_SERVER_ADDRESS}}"
# If it's only a port we need to add the address (it starts with a colon in that case)
case ${NEO4J_SERVER_ADDRESS} in
:*)
NEO4J_SERVER_ADDRESS="${NEO4J_DEFAULT_ADDRESS}${NEO4J_SERVER_ADDRESS}";;
esac
# Add protocol
NEO4J_SERVER_ADDRESS="https://${NEO4J_SERVER_ADDRESS}"
else
# HTTP connector enabled - same as https but different settings
NEO4J_SERVER_ADDRESS="${dbms_connector_http_address:-:7474}"
NEO4J_SERVER_ADDRESS="${dbms_connector_http_listen_address:-${NEO4J_SERVER_ADDRESS}}"
case ${NEO4J_SERVER_ADDRESS} in
:*)
NEO4J_SERVER_ADDRESS="${NEO4J_DEFAULT_ADDRESS}${NEO4J_SERVER_ADDRESS}";;
esac
NEO4J_SERVER_ADDRESS="http://${NEO4J_SERVER_ADDRESS}"
fi

echo "Started neo4j (pid ${NEO4J_PID}). By default, it is available at http://${NEO4J_SERVER_ADDRESS}:${port}/"
echo "Started neo4j (pid ${NEO4J_PID}). It is available at ${NEO4J_SERVER_ADDRESS}/"

if [[ "$(echo "${dbms_mode:-}" | tr [:lower:] [:upper:])" == "HA" ]]; then
echo "This HA instance will be operational once it has joined the cluster."
Expand Down
78 changes: 71 additions & 7 deletions packaging/standalone/src/tests/shell-scripts/test-config.sh
Expand Up @@ -6,22 +6,86 @@ test_description="Test config parsing"
fake_install

test_expect_success "should default port and address if none are provided" "
test_expect_stdout_matching 'By default, it is available at http://localhost:7474/' run_daemon
clear_config &&
test_expect_stdout_matching 'It is available at http://localhost:7474/' run_daemon
"

test_expect_success "http: should read port and address from config" "
clear_config &&
set_config 'dbms.connector.http.address' '1.2.3.4:1234' neo4j.conf &&
set_config 'dbms.connector.http.enabled' 'true' neo4j.conf &&
test_expect_stdout_matching 'It is available at http://1.2.3.4:1234/' run_daemon
"

#test_expect_success "should read port and address from config" "
# set_config 'dbms.connector.0.type' 'HTTP' neo4j.conf &&
# set_config 'dbms.connector.0.address' 'neo4j.example.com' neo4j.conf &&
# set_config 'dbms.connector.0.port' '1234' neo4j.conf &&
# test_expect_stdout_matching 'Started at http://neo4j.example.com:1234' run_daemon
#"
test_expect_success "http: should read only port from config" "
clear_config &&
set_config 'dbms.connector.http.address' ':1234' neo4j.conf &&
set_config 'dbms.connector.http.enabled' 'true' neo4j.conf &&
test_expect_stdout_matching 'It is available at http://localhost:1234/' run_daemon
"

test_expect_success "http: should fallback to default listening address if defined" "
clear_config &&
set_config 'dbms.connectors.default_listen_address' '100.200.300.400' neo4j.conf &&
set_config 'dbms.connector.http.enabled' 'true' neo4j.conf &&
test_expect_stdout_matching 'It is available at http://100.200.300.400:7474/' run_daemon
"

test_expect_success "http: should read port and address from config and prioritize non-deprecated" "
clear_config &&
set_config 'dbms.connector.http.address' '1.2.3.4:1234' neo4j.conf &&
set_config 'dbms.connector.http.listen_address' 'a.b.c.d:333' neo4j.conf &&
set_config 'dbms.connector.http.enabled' 'true' neo4j.conf &&
test_expect_stdout_matching 'It is available at http://a.b.c.d:333/' run_daemon
"

test_expect_success "https: should display default https if http disabled and no other options" "
clear_config &&
set_config 'dbms.connector.http.enabled' 'false' neo4j.conf &&
test_expect_stdout_matching 'It is available at https://localhost:7473/' run_daemon
"

test_expect_success "https: should read port and address from config" "
clear_config &&
set_config 'dbms.connector.http.enabled' 'false' neo4j.conf &&
set_config 'dbms.connector.https.address' '1.2.3.4:1234' neo4j.conf &&
set_config 'dbms.connector.https.enabled' 'true' neo4j.conf &&
test_expect_stdout_matching 'It is available at https://1.2.3.4:1234/' run_daemon
"

test_expect_success "https: should read only port from config" "
clear_config &&
set_config 'dbms.connector.http.enabled' 'false' neo4j.conf &&
set_config 'dbms.connector.https.address' ':1234' neo4j.conf &&
set_config 'dbms.connector.https.enabled' 'true' neo4j.conf &&
test_expect_stdout_matching 'It is available at https://localhost:1234/' run_daemon
"

test_expect_success "https: should fallback to default listening address if defined" "
clear_config &&
set_config 'dbms.connector.http.enabled' 'false' neo4j.conf &&
set_config 'dbms.connectors.default_listen_address' '100.200.300.400' neo4j.conf &&
set_config 'dbms.connector.https.enabled' 'true' neo4j.conf &&
test_expect_stdout_matching 'It is available at https://100.200.300.400:7473/' run_daemon
"

test_expect_success "https: should read port and address from config and prioritize non-deprecated" "
clear_config &&
set_config 'dbms.connector.http.enabled' 'false' neo4j.conf &&
set_config 'dbms.connector.https.address' '1.2.3.4:1234' neo4j.conf &&
set_config 'dbms.connector.https.listen_address' 'a.b.c.d:333' neo4j.conf &&
set_config 'dbms.connector.https.enabled' 'true' neo4j.conf &&
test_expect_stdout_matching 'It is available at https://a.b.c.d:333/' run_daemon
"

test_expect_success "should write a specific message in HA mode" "
clear_config &&
set_config 'dbms.mode' 'HA' neo4j.conf &&
test_expect_stdout_matching 'This HA instance will be operational once it has joined the cluster' run_daemon
"

test_expect_success "should respect log directory configuration" "
clear_config &&
mkdir -p '$(neo4j_home)/other-log-dir' &&
set_config 'dbms.directories.logs' 'other-log-dir' neo4j.conf &&
run_daemon &&
Expand Down