NuoDB REST Service Test Helper
Pre-releaseREST service test helper
This is a package that includes a development version of the REST service JAR that includes support for running a CRUD-only Kubernetes API server, along with a mock controller that simulates reconciliation behavior of the NuoDB DBaaS Operator.
To use this, download the attached test-helper.tgz
artifact, unpack, and run the contained setup-rest.sh
script:
tar -xf test-helper.tgz
./test-helper/setup-rest.sh
This will create a CRUD-only Kubernetes environment consisting of a Kubernetes API server and etcd (see envtest), and the NuoDB REST service configured to use the Kubernetes environment.
To enable usage of kubectl
and nuodb-cp
with this environment, run the following:
export KUBECONFIG="$(pwd)/test-helper/kubeconfig.yml"
alias nuodb-cp="java -jar $(pwd)/test-helper/nuodb-control-plane.jar"
eval "$(nuodb-cp generate-completion)"
Mock reconciliation
To enable the mock reconciliation controller, the servers can be started with the MARK_AS_READY=true
enviroment variable:
MARK_AS_READY=true ./test-helper/setup-rest.sh
This causes a Kubernetes configmap to be created that enables reconciliation of Domain
and Database
custom resources, which has the following format:
apiVersion: v1
kind: ConfigMap
metadata:
name: mock-operator-policy
data:
markAsReady: "true"
readinessDelaySeconds: ""
This configmap can also be created or modified while the servers are running to change the reconciliation behavior. The markAsReady
key enables reconciliation behavior, while the readinessDelaySeconds
key insert the specified delay before making a status update to any resource.
NOTE: The quotes for the values are important, because the configmap schema only accepts string values in the
data
fields.readinessDelaySeconds: "5"
is correct, whilereadinessDelaySeconds: 5
will be rejected by the API server.
Using nuodb-cp
Following the instructions above, nuodb-cp
should be usable without setting up any authentication credentials, since the server is running outside of the Kubernetes cluster and is configured to bypass authentication for client connections coming from the same host.
The REST server will be listening on port 8080
and it is not required to include any path prefix when sending requests to it, because there is no Ingress controller dispatching requests to it based on path prefix rules. The default --url-base
value of http://localhost:8080
should just work.
The following commands can be run to create a project and database (which do not have any actual process resources associated with them):
nuodb-cp project create org/proj --sla dev --tier n0.nano
nuodb-cp database create org/proj/db --dba-password db
With the mock reconciler enabled, the project and database will immediately show as Available
(or with some delay if readinessDelaySeconds
is configured):
$ nuodb-cp project get org/proj
{
"organization": "org",
"name": "proj",
"labels": { },
"sla": "dev",
"tier": "n0.nano",
"properties": {
"tierParameters": { },
"productVersion": "5.0"
},
"resourceVersion": "1377",
"status": {
"caPem": "-----BEGIN CERTIFICATE-----\nMIICwzCCAaugAwIBAgIIJWvF7FHoUL0wDQYJKoZIhvcNAQELBQAwFzEVMBMGA1UE\nAwwMY2EubnVvZGIuY29tMB4XDTI0MDIwMzA0NDgwMVoXDTI1MDIwMjA0NDgwMVow\nFzEVMBMGA1UEAwwMY2EubnVvZGIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\nMIIBCgKCAQEArRJHuBmBn9d7PfAmFwHwIxKj69GtbPJNOiySU18En4dTVF0pLaoJ\nBEo+mebMLkQhcrU87A+RqpPNLPLiPvujysXoqNUGzNsDLMMsthe3NSwHYI1u+Vcl\nrWDds+AQvgXzk+/KoInCvAxcGp0zgKv0qje/Bf0Io9Q1VgtfLUvgCea+cSN8j+Ty\n+xzFcHAAFGIkQ0DtW5qnhO6Ni4n+ftfgQOyclahQmWUlsP/5woFjZMN4yc3ZVmuE\njxTc4NmgCOBkMDwBGP0NClEQWdAEPRWXGOoQKnqCD3xcfogwdxniy8IJ779HH+VM\n3ufj59lB01yHbR342QB4mmR4Yvb0m6Su/wIDAQABoxMwETAPBgNVHRMBAf8EBTAD\nAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCGOckt0j6a9dQWpspZG5dh9rXP/5EQPDrZ\nagvpdTKmK2ZX9cyV/YT4qayXzNlBsZjR8zuohwKWUVGvfdFGSwgezG//Z9B4ZCgY\nopNUhKRS4j6ctg3bIEmbx8Odf7mnLR/hXdhLjo6wUDkow6aFnzd0cn0f6HQJM7Gq\nJWAS1A784NSXyyMeXZuP2SmrVyM8nzT8h7ak1m9ZpiCnDTqCnSyHL5nLtuhcKWDP\nTYMQhs5Wk4ZPYkxWa7Qvk+ClqpzzJ2HYoZJxjQ4eTST1RMu7pNXUcm2MnNbSHnlz\n3bSZjxbX5lkbCqtvyejNAFYSbYGSuGjoywppLmZ8fbVMJAnv4oQ7\n-----END CERTIFICATE-----",
"ready": true,
"shutdown": false,
"message": "Resource is ready",
"state": "Available",
"conditions": [ {
"lastTransitionTime": "2024-02-03T04:48:06Z",
"message": "Resource is ready",
"reason": "ReconciliationSucceeded",
"status": "True",
"type": "Ready"
} ]
}
}
$ nuodb-cp database get org/proj/db
{
"organization": "org",
"project": "proj",
"name": "db",
"labels": { },
"tier": "n0.nano",
"properties": {
"tierParameters": { },
"productVersion": "5.0"
},
"resourceVersion": "1387",
"status": {
"sqlEndpoint": "proj-f4ccefc29c8d.it.nuodb.local",
"caPem": "-----BEGIN CERTIFICATE-----\nMIICwzCCAaugAwIBAgIIJWvF7FHoUL0wDQYJKoZIhvcNAQELBQAwFzEVMBMGA1UE\nAwwMY2EubnVvZGIuY29tMB4XDTI0MDIwMzA0NDgwMVoXDTI1MDIwMjA0NDgwMVow\nFzEVMBMGA1UEAwwMY2EubnVvZGIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\nMIIBCgKCAQEArRJHuBmBn9d7PfAmFwHwIxKj69GtbPJNOiySU18En4dTVF0pLaoJ\nBEo+mebMLkQhcrU87A+RqpPNLPLiPvujysXoqNUGzNsDLMMsthe3NSwHYI1u+Vcl\nrWDds+AQvgXzk+/KoInCvAxcGp0zgKv0qje/Bf0Io9Q1VgtfLUvgCea+cSN8j+Ty\n+xzFcHAAFGIkQ0DtW5qnhO6Ni4n+ftfgQOyclahQmWUlsP/5woFjZMN4yc3ZVmuE\njxTc4NmgCOBkMDwBGP0NClEQWdAEPRWXGOoQKnqCD3xcfogwdxniy8IJ779HH+VM\n3ufj59lB01yHbR342QB4mmR4Yvb0m6Su/wIDAQABoxMwETAPBgNVHRMBAf8EBTAD\nAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCGOckt0j6a9dQWpspZG5dh9rXP/5EQPDrZ\nagvpdTKmK2ZX9cyV/YT4qayXzNlBsZjR8zuohwKWUVGvfdFGSwgezG//Z9B4ZCgY\nopNUhKRS4j6ctg3bIEmbx8Odf7mnLR/hXdhLjo6wUDkow6aFnzd0cn0f6HQJM7Gq\nJWAS1A784NSXyyMeXZuP2SmrVyM8nzT8h7ak1m9ZpiCnDTqCnSyHL5nLtuhcKWDP\nTYMQhs5Wk4ZPYkxWa7Qvk+ClqpzzJ2HYoZJxjQ4eTST1RMu7pNXUcm2MnNbSHnlz\n3bSZjxbX5lkbCqtvyejNAFYSbYGSuGjoywppLmZ8fbVMJAnv4oQ7\n-----END CERTIFICATE-----",
"ready": true,
"shutdown": false,
"message": "Resource is ready",
"state": "Available",
"conditions": [ {
"lastTransitionTime": "2024-02-03T04:48:37Z",
"message": "Resource is ready",
"reason": "ReconciliationSucceeded",
"status": "True",
"type": "Ready"
} ]
}
}
Shutting down the servers
To shutdown the servers, run the teardown-rest.sh
script from the package.
./test-helper/teardown-rest.sh