Skip to content

Commit b3c0f28

Browse files
committed
Changes for the driver:
1. Remove .pem key used by unit test. 2. Add new regions ap-chuncheon-1 and us-sanjose-1. 3. Fix the test issue of ListTablesRequest when the environment is not clean. 4. Change the driver to use different config file for different servers(e.g. config.py, config_onprem.py, config_cloud.py). 5. Change the test to deal with different cloudsim and on-prem version numbers. 6. Some doc change.
1 parent ca61000 commit b3c0f28

23 files changed

+506
-238
lines changed

README-DEV.rst

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ NoSQL Downloads <https://www.oracle.com/database/technologies/nosql-database-
3333
server-downloads.html>`_ to download the on-premise product and proxy server.
3434

3535
Tests and examples have settings that can be changed based on environment. Test
36-
settings are in test/parameters.py. Refer to the comments in the tests and
37-
examples for details. The default values will use a Cloud Simulator instance
38-
that is running on its default settings of localhost:8080.
36+
settings are in test/config*.py. Refer to the comments in the tests and examples
37+
for details. The default test/config.py and test/config_cloudsim.py will use a
38+
Cloud Simulator instance that is running on its default settings of
39+
localhost:8080, config_cloudsim.py is a backup of config.py, when config.py is
40+
overwritten by other config*.py, the default config.py of Cloud Simulator is
41+
back up in config_cloudsim.py.
3942

4043
All tests require that your PYTHONPATH be set to the development tree:
4144

@@ -53,9 +56,19 @@ Or use the API :func:`borneo.NoSQLHandleConfig.set_ssl_ca_certs` to specify it.
5356
Run Unit Tests
5457
--------------
5558

56-
1. Modify <path-to-repo>/test/parameters.py to suit your environment. The
57-
comments in that file tells you how to modify the settings.
58-
2. With the desired server running, start testing.
59+
1. The <path-to-repo>/test/config.py is used to run the unit test against
60+
Cloud Simulator, modify it to suit your environment. When config.py is
61+
overwritten by other config*.py, config_cloudsim.py is used to run the
62+
unit test against Cloud Simulator, modify it to suit your environment.
63+
Then copy the content of config_onprem.py to config.py.
64+
2. The <path-to-repo>/test/config_onprem.py is used to run the unit test
65+
against on-premise proxy, modify it to suit your environment. Then copy
66+
the content of config_onprem.py to config.py.
67+
68+
Notice that the comments in these config files tells you how to modify the
69+
settings.
70+
71+
3. With the desired server running, start testing.
5972

6073
.. code-block:: pycon
6174
@@ -79,9 +92,22 @@ Run Examples
7992
$ export PYTHONPATH=<path-to-nosql-python-sdk>/nosql-python-sdk/src:\
8093
$PYTHONPATH
8194

82-
2. Modify <path-to-repo>/examples/parameters.py to suit your environment.
83-
The comments in that file tells you how to modify the settings.
84-
3. With the Cloud Simulator running, run a test
95+
2. The <path-to-repo>/examples/config.py is used to run the example against
96+
Cloud Simulator, modify it to suit your environment. When config.py is
97+
overwritten by other config*.py, config_cloudsim.py is used to run the
98+
unit test against Cloud Simulator, modify it to suit your environment.
99+
Then copy the content of config_onprem.py to config.py.
100+
3. The <path-to-repo>/examples/config_onprem.py is used to run the example
101+
against on-premise proxy, modify it to suit your environment. Then copy
102+
the content of config_onprem.py to config.py.
103+
4. The <path-to-repo>/examples/config_cloud.py is used to run the example
104+
against Cloud Service, modify it to suit your environment. Then copy the
105+
content of config_onprem.py to config.py.
106+
107+
Notice that the comments in these config files tells you how to modify the
108+
settings.
109+
110+
5. With the desired server running, run an example.
85111

86112
.. code-block:: pycon
87113

docs/installation.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ the region **Regions.US_ASHBURN_1**. Information on regions can be found in
254254
#
255255
handle = NoSQLHandle(config)
256256
257-
See examples and test code for specific details. Both of these use
258-
*parameters.py* files for configuration of required information.
257+
See examples and test code for specific details. Both of these use config*.py
258+
files for configuration of required information.
259259

260260
=================================
261261
Configure for the Cloud Simulator
@@ -270,9 +270,9 @@ topic/lookup?ctx=en/cloud/paas/nosql-cloud&id=CSNSD-GUID-3E11C056-B144-4EEA-8224
270270
-37F4C3CB83F6>`_ to download and start the Cloud Simulator.
271271

272272
1. Download and start the Cloud Simulator
273-
2. Follow instructions in the examples/parameters.py file for connecting
274-
examples to the Cloud Simulator. By default that file is configured to
275-
communicate with the Cloud Simulator, using default configuration.
273+
2. Follow instructions in the examples/config.py file for connecting examples
274+
to the Cloud Simulator. By default that file is configured to communicate
275+
with the Cloud Simulator, using default configuration.
276276

277277
The Cloud Simulator does not require the credentials and authentication
278278
information required by the Oracle NoSQL Database Cloud Service. The Cloud

examples/config.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
3+
#
4+
# Licensed under the Universal Permissive License v 1.0 as shown at
5+
# https://oss.oracle.com/licenses/upl/
6+
7+
#
8+
# Parameters used by example code -- Cloud Simulator Configuration
9+
#
10+
# This file is configured for the examples to be run against a Cloud Simulator
11+
# instance.
12+
#
13+
# The default settings below are sufficient if the Cloud Simulator has been
14+
# started on the endpoint, localhost:8080, which is its default. If not, the
15+
# parameters in this file should be changed as needed.
16+
#
17+
18+
# The endpoint to use to connect to the service. This endpoint is for a Cloud
19+
# Simulator running on its default port (8080) on the local machine.
20+
endpoint = 'localhost:8080'
21+
22+
# The server type, please don't change it.
23+
server_type = 'cloudsim'

examples/config_cloud.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#
2+
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
3+
#
4+
# Licensed under the Universal Permissive License v 1.0 as shown at
5+
# https://oss.oracle.com/licenses/upl/
6+
7+
#
8+
# Parameters used by example code -- Oracle NoSQL Database Cloud Service
9+
#
10+
# This file is configured for the example to be run against Oracle NoSQL
11+
# Database Cloud Service.
12+
#
13+
# To use Oracle Cloud Infrastructure(OCI) user principal verification. The
14+
# default settings below are sufficient if ~/.oci/config is provided. To
15+
# generate ~/.oci/config, it requires an Oracle Cloud account with a
16+
# subscription to the Oracle NoSQL Database Cloud Service. Login OCI Console
17+
# https://console.us-ashburn-1.oraclecloud.com. Then follow the steps below to
18+
# get the required information:
19+
#
20+
# Step1: Generate a RSA key pair in PEM format (minimum 2048 bits).
21+
# Step2: Upload the PEM public key and get the key's fingerprint. Click your
22+
# username in the top-right corner of the console, click User Settings,
23+
# click Add Public Key, paste the contents of the PEM public key in the
24+
# dialog box and click Add. Then you can see the key's fingerprint is
25+
# displayed under the public key.
26+
# Step3: Get the tenancy OCID from the OCI Console on the Tenancy Details page.
27+
# Open the navigation menu, under Governance and Administration, go to
28+
# Administration and click Tenancy Details. The tenancy OCID is shown
29+
# under Tenancy Information.
30+
# Step4: Get the user's OCID from OCI Console on User Settings page. Open the
31+
# Profile menu (User menu icon) and click User Settings. You can find the
32+
# user's OCID is shown under User Information.
33+
#
34+
# Create ~/.oci/config, open the file in your text editor, add the following
35+
# information obtained from the previous steps. This file should be secured so
36+
# that only the application has access to read it.
37+
#
38+
# [DEFAULT]
39+
# tenancy=<your-tenancy-id-from-oci-console>
40+
# user=<<your-user-id-from-oci-console>>
41+
# fingerprint=<fingerprint-of-your-public-key>
42+
# key_file=<path-to-your-private-key-file>
43+
# pass_phrase=<pass-phrase-to-your-private-key-file>
44+
#
45+
# If you want to put ~/.oci/config to somewhere else, set the "credentials_file"
46+
# parameter to point to the config file you just created.
47+
#
48+
# To use Oracle Cloud Infrastructure(OCI) instance principal verification. It
49+
# requires an Oracle Cloud account with a subscription to the Oracle NoSQL
50+
# Database Cloud Service and a OCI machine. You need to run the example on the
51+
# OCI machine without the credentials file. Set the parameter "principal" to
52+
# "instance principal".
53+
#
54+
# To use Oracle Cloud Infrastructure(OCI) resource principal verification. Set
55+
# the parameter "principal" to "resource principal", then execute the example
56+
# as a function using https://github.com/fnproject/fn
57+
#
58+
59+
from os import path
60+
61+
# A endpoint string, a region id or a Region, for example:
62+
# 'nosql.us-ashburn-1.oci.oraclecloud.com', 'us-ashburn-1' or
63+
# Regions.US_ASHBURN_1
64+
endpoint = 'us-ashburn-1'
65+
66+
# The server type, please don't change it.
67+
server_type = 'cloud'
68+
69+
# Please use one of 'user principal', 'instance principal' or
70+
# 'resource principal'.
71+
principal = 'user principal'
72+
73+
# Absolute path to credentials file, default path is "~/.oci/config"
74+
credentials_file = path.join(path.expanduser('~'), '.oci', 'config')

examples/config_cloudsim.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
3+
#
4+
# Licensed under the Universal Permissive License v 1.0 as shown at
5+
# https://oss.oracle.com/licenses/upl/
6+
7+
#
8+
# Parameters used by example code -- Cloud Simulator Configuration
9+
#
10+
# This file is configured for the examples to be run against a Cloud Simulator
11+
# instance.
12+
#
13+
# The default settings below are sufficient if the Cloud Simulator has been
14+
# started on the endpoint, localhost:8080, which is its default. If not, the
15+
# parameters in this file should be changed as needed. This is a backup of
16+
# config.py, when config.py is overwritten by other config*.py, the default
17+
# config.py of Cloud Simulator is back up in this file.
18+
#
19+
20+
# The endpoint to use to connect to the service. This endpoint is for a Cloud
21+
# Simulator running on its default port (8080) on the local machine.
22+
endpoint = 'localhost:8080'
23+
24+
# The server type, please don't change it.
25+
server_type = 'cloudsim'

examples/config_onprem.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
3+
#
4+
# Licensed under the Universal Permissive License v 1.0 as shown at
5+
# https://oss.oracle.com/licenses/upl/
6+
#
7+
8+
#
9+
# Parameters used by example code -- On-premise Oracle NoSQL database
10+
#
11+
# This file is configured for the example to be run against a On-prem Oracle
12+
# NoSQL database. Please start the database and proxy first.
13+
#
14+
# The default settings below are sufficient if the On-prem proxy has been
15+
# started on the endpoint, localhost:8080, with security disable. If not, the
16+
# parameters in this file should be changed as needed.
17+
#
18+
19+
# The endpoint to use to connect to the service. This endpoint is for a on-prem
20+
# proxy started by the customer. Use 'http' protocol for non-secure database and
21+
# 'https' for secure database.
22+
endpoint = 'http://localhost:8080'
23+
24+
# The server type, please don't change it.
25+
server_type = 'onprem'
26+
27+
# Please set the following parameters if running against secure .
28+
29+
# SSL CA certificates. Configure it to specify CA certificates or set
30+
# REQUESTS_CA_BUNDLE environment variable when running against a secure
31+
# database. For non-secure database, use the default None.
32+
ca_certs = None
33+
# User name for secure database, for non-secure database, use the default None.
34+
user_name = None
35+
# Password for secure database, for non-secure database, use the default None.
36+
user_password = None

examples/multi_data_ops.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# cloud service, against the Cloud Simulator, or against an on-premise Oracle
1212
# NoSQL database.
1313
#
14-
# See the comments in parameters.py about running in different environments. By
14+
# See the comments in config*.py about running in different environments. By
1515
# default the example is ready to run against the Cloud Simulator.
1616
#
1717
# The example demonstrates:
@@ -33,20 +33,20 @@
3333
# It requires Java
3434
# 4. If running against the Oracle NoSQL Database Cloud Service an account must
3535
# be used along with additional authentication information. See instructions in
36-
# the comments in parameters.py
36+
# the comments in config_cloud.py.
3737
#
3838
# To run:
3939
# 1. set PYTHONPATH to include the parent directory of ../src/borneo
40-
# 2. modify variables in parameters.py for the runtime environment after
41-
# reading instructions in the comments.
40+
# 2. modify variables in config*.py for the runtime environment after reading
41+
# instructions in the comments.
4242
# 3. run
4343
# $ python multi_data.py
4444
#
4545

4646
import traceback
4747

4848
from borneo import (
49-
MultiDeleteRequest, PrepareRequest, PutRequest, QueryRequest, TableLimits,
49+
MultiDeleteRequest, PrepareRequest, PutRequest, QueryRequest, TableLimits,
5050
TableRequest, WriteMultipleRequest)
5151

5252
from parameters import drop_table, table_name, tenant_id

0 commit comments

Comments
 (0)