Skip to content

Commit

Permalink
Remove site.psh
Browse files Browse the repository at this point in the history
Site.psh was another means of configuring the services and
service groups. That functionality for users can be more easily
provided by pdo-service-groups and pdo-[eps]service commands.

However, we still need the ability to reset the service and
groups databases for running tests. So we moved site.psh to
the tests directory and incorporated it into test execution.

Signed-off-by: Mic Bowman <[email protected]>
  • Loading branch information
cmickeyb committed Mar 21, 2024
1 parent 90468b1 commit fe74f29
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 166 deletions.
2 changes: 1 addition & 1 deletion build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ build-client : $(PYTHON_DIR)
# CLIENT_KEY_COUNT is the number of user keys to create
# For the test environment we create 10 by default
CLIENT_KEY_COUNT ?= 10
CLIENT_CONF_TEMPLATES = $(addprefix $(SCRIPTDIR)/template/, pcontract.toml site.psh)
CLIENT_CONF_TEMPLATES = $(addprefix $(SCRIPTDIR)/template/, pcontract.toml)
CLIENT_CONF_TARGET = $(DSTDIR)/opt/pdo/.client_configured

$(CLIENT_CONF_TARGET) : $(PYTHON_DIR) $(CLIENT_CONF_TEMPLATES)
Expand Down
6 changes: 3 additions & 3 deletions build/cmake/Test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ ENDFUNCTION()
# -----------------------------------------------------------------
# ADD_SYSTEM_TEST
# This function invokes a pdo-shell script on an optional set of
# parameters. The assumption is that the script loads site.psh to
# pick up the service configuration. TEST_SERVICE_HOST will be used
# to configure the services host in site.psh.
# parameters. The assumption is that site configuration has taken
# place outside the script (meaning the service data and service
# group databases are assumed to be up to date).
# -----------------------------------------------------------------
FUNCTION(ADD_SYSTEM_TEST contract)
CMAKE_PARSE_ARGUMENTS(ST "" "SCRIPT" "PARAMS" ${ARGN})
Expand Down
90 changes: 75 additions & 15 deletions build/tests/service-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,28 +102,77 @@ for v in $(seq 0 $((${port_count} - 1))) ; do
done

# -----------------------------------------------------------------
say run unit tests for eservice database
# these functions attemp to create a reproducible environment for
# each of the tests
# -----------------------------------------------------------------
function begin_test {
yell $@
try ${PDO_SOURCE_ROOT}/build/tests/site-configuration.psh ${PSHELL_OPTS}
}

function end_test {
yell end test

try pdo-service-db clear ${PSHELL_OPTS}
try pdo-service-groups clear ${PSHELL_OPTS}
}

# -----------------------------------------------------------------
# -----------------------------------------------------------------
begin_test run unit tests for eservice database

try ${PDO_SOURCE_ROOT}/build/tests/service-storage-test.psh \
${PSHELL_OPTS} \
--bind tmpfile ${ESDB_FILE}

say create the eservice database using database CLI
try pdo-service-db clear ${PSHELL_OPTS}
try pdo-service-groups clear

try pdo-service-db add --url http://${F_SERVICE_HOST}:7101 --name es7101 --type eservice ${PSHELL_OPTS}
try pdo-service-db add --url http://${F_SERVICE_HOST}:7102 --name es7102 --type eservice ${PSHELL_OPTS}
try pdo-service-db add --url http://${F_SERVICE_HOST}:7103 --name es7103 --type eservice ${PSHELL_OPTS}
try pdo-service-db add --url http://${F_SERVICE_HOST}:7104 --name es7104 --type eservice ${PSHELL_OPTS}
try pdo-service-db add --url http://${F_SERVICE_HOST}:7105 --name es7105 --type eservice ${PSHELL_OPTS}

end_test

# -----------------------------------------------------------------
say start storage service test
# ----------------------------------------------------------------
# ----------------------------------------------------------------
begin_test start storage service test

try pdo-test-storage ${LOCAL_OPTS} --url http://${F_SERVICE_HOST}:7201

end_test

# -----------------------------------------------------------------
say start request test
# -----------------------------------------------------------------
begin_test run unit tests for service groups database

try ${PDO_SOURCE_ROOT}/build/tests/service-groups-test.psh \
${PSHELL_OPTS} \
--bind tmpfile ${GROUPS_FILE}

say create the service and groups database using the groups CLI
try pdo-service-db clear ${PSHELL_OPTS}
try pdo-service-groups clear

try pdo-service-db add --url http://${F_SERVICE_HOST}:7101 --name es7101 --type eservice ${PSHELL_OPTS}
try pdo-service-db add --url http://${F_SERVICE_HOST}:7102 --name es7102 --type eservice ${PSHELL_OPTS}
try pdo-service-db add --url http://${F_SERVICE_HOST}:7103 --name es7103 --type eservice ${PSHELL_OPTS}
try pdo-service-db add --url http://${F_SERVICE_HOST}:7104 --name es7104 --type eservice ${PSHELL_OPTS}
try pdo-service-db add --url http://${F_SERVICE_HOST}:7105 --name es7105 --type eservice ${PSHELL_OPTS}

try pdo-eservice create --group test1
try pdo-eservice add --group test1 --url http://${F_SERVICE_HOST}:7101 http://${F_SERVICE_HOST}:7102
try pdo-eservice add --group test1 --name es7103 es7104

end_test

# -----------------------------------------------------------------
# -----------------------------------------------------------------
begin_test start request test

try pdo-test-request \
${NETWORK_OPTS} \
--config pcontract.toml \
Expand Down Expand Up @@ -163,70 +212,79 @@ for test_file in ${PDO_SOURCE_ROOT}/build/tests/${INTERPRETER_NAME}/*.json ; do
--logfile __screen__ --loglevel ${F_LOGLEVEL}
done

end_test

## -----------------------------------------------------------------
## -----------------------------------------------------------------
if [[ "$PDO_INTERPRETER" =~ ^"wawaka" ]]; then
yell start multi-user tests
begin_test start the multi-user test
try ${PDO_SOURCE_ROOT}/build/tests/multi-user.sh -h ${F_SERVICE_HOST} -l ${F_LEDGER_URL} --loglevel ${F_LOGLEVEL}
end_test
else
yell no multi-user test for ${PDO_INTERPRETER}
fi

## -----------------------------------------------------------------
yell test failure conditions to ensure they are caught
## -----------------------------------------------------------------
say create the contract
begin_test test failure conditions to ensure they are caught

say create the contract
declare CONTRACT_FILE=${PDO_HOME}/contracts/_mock-contract.b64
if [ ! -f ${CONTRACT_FILE} ]; then
die missing contract source file, ${CONTRACT_FILE}
fi
try ${PDO_HOME}/bin/pdo-create.psh \
${PSHELL_OPTS} \
--identity user1 --psgroup all --esgroup all --ssgroup all \
--client-identity user1 --psgroup all --esgroup all --ssgroup all \
--pdo_file ${SAVE_FILE} --source ${CONTRACT_FILE} --class mock-contract

say invalid method, this should fail
${PDO_HOME}/bin/pdo-invoke.psh \
${PSHELL_OPTS} \
--identity user1 --pdo_file ${SAVE_FILE} --method no-such-method
--client-identity user1 --pdo_file ${SAVE_FILE} --method no-such-method
if [ $? == 0 ]; then
die mock contract test succeeded though it should have failed
fi

say policy violation with identity, this should fail
${PDO_HOME}/bin/pdo-invoke.psh \
${PSHELL_OPTS} \
--identity user2 --pdo_file ${SAVE_FILE} --method get_value
--client-identity user2 --pdo_file ${SAVE_FILE} --method get_value
if [ $? == 0 ]; then
die mock contract test succeeded though it should have failed
fi

end_test

# -----------------------------------------------------------------
yell test pdo-shell
# -----------------------------------------------------------------
begin_test test pdo-shell

try ${PDO_SOURCE_ROOT}/build/tests/shell-test.psh \
${PSHELL_OPTS} \
--bind tmpfile ${GROUPS_FILE}
${PSHELL_OPTS}

end_test

# -----------------------------------------------------------------
# -----------------------------------------------------------------
if [[ "$PDO_INTERPRETER" =~ ^"wawaka" ]]; then
yell run system tests for contracts
begin_test run system tests for contracts

cd ${PDO_SOURCE_ROOT}/contracts/wawaka
try make system-test \
TEST_LOG_LEVEL=${F_LOGLEVEL} \
TEST_SERVICE_HOST=${F_SERVICE_HOST} \
TEST_LEDGER=${F_LEDGER_URL}
end_test
else
yell no system tests for "${PDO_INTERPRETER}"
fi

# -----------------------------------------------------------------
# -----------------------------------------------------------------
begin_test run tests for state replication

cd ${PDO_SOURCE_ROOT}/build
yell run tests for state replication
say start mock-contract test with replication 3 eservices 2 replicas needed before txn.

try pdo-test-request \
Expand All @@ -238,6 +296,8 @@ try pdo-test-request \
--logfile __screen__ --loglevel ${F_LOGLEVEL} --iterations 100 \
--num-provable-replicas 2 --availability-duration 100 --randomize-eservice

end_test

# -----------------------------------------------------------------
# -----------------------------------------------------------------
yell completed all service tests
Expand Down
Loading

0 comments on commit fe74f29

Please sign in to comment.