Skip to content

Commit

Permalink
Changes for the driver:
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pengfei0107 committed Aug 10, 2020
1 parent ca61000 commit b3c0f28
Show file tree
Hide file tree
Showing 23 changed files with 506 additions and 238 deletions.
44 changes: 35 additions & 9 deletions README-DEV.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ NoSQL Downloads <https://www.oracle.com/database/technologies/nosql-database-
server-downloads.html>`_ to download the on-premise product and proxy server.

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

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

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

1. Modify <path-to-repo>/test/parameters.py to suit your environment. The
comments in that file tells you how to modify the settings.
2. With the desired server running, start testing.
1. The <path-to-repo>/test/config.py is used to run the unit test against
Cloud Simulator, modify it to suit your environment. When config.py is
overwritten by other config*.py, config_cloudsim.py is used to run the
unit test against Cloud Simulator, modify it to suit your environment.
Then copy the content of config_onprem.py to config.py.
2. The <path-to-repo>/test/config_onprem.py is used to run the unit test
against on-premise proxy, modify it to suit your environment. Then copy
the content of config_onprem.py to config.py.

Notice that the comments in these config files tells you how to modify the
settings.

3. With the desired server running, start testing.

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

2. Modify <path-to-repo>/examples/parameters.py to suit your environment.
The comments in that file tells you how to modify the settings.
3. With the Cloud Simulator running, run a test
2. The <path-to-repo>/examples/config.py is used to run the example against
Cloud Simulator, modify it to suit your environment. When config.py is
overwritten by other config*.py, config_cloudsim.py is used to run the
unit test against Cloud Simulator, modify it to suit your environment.
Then copy the content of config_onprem.py to config.py.
3. The <path-to-repo>/examples/config_onprem.py is used to run the example
against on-premise proxy, modify it to suit your environment. Then copy
the content of config_onprem.py to config.py.
4. The <path-to-repo>/examples/config_cloud.py is used to run the example
against Cloud Service, modify it to suit your environment. Then copy the
content of config_onprem.py to config.py.

Notice that the comments in these config files tells you how to modify the
settings.

5. With the desired server running, run an example.

.. code-block:: pycon
Expand Down
10 changes: 5 additions & 5 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ the region **Regions.US_ASHBURN_1**. Information on regions can be found in
#
handle = NoSQLHandle(config)
See examples and test code for specific details. Both of these use
*parameters.py* files for configuration of required information.
See examples and test code for specific details. Both of these use config*.py
files for configuration of required information.

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

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

The Cloud Simulator does not require the credentials and authentication
information required by the Oracle NoSQL Database Cloud Service. The Cloud
Expand Down
23 changes: 23 additions & 0 deletions examples/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl/

#
# Parameters used by example code -- Cloud Simulator Configuration
#
# This file is configured for the examples to be run against a Cloud Simulator
# instance.
#
# The default settings below are sufficient if the Cloud Simulator has been
# started on the endpoint, localhost:8080, which is its default. If not, the
# parameters in this file should be changed as needed.
#

# The endpoint to use to connect to the service. This endpoint is for a Cloud
# Simulator running on its default port (8080) on the local machine.
endpoint = 'localhost:8080'

# The server type, please don't change it.
server_type = 'cloudsim'
74 changes: 74 additions & 0 deletions examples/config_cloud.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl/

#
# Parameters used by example code -- Oracle NoSQL Database Cloud Service
#
# This file is configured for the example to be run against Oracle NoSQL
# Database Cloud Service.
#
# To use Oracle Cloud Infrastructure(OCI) user principal verification. The
# default settings below are sufficient if ~/.oci/config is provided. To
# generate ~/.oci/config, it requires an Oracle Cloud account with a
# subscription to the Oracle NoSQL Database Cloud Service. Login OCI Console
# https://console.us-ashburn-1.oraclecloud.com. Then follow the steps below to
# get the required information:
#
# Step1: Generate a RSA key pair in PEM format (minimum 2048 bits).
# Step2: Upload the PEM public key and get the key's fingerprint. Click your
# username in the top-right corner of the console, click User Settings,
# click Add Public Key, paste the contents of the PEM public key in the
# dialog box and click Add. Then you can see the key's fingerprint is
# displayed under the public key.
# Step3: Get the tenancy OCID from the OCI Console on the Tenancy Details page.
# Open the navigation menu, under Governance and Administration, go to
# Administration and click Tenancy Details. The tenancy OCID is shown
# under Tenancy Information.
# Step4: Get the user's OCID from OCI Console on User Settings page. Open the
# Profile menu (User menu icon) and click User Settings. You can find the
# user's OCID is shown under User Information.
#
# Create ~/.oci/config, open the file in your text editor, add the following
# information obtained from the previous steps. This file should be secured so
# that only the application has access to read it.
#
# [DEFAULT]
# tenancy=<your-tenancy-id-from-oci-console>
# user=<<your-user-id-from-oci-console>>
# fingerprint=<fingerprint-of-your-public-key>
# key_file=<path-to-your-private-key-file>
# pass_phrase=<pass-phrase-to-your-private-key-file>
#
# If you want to put ~/.oci/config to somewhere else, set the "credentials_file"
# parameter to point to the config file you just created.
#
# To use Oracle Cloud Infrastructure(OCI) instance principal verification. It
# requires an Oracle Cloud account with a subscription to the Oracle NoSQL
# Database Cloud Service and a OCI machine. You need to run the example on the
# OCI machine without the credentials file. Set the parameter "principal" to
# "instance principal".
#
# To use Oracle Cloud Infrastructure(OCI) resource principal verification. Set
# the parameter "principal" to "resource principal", then execute the example
# as a function using https://github.com/fnproject/fn
#

from os import path

# A endpoint string, a region id or a Region, for example:
# 'nosql.us-ashburn-1.oci.oraclecloud.com', 'us-ashburn-1' or
# Regions.US_ASHBURN_1
endpoint = 'us-ashburn-1'

# The server type, please don't change it.
server_type = 'cloud'

# Please use one of 'user principal', 'instance principal' or
# 'resource principal'.
principal = 'user principal'

# Absolute path to credentials file, default path is "~/.oci/config"
credentials_file = path.join(path.expanduser('~'), '.oci', 'config')
25 changes: 25 additions & 0 deletions examples/config_cloudsim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl/

#
# Parameters used by example code -- Cloud Simulator Configuration
#
# This file is configured for the examples to be run against a Cloud Simulator
# instance.
#
# The default settings below are sufficient if the Cloud Simulator has been
# started on the endpoint, localhost:8080, which is its default. If not, the
# parameters in this file should be changed as needed. This is a backup of
# config.py, when config.py is overwritten by other config*.py, the default
# config.py of Cloud Simulator is back up in this file.
#

# The endpoint to use to connect to the service. This endpoint is for a Cloud
# Simulator running on its default port (8080) on the local machine.
endpoint = 'localhost:8080'

# The server type, please don't change it.
server_type = 'cloudsim'
36 changes: 36 additions & 0 deletions examples/config_onprem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl/
#

#
# Parameters used by example code -- On-premise Oracle NoSQL database
#
# This file is configured for the example to be run against a On-prem Oracle
# NoSQL database. Please start the database and proxy first.
#
# The default settings below are sufficient if the On-prem proxy has been
# started on the endpoint, localhost:8080, with security disable. If not, the
# parameters in this file should be changed as needed.
#

# The endpoint to use to connect to the service. This endpoint is for a on-prem
# proxy started by the customer. Use 'http' protocol for non-secure database and
# 'https' for secure database.
endpoint = 'http://localhost:8080'

# The server type, please don't change it.
server_type = 'onprem'

# Please set the following parameters if running against secure .

# SSL CA certificates. Configure it to specify CA certificates or set
# REQUESTS_CA_BUNDLE environment variable when running against a secure
# database. For non-secure database, use the default None.
ca_certs = None
# User name for secure database, for non-secure database, use the default None.
user_name = None
# Password for secure database, for non-secure database, use the default None.
user_password = None
10 changes: 5 additions & 5 deletions examples/multi_data_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# cloud service, against the Cloud Simulator, or against an on-premise Oracle
# NoSQL database.
#
# See the comments in parameters.py about running in different environments. By
# See the comments in config*.py about running in different environments. By
# default the example is ready to run against the Cloud Simulator.
#
# The example demonstrates:
Expand All @@ -33,20 +33,20 @@
# It requires Java
# 4. If running against the Oracle NoSQL Database Cloud Service an account must
# be used along with additional authentication information. See instructions in
# the comments in parameters.py
# the comments in config_cloud.py.
#
# To run:
# 1. set PYTHONPATH to include the parent directory of ../src/borneo
# 2. modify variables in parameters.py for the runtime environment after
# reading instructions in the comments.
# 2. modify variables in config*.py for the runtime environment after reading
# instructions in the comments.
# 3. run
# $ python multi_data.py
#

import traceback

from borneo import (
MultiDeleteRequest, PrepareRequest, PutRequest, QueryRequest, TableLimits,
MultiDeleteRequest, PrepareRequest, PutRequest, QueryRequest, TableLimits,
TableRequest, WriteMultipleRequest)

from parameters import drop_table, table_name, tenant_id
Expand Down
Loading

0 comments on commit b3c0f28

Please sign in to comment.