Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/api/actors.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
*** Settings ***
Resource keywords.robot
Library RequestsLibrary

*** Variables ***
${ACTORS_ENDPOINT} ${BASE_URL}/actors
${RESTART_ACTOR_ENDPOINT} ${ACTORS_ENDPOINT}/Vectordb/restart


*** Test Cases ***

List Ray Actors
${response}= GET ${ACTORS_ENDPOINT} headers=${HEADERS} expected_status=200
${json}= Set Variable ${response.json()}
Dictionary Should Contain Key ${json} actors

Restart Vectordb Actor
${response}= POST ${RESTART_ACTOR_ENDPOINT} headers=${HEADERS} expected_status=200
${json}= Set Variable ${response.json()}
Dictionary Should Contain Key ${json} message
Should Contain ${json}[message] restarted successfully
Dictionary Should Contain Key ${json} actor_id
17 changes: 0 additions & 17 deletions tests/api/extracts.robot

This file was deleted.

116 changes: 61 additions & 55 deletions tests/api/indexer.robot
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,86 @@ Resource keywords.robot

*** Test Cases ***
Add File and Delete it
Index File ${CURDIR}/${test_file_1} 0 test
Index File ${CURDIR}/${test_file_pdf} 0 test
Delete File 0 test
[Teardown] Clean Up Test test

Get Non Existent Task Status
${response}= Get Task Status 82891771158d68c1eacb9d1f151391007f68c96901000000 404
${response}= Get Task Status 82891771158d68c1eacb9d1f151391007f68c96901000000 ${HEADERS} 404
Should Be Equal As Strings
... ${response}[detail]
... Task '82891771158d68c1eacb9d1f151391007f68c96901000000' not found.

Get Invalid Task Id Status (-1)
${response}= Get Task Status -1 404
Should Be Equal As Strings ${response}[detail] Task '-1' not found.

Get Invalid Task Id Status (123)
${response}= Get Task Status 123 404
Should Be Equal As Strings ${response}[detail] Task '123' not found.
... Task '82891771158d68c1eacb9d1f151391007f68c96901000000' not found

Add File and Check Metadata
&{file_metadata}= Create Dictionary filename=${test_file_1} partition=test file_id=0
Index File ${CURDIR}/${test_file_1} 0 test
&{file_metadata}= Create Dictionary filename=${test_file_pdf} partition=test file_id=0
Index File ${CURDIR}/${test_file_txt} 0 test
${response}= Get File Metadata 0 test &{file_metadata}
[Teardown] Clean Up Test test

Add File and Patch it with new metadata
Index File ${CURDIR}/${test_file_2} 0 test
Index File ${CURDIR}/${test_file_txt} 0 test
${metadata}= Create Dictionary title=Test Title author=Test Author
${metadata}= Evaluate json.dumps(${metadata}) json
Patch File 0 test ${metadata}
&{file_metadata}= Create Dictionary title=Test Title author=Test Author
${response}= Get File Metadata 0 test &{file_metadata}
[Teardown] Clean Up Test test

Get Non Existent File
Get File Metadata id=0 part=test expected_status=404
Move File to New Partition
[Documentation] Move a file from one partition to another and verify it no longer exists in the source partition.
# --- Step 1: Move file to destination partition
${metadata}= Create Dictionary partition=test1
${metadata_json}= Evaluate json.dumps(${metadata}) json
${form_data}= Create Dictionary metadata=${metadata_json}
${response}= PATCH
... ${BASE_URL}/indexer/partition/test/file/0
... headers=${HEADERS}
... data=${form_data}
... expected_status=200
${json}= Set Variable ${response.json()}
Dictionary Should Contain Key ${json} message

Get Invalid File Id (-1)
Get File Metadata id=-1 part=test expected_status=404
# --- Step 2: Check that the file exists in destination partition
${response}= GET
... ${BASE_URL}/partition/test1/file/0
... headers=${HEADERS}
... expected_status=200
# --- Step 3: Verify that file no longer exists in the original partition
${response}= GET
... ${BASE_URL}/partition/test/file/0
... headers=${HEADERS}
... expected_status=404
${json}= Set Variable ${response.json()}
Should Contain ${json}[detail] does not exist

Get Invalid File Id (`"&é\'-!")

Get Invalid File Id (`"&é\'-!")
Get File Metadata id="&é\'-! part=test expected_status=404

Test Indexer Overload
${task_ids}= Create List
FOR ${i} IN RANGE 0 100
${response}= Index File Non Blocking ${CURDIR}/${test_file_1} ${i} test
${task_url}= Set Variable ${response}[task_status_url]
${task_id}= Fetch From Right ${task_url} /
Append To List ${task_ids} ${task_id}
END
Sleep 1
FOR ${i} IN RANGE 0 1200
FOR ${task_id} IN @{task_ids}
${response}= Get Task Status ${task_id}
${task_state}= Set Variable ${response}[task_state]
IF '${task_state}' == 'FAILED'
Fail Task '${task_id}' failed.
ELSE IF '${task_state}' == 'COMPLETED'
Remove Values From List ${task_ids} ${task_id}
END
END
Sleep 1
${list_length}= Get Length ${task_ids}
IF ${list_length} > 0
Log ${task_ids}
END
# Exit early if all tasks completed
${list_length}= Get Length ${task_ids}
IF ${list_length} == 0
BREAK
END
END
IF ${list_length} > 0
Log Some tasks are still running after 1200 seconds: ${task_ids}
Fail Some tasks are still running after 1200 seconds.
END
[Teardown] Clean Up Test test

Copy File to Another Partition
[Documentation] Index a file into one partition, copy it to another, and verify it exists in the destination.

# --- Step 1: Copy file to destination partition
${form_data}= Create Dictionary source_partition=test1 source_file_id=0
${response}= POST
... ${BASE_URL}/indexer/partition/test/file/1/copy
... headers=${HEADERS}
... data=${form_data}
... expected_status=201

# --- Step 2: Check that the file exists in destination partition
${response}= GET
... ${BASE_URL}/partition/test/file/1
... headers=${HEADERS}
... expected_status=200
# --- Step 3: Verify that file still exists in the original partition
${response}= GET
... ${BASE_URL}/partition/test1/file/0
... headers=${HEADERS}
... expected_status=200
${json}= Set Variable ${response.json()}

Cleanup
${response}= DELETE ${BASE_URL}/partition/test headers=${HEADERS} expected_status=204
${response}= DELETE ${BASE_URL}/partition/test1 headers=${HEADERS} expected_status=204

82 changes: 58 additions & 24 deletions tests/api/keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,34 @@ Library Collections
Library RequestsLibrary

*** Variables ***
${BASE}
${PORT}
${test_file_1} test_file_1.pdf
${test_file_2} test_file_2.pdf
${BASE}
${PORT}
${test_file_pdf} ../resources/test_file.pdf
${test_file_txt} ../resources/test_file.txt
${test_part_1} test
${test_part_2} test2
${BASE_URL} ${BASE}:${PORT}
${AUTH_TOKEN} none
&{HEADERS} Authorization=Bearer ${AUTH_TOKEN}

*** Keywords ***
Clean Up Test
[Arguments] @{part}
${allowed_status}= Create List 204 404
FOR ${partition} IN @{part}
${response}= DELETE ${BASE_URL}/partition/${partition} expected_status=any
${response}= DELETE ${BASE_URL}/partition/${partition} headers=${HEADERS} expected_status=any
${status_code}= Convert To String ${response.status_code}
List Should Contain Value ${allowed_status} ${status_code}
END

Get Task Status
[Arguments] ${task_id} ${expected_status}=200
${response}= GET ${BASE_URL}/indexer/task/${task_id} expected_status=${expected_status}
[Arguments] ${task_id} ${headers}=${HEADERS} ${expected_status}=200
${response}= GET ${BASE_URL}/indexer/task/${task_id} headers=${headers} expected_status=${expected_status}
RETURN ${response.json()}

Get Extract
[Arguments] ${extract_id} ${expected_status}=200
${response}= GET ${BASE_URL}/extract/${extract_id} expected_status=${expected_status}
[Arguments] ${extract_id} ${headers}=${HEADERS} ${expected_status}=200
${response}= GET ${BASE_URL}/extract/${extract_id} headers=${headers} expected_status=${expected_status}
RETURN ${response.json()}

Index File Non Blocking
Expand All @@ -39,42 +41,53 @@ Index File Non Blocking
${response}= POST
... ${BASE_URL}/indexer/partition/${part}/file/${id}
... files=${files}
... headers=${HEADERS}
... expected_status=${expected_status}
${response}= Set Variable ${response.json()}
Should Match Regexp ${response}[task_status_url] ${BASE_URL}/indexer/task/[a-fA-F0-9]{48}
RETURN ${response}

Index File
[Arguments] ${file_path} ${id} ${part} ${expected_status}=201
[Arguments] ${file_path} ${id} ${part} ${headers}=${HEADERS} ${expected_status}=201
${file}= Get File For Streaming Upload ${file_path}
${files}= Create Dictionary file ${file}
${response}= POST
... ${BASE_URL}/indexer/partition/${part}/file/${id}
... files=${files}
... headers=${headers}
... expected_status=${expected_status}
${response}= Set Variable ${response.json()}
Should Match Regexp ${response}[task_status_url] ${BASE_URL}/indexer/task/[a-fA-F0-9]{48}
${task_id}= Fetch From Right ${response}[task_status_url] /
Sleep 1
FOR ${i} IN RANGE 0 60 # 60 seconds
${response}= Get Task Status ${task_id}
FOR ${i} IN RANGE 0 120
${response}= Get Task Status ${task_id} headers=${headers}
IF '${response}[task_state]' == 'COMPLETED' BREAK
Sleep 1
IF ${i} == 59
Log Task '${task_id}' is still running after 60 seconds.
IF ${i} == 119
Log Task '${task_id}' is still running after 120 seconds.
Log ${response}
Fail Task '${task_id}' is still running after 60 seconds.
Fail Task '${task_id}' is still running after 120 seconds.
END
END

Check File Exists
[Arguments] ${id} ${part} ${expected_status}=200
${response}= GET ${BASE_URL}/partition/check-file/${part}/file/${id} expected_status=${expected_status}
${response}= GET ${BASE_URL}/${part}/file/${id} headers=${HEADERS} expected_status=${expected_status}
${json}= Set Variable ${response.json()}

IF '${expected_status}' == '200'
Should Be Equal As Strings ${response.json()} File '${id}' exists in partition '${part}'.
Dictionary Should Contain Key ${json} metadata
Dictionary Should Contain Key ${json} documents
${documents}= Get From Dictionary ${json} documents
Should Be True ${documents} != []
FOR ${doc} IN @{documents}
Dictionary Should Contain Key ${doc} link
END
END

IF '${expected_status}' == '404'
Should Be Equal As Strings ${response.json()}[detail] [VDB_FILE_NOT_FOUND]: File ID '${id}' does not exist in partition '${part}'
Should Be Equal As Strings ${json}[detail] [VDB_FILE_NOT_FOUND]: File ID '${id}' does not exist in partition '${part}'
END

Patch File
Expand All @@ -83,26 +96,30 @@ Patch File
${response}= PATCH
... ${BASE_URL}/indexer/partition/${part}/file/${id}
... data=${form_data}
... headers=${HEADERS}
... expected_status=${expected_status}
IF '${expected_status}' == '200'
Should Be Equal As Strings ${response.json()}[message] Metadata for file '${id}' successfully updated.
END

Delete File
[Arguments] ${id} ${part}=${test_part_1} ${expected_status}=204
${response}= DELETE ${BASE_URL}/indexer/partition/${part}/file/${id} expected_status=${expected_status}
${response}= DELETE ${BASE_URL}/indexer/partition/${part}/file/${id} headers=${HEADERS} expected_status=${expected_status}
RETURN None

Delete Partition
[Arguments] ${part} ${expected_status}=204
${response}= DELETE ${BASE_URL}/partition/${part} expected_status=${expected_status}
[Arguments] ${part} ${headers}=${HEADERS} ${expected_status}=204
${response}= DELETE
... ${BASE_URL}/partition/${part}
... headers=${headers}
... expected_status=${expected_status}
RETURN None

Get File Metadata
[Arguments] ${id} ${part} &{expected_metadata_and_status}
${expected_status}= Get From Dictionary ${expected_metadata_and_status} expected_status 200
${expected_metadata}= Remove From Dictionary ${expected_metadata_and_status} expected_status
${response}= GET ${BASE_URL}/partition/${part}/file/${id} expected_status=${expected_status}
${response}= GET ${BASE_URL}/partition/${part}/file/${id} headers=${HEADERS} expected_status=${expected_status}
${json_response}= Set Variable ${response.json()}
IF '${expected_status}' == '404'
Should Be Equal As Strings ${json_response}[detail] [VDB_FILE_NOT_FOUND]: File ID '${id}' does not exist in partition '${part}'
Expand All @@ -116,5 +133,22 @@ Get File Metadata
END

Get Models
${response}= GET ${BASE_URL}/v1/models
Log To Console ${response}
[Arguments] ${headers}=${HEADERS}
${response}= GET ${BASE_URL}/v1/models headers=${headers}
Log To Console ${response}

Create User
[Arguments] ${display_name} ${external_user_id} ${is_admin}=false ${expected_status}=201
${form_data}= Create Dictionary
... display_name=${display_name}
... external_user_id=${external_user_id}
... is_admin=${is_admin}
${response}= POST
... ${BASE_URL}/users
... headers=${HEADERS}
... data=${form_data}
... expected_status=${expected_status}
RETURN ${response.json()}

Skip If Auth Disabled
Run Keyword If '${AUTH_TOKEN}' == 'none' Skip Auth is disabled
2 changes: 1 addition & 1 deletion tests/api/main.robot
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Resource keywords.robot

*** Test Cases ***
Health Check
${response}= GET ${BASE_URL}/health_check expected_status=any
${response}= GET ${BASE_URL}/health_check headers=${HEADERS} expected_status=any
IF '${response.status_code}' != '200'
Fatal Error Health check failed with status code: ${response.status_code}. Canceling all tests.
END
Expand Down
Loading