Skip to content

Commit

Permalink
updated readme to match new config actions
Browse files Browse the repository at this point in the history
fixed problem with curl and too many /// in URLs for testing purposes
added better version compare function to cope with java version
  • Loading branch information
ogmueller committed Sep 29, 2018
1 parent 3603b5e commit cb9ab0d
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 72 deletions.
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,31 +260,34 @@ Just typing `ineo` you can get a brief description of every Ineo command.
```
$ ineo help

USAGE:
ineo <command> [options] [<arguments>]
USAGE:
ineo <command> [options] [<arguments>]

COMMANDS:

COMMANDS:
create Create a new instance with a specific <name>
set-port Change the port of a specific instance <name>
versions Show the Neo4j versions available for installation
instances Show the information about installed instances

create Create a new instance with a specific <name>
set-port Change the port of a specific instance <name>
versions Show the Neo4j versions available for installing
instances Show the information about the installed instances
start Start Neo4j instances
stop Stop Neo4j instances
restart Restart Neo4j instances
status Show instances status
shell Start the shell for a Neo4j instance
console Start a Neo4j instance in mode console

start Start Neo4j instances
stop Stop Neo4j instances
restart Restart Neo4j instances
status Show instances status
shell Start the shell for a Neo4j instance
console Start a Neo4j instance in mode console
set-config Change settings in configuration file
get-config Read settings from configuration file

delete-db Delete all data of a specific instance <name>
destroy Remove a specific instance <name>
delete-db Delete all data of a specific instance <name>
destroy Remove a specific instance <name>

install Install ineo
update Update ineo
uninstall Uninstall ineo
install Install ineo
update Update ineo
uninstall Uninstall ineo

help Show this help or help for specific [command]
help Show this help or help for specific [command]
```
### Help for a specific command
Expand Down
6 changes: 3 additions & 3 deletions ineo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# ineo 1.1.0 - Neo4j Instances Manager
# Copyright (C) 2015-2018 Carlos Forero
#!/bin/bash
# ineo 1.1.0 - Neo4j Instances Manager
# Copyright (C) 2015-2018 Carlos Forero
#
# http://github.com/carlosforero/ineo
#
Expand Down
134 changes: 84 additions & 50 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,85 @@ BOLD='\033[1m'
# No Format
NF='\033[0m'

# ==============================================================================
# HELPER FUNCTIONS
# ==============================================================================

function get_running_message {
local version=$1
local instance=$2
local pid=$3
local major_version_number=${version%%.*}

if [ $major_version_number -lt 3 ]; then
printf \
"
status '$instance'
Neo4j Server is running at pid $pid
"
else
printf \
"
status '$instance'
Neo4j is running at pid $pid
"
fi
}

function get_not_running_message {
local version=$1
local instance=$2
local major_version_number=${version%%.*}

if [ $major_version_number -lt 3 ]; then
printf \
"
status '$instance'
Neo4j Server is not running
"
else
printf \
"
status '$instance'
Neo4j is not running
"
fi
}

# compare two version strings
# return values are:
# -1 operator <
# 0 operator =
# 1 operator >
function compare_version () {
if [[ "$1" == "$2" ]]; then
printf 0
return
else
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++)); do
if [[ -z ${ver2[i]} ]]; then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]})); then
printf 1
return
fi
if ((10#${ver1[i]} < 10#${ver2[i]})); then
printf -1
return
fi
done
fi
printf 0
}

# ==============================================================================
# PROVISION
# ==============================================================================
Expand Down Expand Up @@ -86,7 +165,7 @@ fi
if [ ${versions[0]} == 'all' ]; then
# check current java version and select "all" version appropriately
java_version=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2)
if [[ "${java_version%*.*}" < "1.8" ]]; then
if [[ $(compare_version "${java_version%*.*}" "1.8") == -1 ]]; then
versions=(1.9.9 2.3.6 3.0.3 3.3.1)
else
# neo4j 1.9.x is not compatible with java >= 1.8
Expand Down Expand Up @@ -140,8 +219,8 @@ set -e
# Set the variables to create instances
# ------------------------------------------------------------------------------

export NEO4J_HOSTNAME="file:///$(pwd)/fake_neo4j_host"
export INEO_HOSTNAME="file:///$(pwd)/fake_ineo_host"
export NEO4J_HOSTNAME="file://$(pwd)/fake_neo4j_host"
export INEO_HOSTNAME="file://$(pwd)/fake_ineo_host"
export INEO_HOME="$(pwd)/ineo_for_test"

# ==============================================================================
Expand Down Expand Up @@ -190,51 +269,6 @@ function setup {
assert_raises "test -d ineo_for_test" 1
}

# ==============================================================================
# HELPER FUNCTIONS
# ==============================================================================

function get_running_message {
local version=$1
local instance=$2
local pid=$3
local major_version_number=${version%%.*}

if [ $major_version_number -lt 3 ]; then
printf \
"
status '$instance'
Neo4j Server is running at pid $pid
"
else
printf \
"
status '$instance'
Neo4j is running at pid $pid
"
fi
}

function get_not_running_message {
local version=$1
local instance=$2
local major_version_number=${version%%.*}

if [ $major_version_number -lt 3 ]; then
printf \
"
status '$instance'
Neo4j Server is not running
"
else
printf \
"
status '$instance'
Neo4j is not running
"
fi
}

# ==============================================================================
# TEST INSTALL
# ==============================================================================
Expand Down Expand Up @@ -813,7 +847,7 @@ CreateAnInstanceWithABadTarAndTryAgainWithDOption() {
$command_truncate -s20MB bad_tar_for_test/neo4j-community-${LAST_VERSION}-unix.tar.gz

# Change the NEO4J_HOSTNAME for test to download the bad tar
export NEO4J_HOSTNAME="file:///$(pwd)/bad_tar_for_test"
export NEO4J_HOSTNAME="file://$(pwd)/bad_tar_for_test"

# Make an installation
assert_raises "./ineo install -d $(pwd)/ineo_for_test" 0
Expand Down Expand Up @@ -853,7 +887,7 @@ CreateAnInstanceWithABadTarAndTryAgainWithDOption() {
assert_raises "test -f $(pwd)/ineo_for_test/instances/twitter/bin/neo4j" 0

# Restore the correct NEO4J_HOSTNAME for test
export NEO4J_HOSTNAME="file:///$(pwd)/fake_neo4j_host"
export NEO4J_HOSTNAME="file://$(pwd)/fake_neo4j_host"

assert_end CreateAnInstanceWithABadTarAndTryAgainWithDOption
}
Expand Down

0 comments on commit cb9ab0d

Please sign in to comment.