Wednesday, November 27, 2019

How to test MapR Data Access Gateway

Goal:

This article explains the steps on how to test MapR Data Access Gateway.

Env:

MapR 6.1 (secured)

Solution:

1. Python OJAI client

Follow the documentation https://mapr.com/docs/61/MapR-DB/JSON_DB/UsingPythonOJAIClient.html to install python library "maprdb-python-client".
Below is a sample python program named "test.py" to scan the column "_id" of maprdb table "/tmp/test":
from mapr.ojai.storage.ConnectionFactory import ConnectionFactory
connection_str = "v1.poc.com:5678?auth=basic;user=mapr;password=mapr;" \
    "ssl=true;" \
    "sslCA=./ssl_truststore.pem;" \
    "sslTargetNameOverride=v1.poc.com"
connection = ConnectionFactory.get_connection(connection_str=connection_str)                              
store = connection.get_store('/tmp/test')
query = {"$select": ["_id"]}
options = {
  'ojai.mapr.query.result-as-document': True
}
query_result = store.find(query, options=options)
for doc in query_result:
    print(doc.as_dictionary())
connection.close()    

Note: make sure a valid ssl_truststore.pem is located here.
Run it:
$ python test.py
{'_id': '0002'}

2. REST OJAI API

Refer to documentation https://mapr.com/docs/61/MapR-DB/JSON_DB/UsingMapRDBJSONRESTAPI.html
Below examples are using basic authentication.

2.a insecure mode(-k)

curl -X GET -k \
'https://v1.poc.com:8243/api/v2/table/%2Ftmp%2Ftest%2F' \
-u mapr:mapr

2.b using SSL certificates

curl --cacert ./ssl_truststore.pem -X GET \
'https://v1.poc.com:8243/api/v2/table/%2Ftmp%2Ftest%2F' \
-u mapr:mapr

Troubleshooting:

If there is any issue with SSL/TLS/Certificates, use below commands to troubleshoot.
From Data Access Gateway node: 
keytool -list -keystore /opt/mapr/conf/ssl_keystore -v
keytool -list -v -keystore /opt/mapr/conf/ssl_keystore.p12 -storetype PKCS12
keytool -list -keystore /opt/mapr/conf/ssl_truststore -v
From the client node:
openssl s_client -connect v1.poc.com:5678 -CAfile /path/on/client/node/ssl_truststore.pem -showcerts

6 comments:

  1. Replies
    1. The article gives a practical way to validate MapR Data Access Gateway connectivity in a secured MapR 6.1 environment. I found the side-by-side testing approaches particularly useful because they cover both client-library access and direct REST requests, while the SSL troubleshooting commands help isolate certificate or truststore issues.

      The Python OJAI example is especially clear because it shows the complete flow from creating the ConnectionFactory connection to retrieving the /tmp/test store and scanning the _id field. This makes the example relevant for anyone applying Python Online Training concepts to database connectivity and client-side testing.

      Delete
    2. The REST OJAI section also highlights an important distinction between using -k for insecure certificate verification and supplying --cacert with a trusted certificate. That practical comparison fits well with RESTful API Training, particularly when testing secured REST endpoints.

      Delete
    3. I also liked the troubleshooting section because the keytool and openssl s_client commands provide concrete ways to inspect keystores, truststores, and the server certificate chain. These are useful operational skills within Data Engineering Training when working with secured data-access services.

      Delete

Popular Posts