Open jonnyz32 opened 3 months ago
@ajshedivy Is this something you will be using for the py client tests? I wonder if this issue should be a nicely formatted page in the docs.
@ajshedivy Is this something you will be using for the py client tests? I wonder if this issue should be a nicely formatted page in the docs.
yes working on that now!
Mapepire test cases
Test Case: Connect to Database Test Case ID: TC01 Type: Connect Description: Verify successful connection to the database. Ensure existing connections are implicitly disconnected. Inputs: props: "system=mySystem;uid=user;pwd=password" application: "MyApp" technique: "cli" Expected Outputs: Status Code: 200 OK Response Fields: job: Should return the server job identifier (e.g., "QPADEV0001") Validation Criteria:
Test Case: Connect to Database with Invalid Properties Test Case ID: TC02 Type: Connect Description: Verify that connection fails when invalid connection properties are provided. Inputs: props: "system=invalidSystem;uid=wrongUser;pwd=wrongPassword" application: "MyApp" technique: "cli" Expected Outputs: Status Code: 401 Unauthorized or appropriate error code Response Fields: error: A descriptive error message indicating connection failure (e.g., "Invalid credentials or system not found.") Validation Criteria:
Ensure that the error field provides a clear reason for the connection failure. Confirm that no job identifier is returned.
Preconditions:
A valid database connection must be established. Inputs:
cmd: "WRKACTJOB" Expected Outputs: Status Code: 200 OK Response Fields: data: Should return a list of job log entries related to the executed command. Validation Criteria: Confirm that the data field contains relevant job log entries. Verify that the command was executed successfully by checking the contents of the job log.
Preconditions: A valid database connection must be established. Inputs:
cmd: "INVALIDCOMMAND" Expected Outputs: Status Code: 400 Bad Request or appropriate error code Response Fields: error: A descriptive error message indicating the failure of the command. data: Should return job log entries indicating the nature of the error.
Validation Criteria: Ensure that the error field clearly indicates the reason for the command failure. Verify that the data field contains job log entries corresponding to the error.
Inputs: props: "system=mySystem;uid=user;pwd=password" application: "MyApp" technique: "tcp" job: "" Expected Outputs: Status Code: 200 OK Response Fields: job: Should return the server job identifier. Validation Criteria: Verify that the connection is successfully established using the TCP technique. Confirm that the job field is populated with a valid job identifier.
Preconditions:
A valid database connection must be established. Inputs: props: "system=mySystem;uid=user;pwd=password" application: "MyApp" technique: "cli" job: "" Expected Outputs:
Status Code: 200 OK Response Fields: job: A new server job identifier. Validation Criteria: Confirm that the job identifier returned differs from the previous connection, indicating an implicit disconnection. Ensure that no errors are reported in the response.
Test Cases for SQL Request
Inputs: sql: "SELECT * FROM QGPL.TEST_TABLE" rows: 10 terse: false Expected Outputs:
Status Code: 200 OK Response Fields: metadata: Contains column metadata (e.g., column names, data types). data: Contains up to 10 rows of data from QGPL.TEST_TABLE. is_done: true if all rows have been fetched, false if more rows are available. Validation Criteria: Verify that the metadata field correctly describes the result set. Confirm that the data field contains the expected rows. Check that is_done is true when the result set contains 10 or fewer rows.
Inputs: sql: "SELECT * FROM QGPL.LARGE_TABLE" rows: 50 terse: false Expected Outputs:
Status Code: 200 OK Response Fields: metadata: Contains column metadata for QGPL.LARGE_TABLE. data: Contains the first 50 rows of the result set. is_done: false if there are more rows available, true if the entire dataset has been returned. Validation Criteria:
Ensure that only the specified number of rows (50) is returned in the data field. Confirm that is_done is false if more rows are available. Check that subsequent requests can retrieve additional rows until is_done is true.
Inputs: sql: "SELECT * FROM QGPL.TEST_TABLE" rows: 5 terse: true Expected Outputs: Status Code: 200 OK Response Fields: metadata: Contains column metadata in a compact format. data: Contains 5 rows of data in terse format. is_done: true if all rows have been fetched, false if more rows are available. Validation Criteria:
Confirm that the metadata and data fields are returned in terse format, reducing data verbosity. Ensure that the data field still accurately represents the expected rows.
Status Code: 400 Bad Request or appropriate error code Response Fields: error: A descriptive error message indicating the reason for the query failure. Validation Criteria:
Ensure that the error field provides a clear and descriptive message regarding the invalid query. Verify that no data or metadata fields are returned.
Inputs:
sql: "" rows: 0 terse: false Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: error: A descriptive error message indicating the nature of the invalid input. Validation Criteria:
Ensure that the error field clearly explains why the input is invalid. Confirm that the API gracefully handles edge cases without crashing or returning unexpected results.
Test Case ID: TC06 Type: SQL Description: Verify that the API allows fetching of additional rows after an initial request that did not return the full dataset.
Preconditions:
Initial request returned partial data with is_done set to false. Inputs:
sql: "SELECT * FROM QGPL.LARGE_TABLE" rows: 50 terse: false Expected Outputs:
Status Code: 200 OK Response Fields: metadata: Should match the metadata of the initial request. data: Contains the next set of rows from the result set. is_done: true if all rows have been fetched, otherwise false. Validation Criteria:
Confirm that the subsequent request retrieves additional rows starting from where the last request left off. Ensure that is_done eventually returns true when all data has been fetched.
Test Cases for Prepare SQL Request
Inputs:
sql: "SELECT * FROM QGPL.TEST_TABLE" terse: false Expected Outputs: Status Code: 200 OK Response Fields: Status: SQL statement is prepared successfully. Statement Handle: A unique identifier for the prepared SQL statement. Validation Criteria:
Confirm that the SQL statement is prepared without errors. Ensure that a valid statement handle is returned for future execution.
Inputs:
sql: "SELECT * FROM QGPL.TEST_TABLE WHERE COLUMN1 = ?" terse: true Expected Outputs:
Status Code: 200 OK Response Fields: Status: SQL statement is prepared successfully. Metadata: Metadata returned in terse format. Statement Handle: A unique identifier for the prepared SQL statement. Validation Criteria:
Ensure that the terse format reduces verbosity while retaining necessary information. Verify that the metadata accurately describes the prepared statement.
Inputs:
sql: "SELECT * FROM NON_EXISTENT_TABLE" terse: false Expected Outputs:
Status Code: 400 Bad Request or appropriate error code
Response Fields: Error: A descriptive error message indicating why the SQL statement could not be prepared. Validation Criteria:
Ensure that the error message clearly explains the issue with the SQL statement. Confirm that no statement handle is returned.
Inputs:
sql: "SELECT * FROM QGPL.TEST_TABLE WHERE COLUMN1 = ?" Expected Outputs:
Status Code: 200 OK Response Fields: Status: SQL statement is prepared successfully. Metadata: Metadata is returned in the default format. Statement Handle: A unique identifier for the prepared SQL statement. Validation Criteria:
Verify that the default format (non-terse) is used for metadata when terse is not specified. Ensure that the statement handle is returned and valid.
Inputs:
sql: "SELECT A.COL1, B.COL2 FROM QGPL.TABLE_A A JOIN QGPL.TABLE_B B ON A.ID = B.ID WHERE A.COL3 IN (SELECT COL3 FROM QGPL.TABLE_C)" terse: false Expected Outputs:
Status Code: 200 OK Response Fields: Status: SQL statement is prepared successfully. Metadata: Metadata reflecting the complex SQL statement. Statement Handle: A unique identifier for the prepared SQL statement. Validation Criteria: Ensure that the complex SQL statement is prepared without errors. Verify that the metadata accurately reflects the structure of the prepared SQL statement.
Inputs: sql: "" terse: false Expected Outputs: Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating why the SQL statement could not be prepared. Validation Criteria: Ensure that the API returns an appropriate error message for empty SQL input. Confirm that no statement handle is returned.
Test Cases for Execute SQL Request
Inputs:
cont_id: "valid-prepared-statement-id" batch: false parameters: ["value1", "value2"] Expected Outputs:
Status Code: 200 OK Response Fields: data: Resulting data from the executed SQL statement. Validation Criteria:
Confirm that the SQL statement executes successfully and returns the expected results. Ensure that the returned data matches the expected output based on the SQL statement.
Inputs:
cont_id: "valid-prepared-statement-id" batch: true parameters: [["value1a", "value2a"], ["value1b", "value2b"]] Expected Outputs:
Status Code: 200 OK Response Fields: data: Combined result set from all SQL operations in the batch. Validation Criteria:
Ensure that all operations in the batch are executed successfully. Verify that the returned data includes results from all executed SQL statements.
Inputs:
cont_id: "" batch: false parameters: ["value1"] Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that cont_id is required. Validation Criteria:
Ensure that the error message clearly states that cont_id is missing. Confirm that no data is returned.
Inputs:
cont_id: "invalid-prepared-statement-id" batch: false parameters: ["value1"] Expected Outputs:
Status Code: 404 Not Found or appropriate error code Response Fields: Error: A descriptive error message indicating that the prepared SQL statement was not found. Validation Criteria:
Ensure that the error message clearly explains that the provided cont_id is invalid. Confirm that no data is returned.
Inputs:
cont_id: "valid-prepared-statement-id" batch: true parameters: [] Expected Outputs:
Status Code: 200 OK Response Fields: data: Resulting data from the executed batch of SQL operations. Validation Criteria:
Confirm that the batch is executed even when no parameters are specified. Ensure that the returned data matches the expected output based on the SQL operations in the batch.
Inputs:
cont_id: "valid-prepared-statement-id" batch: true parameters: [[]] Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that parameters must not be empty. Validation Criteria:
Ensure that the error message clearly states that empty parameter arrays are invalid. Confirm that no data is returned.
Inputs:
cont_id: "valid-prepared-statement-id" batch: true parameters: [["value1a", "value2a"], ["value1b"]] Expected Outputs:
Status Code: 200 OK Response Fields: data: Combined result set from all SQL operations in the batch. Validation Criteria:
Ensure that all SQL operations in the batch execute successfully, regardless of the number of parameters. Verify that the returned data includes results from all executed SQL statements, with proper handling of missing parameters where applicable.
Test Cases for Prepare and Execute SQL Request
Inputs:
parameters: ["value1", "value2"] terse: false Expected Outputs:
Status Code: 200 OK Response Fields: data: Resulting data from the executed SQL statement. Validation Criteria:
Confirm that the SQL statement executes successfully and returns the expected results. Ensure that the returned data matches the expected output based on the SQL statement.
Inputs:
parameters: [] terse: false Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that parameters are required. Validation Criteria:
Ensure that the error message clearly states that required parameters are missing. Confirm that no data is returned.
Inputs:
parameters: [123, true] // Assuming SQL expects strings terse: false Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that parameters must be of valid types. Validation Criteria:
Ensure that the error message clearly explains that the provided parameters are invalid. Confirm that no data is returned.
Inputs:
parameters: ["value1", "value2"] terse: true Expected Outputs:
Status Code: 200 OK Response Fields: data: Resulting data in terse format from the executed SQL statement. Validation Criteria:
Confirm that the SQL statement executes successfully and returns the expected results in terse format. Ensure that the returned data matches the expected output based on the SQL statement.
Inputs:
parameters: [] terse: false Expected Outputs:
Status Code: 200 OK Response Fields: data: Resulting data from the executed SQL statement. Validation Criteria:
Ensure that the SQL statement executes successfully without any parameters if allowed. Verify that the returned data matches the expected output.
Inputs:
parameters: ["value1", "value2", "value3", "value4", "value5", ...] // Large array terse: false Expected Outputs:
Status Code: 200 OK Response Fields: data: Resulting data from the executed SQL statement. Validation Criteria:
Confirm that the SQL statement executes successfully with the large array of parameters. Ensure that the returned data matches the expected output based on the SQL statement.
Inputs:
parameters: ["value1", "value2"] terse: false Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that there is a syntax error in the SQL statement. Validation Criteria:
Ensure that the error message clearly states that there is a syntax error in the SQL statement. Confirm that no data is returned.
Test Cases for SQL More Request
Inputs:
cont_id: "valid_request_id" // Valid request ID from a previous SQL request rows: 10 // Maximum number of rows to return Expected Outputs:
Status Code: 200 OK Response Fields: data: Array of the next set of data rows. is_done: false (indicating more rows are available) Validation Criteria:
Confirm that the response contains the expected data and the is_done field indicates more rows are available. Ensure that the number of rows returned does not exceed the specified limit.
Inputs:
cont_id: "invalid_request_id" // Invalid request ID rows: 10 Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that the request ID is invalid. Validation Criteria:
Ensure that the error message clearly states that the request ID is not valid. Confirm that no data is returned.
Inputs:
cont_id: "request_id_all_fetched" // Valid request ID where all rows have been fetched rows: 10 Expected Outputs:
Status Code: 200 OK Response Fields: data: [] (empty array, indicating no more data) is_done: true (indicating that all rows have been fetched) Validation Criteria:
Confirm that the response data is an empty array and the is_done field is set to true. Ensure that the API correctly identifies that there are no more rows to fetch.
Inputs:
cont_id: "valid_request_id" // Valid request ID from a previous SQL request rows: 0 // Maximum number of rows to return Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that the number of rows must be greater than zero. Validation Criteria:
Ensure that the error message clearly states that the number of rows requested must be greater than zero. Confirm that no data is returned.
Inputs:
cont_id: "valid_request_id" // Valid request ID from a previous SQL request rows: -5 // Invalid number of rows Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that the number of rows must be a positive integer. Validation Criteria:
Ensure that the error message clearly states that the number of rows requested must be a positive integer. Confirm that no data is returned.
Inputs:
cont_id: "valid_request_id" // Valid request ID from a previous SQL request rows: 1000 // Maximum number of rows to return Expected Outputs:
Status Code: 200 OK Response Fields: data: Array containing up to 1000 rows of data. is_done: false (indicating more rows are available, or true if all rows are fetched) Validation Criteria:
Confirm that the response contains the expected number of data rows without exceeding the specified limit. Ensure that the is_done field reflects whether more rows are available.
Inputs:
cont_id: "request_id_no_data" // Valid request ID from a previous SQL request that returned no data rows: 10 Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that no data is available to fetch. Validation Criteria:
Ensure that the error message clearly states that there are no rows available to fetch from the previous request. Confirm that no data is returned.
Test Cases SQL Close Request
Inputs:
cont_id: "valid_request_id" // Valid request ID from a previous SQL/prepare_sql/prepare_sql_execute request Expected Outputs:
Status Code: 200 OK Response Fields: data: Confirmation message indicating that the cursor has been closed successfully. Validation Criteria:
Confirm that the response indicates successful closure of the cursor. Ensure that subsequent requests using the same cont_id return an error indicating the cursor is closed.
Inputs:
cont_id: "invalid_request_id" // Invalid request ID Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that the request ID is invalid. Validation Criteria:
Ensure that the error message clearly states that the request ID is not valid. Confirm that no data is returned.
Inputs:
cont_id: "already_closed_request_id" // Valid request ID from a previous SQL operation where the cursor has already been closed Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that the cursor is already closed. Validation Criteria:
Confirm that the error message states that the cursor has already been closed. Ensure that no data is returned.
Inputs:
cont_id: "" // Empty request ID Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that the request ID cannot be empty. Validation Criteria:
Ensure that the error message clearly states that the request ID cannot be empty. Confirm that no data is returned.
Inputs:
cont_id: null // Null request ID Expected Outputs:
Status Code: 400 Bad Request or appropriate error code Response Fields: Error: A descriptive error message indicating that the request ID cannot be null. Validation Criteria:
Ensure that the error message clearly states that the request ID cannot be null. Confirm that no data is returned.
Inputs:
cont_id: "non_existent_request_id" // Non-existent request ID Expected Outputs:
Status Code: 404 Not Found or appropriate error code Response Fields: Error: A descriptive error message indicating that the request ID does not exist. Validation Criteria:
Ensure that the error message clearly states that the request ID does not exist. Confirm that no data is returned.
Inputs:
cont_id: "valid_request_id" // Valid request ID from a previous SQL operation Expected Outputs:
Status Code: 200 OK for the first close request. Status Code: 400 Bad Request or appropriate error code for the subsequent close request. Response Fields: First close request: data: Confirmation message indicating successful closure. Second close request: Error: A message indicating the cursor is already closed. Validation Criteria:
Confirm that the first close request is successful. Ensure that the second close request returns an error indicating the cursor is already closed.