Skip to content

Commit 423a3b8

Browse files
cmickeybprakashngit
authored andcommitted
Move eservice database creation & update to site.psh.
A small change to the the eservice command to load the datatbase makes it possible to create and update the eservice database directly from the site.psh script. This should simplify creating the database. Note that the site.psh is set up for the current standard test environment. It should be customized with any site-specific changes. Signed-off-by: Mic Bowman <[email protected]>
1 parent 06d05cf commit 423a3b8

File tree

5 files changed

+35
-31
lines changed

5 files changed

+35
-31
lines changed

build/opt/pdo/etc/template/site.psh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,24 @@ if --null "${data}"
1919
exit
2020
fi
2121

22-
set -q --conditional -s dbfile -v ${data}/eservice-db.json
23-
eservice_db load --database ${dbfile}
22+
## load the local database if it exists
23+
set -q --conditional -s dbfile --state Service EnclaveServiceDatabaseFile
24+
25+
## this returns false of the database file does not exist
26+
## we can use this later to save the updates
27+
eservice_db load --database ${dbfile} -s _database_exists_
28+
29+
## make sure the minimal set of enclave services is included
30+
eservice_db add --url http://localhost:7101 --name es7101
31+
eservice_db add --url http://localhost:7102 --name es7102
32+
eservice_db add --url http://localhost:7103 --name es7103
33+
eservice_db add --url http://localhost:7104 --name es7104
34+
eservice_db add --url http://localhost:7105 --name es7105
35+
36+
if -e ${_database_exists_} False
37+
eservice_db save --database ${dbfile}
38+
echo eservice database updated
39+
fi
2440

2541
## default pservice group
2642
pservice add --url http://localhost:7001
@@ -56,8 +72,8 @@ eservice --group e4 add --url http://localhost:7104 http://localhost:7105 http:/
5672
eservice --group e4 use --url http://localhost:7104
5773

5874
## eservice group e5
59-
eservice --group e4 add --url http://localhost:7105 http://localhost:7101 http://localhost:7102
60-
eservice --group e4 use --url http://localhost:7105
75+
eservice --group e5 add --url http://localhost:7105 http://localhost:7101 http://localhost:7102
76+
eservice --group e5 use --url http://localhost:7105
6177

6278
## eservice group all
6379
eservice --group all add --url http://localhost:7101 http://localhost:7102 http://localhost:7103 http://localhost:7104 http://localhost:7105

client/pdo/client/controller/commands/eservice_db.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def command_eservice_db(state, bindings, pargs) :
5353

5454
load_parser = subparsers.add_parser('load', description='load an eservice database')
5555
load_parser.add_argument('--database', help='Name of the eservice database to use', type=str, required=True)
56+
load_parser.add_argument('-s', '--symbol', help='binding symbol for the result', type=str)
5657
merge_group = load_parser.add_mutually_exclusive_group(required=False)
5758
merge_group.add_argument('--merge', help='Merge new database with current db', dest='merge', action='store_true')
5859
merge_group.add_argument('--no-merge', help='Overwrite current db with new database', dest='merge', action='store_false')
@@ -64,6 +65,7 @@ def command_eservice_db(state, bindings, pargs) :
6465

6566
save_parser = subparsers.add_parser('save', description='save the current eservice database')
6667
save_parser.add_argument('--database', help='Name of the eservice database to use', type=str, required=True)
68+
save_parser.add_argument('-s', '--symbol', help='binding symbol for the result', type=str)
6769

6870
options = parser.parse_args(pargs)
6971

@@ -118,15 +120,21 @@ def command_eservice_db(state, bindings, pargs) :
118120
return
119121

120122
if options.command == 'load' :
121-
eservice_db.load_database(options.database, options.merge)
123+
result = eservice_db.load_database(options.database, options.merge)
124+
if options.symbol :
125+
bindings.bind(options.symbol, result)
126+
122127
return
123128

124129
if options.command == 'remove' :
125130
eservice_db.remove_by_name(name=options.name)
126131
return
127132

128133
if options.command == 'save' :
129-
eservice_db.save_database(options.database, True)
134+
result = eservice_db.save_database(options.database, True)
135+
if options.symbol :
136+
bindings.bind(options.symbol, result)
137+
130138
return
131139

132140
raise Exception('unknown subcommand')

contracts/wawaka/Makefile

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ ifndef PDO_INSTALL_ROOT
1616
$(error Incomplete configuration, PDO_INSTALL_ROOT is not defined)
1717
endif
1818

19-
ifndef PDO_INTERPRETER
20-
$(error Incomplete configuration, PDO_INTERPRETER is not defined)
19+
ifndef PDO_HOME
20+
$(error Incomplete configuration, PDO_HOME is not defined)
2121
endif
2222

2323
SCRIPTDIR ?= $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
@@ -54,17 +54,7 @@ debug :
5454
test : install interface-test interpreter-test memory-test mock-contract-test
5555

5656
# this is the system test target, these tests require an eservice
57-
system-test : install eservice-db attestation-test kv-test
58-
59-
ESERVICE_DB=$(DATA_DIR)/eservice-test-db.json
60-
eservice-db:
61-
@ . $(abspath $(DSTDIR)/bin/activate) && \
62-
pdo-eservicedb --loglevel $(TEST_LOG_LEVEL) -d $(ESERVICE_DB) reset --create && \
63-
pdo-eservicedb --loglevel $(TEST_LOG_LEVEL) -d $(ESERVICE_DB) add -u http://localhost:7101 -n es7101 && \
64-
pdo-eservicedb --loglevel $(TEST_LOG_LEVEL) -d $(ESERVICE_DB) add -u http://localhost:7102 -n es7102 && \
65-
pdo-eservicedb --loglevel $(TEST_LOG_LEVEL) -d $(ESERVICE_DB) add -u http://localhost:7103 -n es7103 && \
66-
pdo-eservicedb --loglevel $(TEST_LOG_LEVEL) -d $(ESERVICE_DB) add -u http://localhost:7104 -n es7104 && \
67-
pdo-eservicedb --loglevel $(TEST_LOG_LEVEL) -d $(ESERVICE_DB) add -u http://localhost:7105 -n es7105
57+
system-test : install attestation-test kv-test
6858

6959
interface-test:
7060
@echo run test: $@
@@ -99,15 +89,13 @@ attestation-test:
9989
@ . $(abspath $(DSTDIR)/bin/activate) && \
10090
cd attestation-test && \
10191
scripts/attestation-test.psh --loglevel $(TEST_LOG_LEVEL) --logfile $(TEST_LOG_FILE) \
102-
-m eservice_dbfile $(ESERVICE_DB) \
10392
-m test_data $(SCRIPTDIR)/attestation-test/scripts
10493

10594
kv-test: kv-test/plugins/kv-test.py kv-test/scripts/kv-test.psh
10695
@echo run test: $@
10796
@ . $(abspath $(DSTDIR)/bin/activate) && \
10897
cd kv-test && \
109-
scripts/kv-test.psh --loglevel $(TEST_LOG_LEVEL) --logfile $(TEST_LOG_FILE) \
110-
-m eservice_dbfile $(ESERVICE_DB)
98+
scripts/kv-test.psh --loglevel $(TEST_LOG_LEVEL) --logfile $(TEST_LOG_FILE)
11199

112100
install : build $(PLUGIN_SOURCE) $(SCRIPT_SOURCE)
113101
@echo install contracts

contracts/wawaka/attestation-test/scripts/attestation-test.psh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ set -q --conditional -s test_data -v ${data}
2222
set -q --conditional -s _contracts_ -v ${home}/contracts
2323
set -q --conditional -s _plugins_ -v ${_contracts_}/plugins
2424

25-
## load the eservice database
26-
set -q --conditional -s eservice_dbfile -v ${data}/eservice-test-db.json
27-
eservice_db load --database ${eservice_dbfile}
28-
29-
## load the eservice and pservice groups for the site
25+
## load the eservice and pservice groups and databases for the site
3026
script -f ${home}/etc/site.psh
3127

3228
## some definitions to make it easier to display text

contracts/wawaka/kv-test/scripts/kv-test.psh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ set -q --conditional -s test_data -v ${data}
2222
set -q --conditional -s _contracts_ -v ${home}/contracts
2323
set -q --conditional -s _plugins_ -v ${_contracts_}/plugins
2424

25-
## load the eservice database
26-
set -q --conditional -s eservice_dbfile -v ${data}/eservice-test-db.json
27-
eservice_db load --database ${eservice_dbfile}
28-
2925
## load the eservice and pservice groups for the site
3026
script -f ${home}/etc/site.psh
3127

0 commit comments

Comments
 (0)