Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tharsanan1 committed Sep 20, 2024
1 parent db72e7b commit c108237
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 11 deletions.
22 changes: 22 additions & 0 deletions test/cucumber-tests/CRs/artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1729,3 +1729,25 @@ spec:
in: "Body"
value: "usage.total_tokens"
---
apiVersion: dp.wso2.com/v1alpha3
kind: AIProvider
metadata:
name: llm-provider-1
namespace: apk-integration-test
spec:
providerName : "AzureAI"
providerAPIVersion : "2024-06-01"
organization : "default"
model:
in: "Body"
value: "model"
rateLimitFields:
promptTokens:
in: "Body"
value: "usage.prompt_tokens"
completionToken:
in: "Body"
value: "usage.completion_tokens"
totalToken:
in: "Body"
value: "usage.total_tokens"
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: "BackendBasedAIRL"
basePath: "/backend-based-airl"
id: "backend-based-airl"
version: "1.0.0"
type: "REST"
defaultVersion: false
subscriptionValidation: false
aiProvider:
name: llm-provider-1
apiVersion: “2024.06.01”
endpointConfigurations:
production:
endpoint: "http://llm-service:80"
aiRatelimit:
enabled: true
token:
promptLimit: 5000
completionLimit: 10000
totalLimit: 15000
unit: Minute
request:
requestLimit: 6000
unit: Minute
operations:
- target: "/employee"
verb: "GET"
secured: true
scopes: []
- target: "/employee"
verb: "POST"
secured: true
scopes: []
- target: "/employee/{employeeId}"
verb: "PUT"
secured: true
scopes: []
- target: "/employee/{employeeId}"
verb: "DELETE"
secured: true
scopes: []
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
Feature: API backend based AI ratelimit Feature

Scenario: backend based AI ratelimit token detail comes in the body.
Given The system is ready
And I have a valid subscription
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I wait for next minute strictly
And I send "GET" request to "https://default.gw.wso2.com:9095/llm-api/v1.0.0/3.14/employee?send=body" with body ""
Then the response status code should be 200
And the response headers should contain
| x-ratelimit-remaining | 4999 |
| x-ratelimit-remaining | 4999 |
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/llm-api/v1.0.0/3.14/employee?send=body" with body ""
Then the response status code should be 200
And the response headers should contain
| x-ratelimit-remaining | 4699 |
| x-ratelimit-remaining | 4699 |
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/llm-api/v1.0.0/3.14/employee?send=body&prompt_tokens=40000" with body ""
Then the response status code should be 200
And the response headers should contain
| x-ratelimit-remaining | 4399 |
| x-ratelimit-remaining | 4399 |
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/llm-api/v1.0.0/3.14/employee?send=body&prompt_tokens=40000" with body ""
Then the response status code should be 429
Expand All @@ -34,26 +35,27 @@ Feature: API backend based AI ratelimit Feature
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/llm-api/v1.0.0/3.14/employee?send=body" with body ""
Then the response status code should be 429

Scenario: backend based AI ratelimit token detail comes in the header.
Given The system is ready
And I have a valid subscription
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I wait for next minute strictly
And I send "GET" request to "https://default.gw.wso2.com:9095/llm-api-header/v1.0.0/3.14/employee?send=header" with body ""
Then the response status code should be 200
And the response headers should contain
| x-ratelimit-remaining | 4999 |
| x-ratelimit-remaining | 4999 |
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/llm-api-header/v1.0.0/3.14/employee?send=header" with body ""
Then the response status code should be 200
And the response headers should contain
| x-ratelimit-remaining | 4699 |
| x-ratelimit-remaining | 4699 |
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/llm-api-header/v1.0.0/3.14/employee?send=header&prompt_tokens=40000" with body ""
Then the response status code should be 200
And the response headers should contain
| x-ratelimit-remaining | 4399 |
| x-ratelimit-remaining | 4399 |
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/llm-api-header/v1.0.0/3.14/employee?send=header&prompt_tokens=40000" with body ""
Then the response status code should be 429
Expand All @@ -69,18 +71,69 @@ Feature: API backend based AI ratelimit Feature
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/llm-api-header/v1.0.0/3.14/employee?send=header" with body ""
Then the response status code should be 429

Scenario: backend based AI ratelimit token detail comes in the header but a body configured api checked.
Given The system is ready
And I have a valid subscription
Then I set headers
|Authorization|bearer ${accessToken}|
| Authorization | bearer ${accessToken} |
And I wait for next minute strictly
And I send "GET" request to "https://default.gw.wso2.com:9095/llm-api/v1.0.0/3.14/employee?send=header" with body ""
Then the response status code should be 200
And the response headers should contain
| x-ratelimit-remaining | 4999 |
| x-ratelimit-remaining | 4999 |
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/llm-api/v1.0.0/3.14/employee?send=header" with body ""
Then the response status code should be 200
And the response headers should contain
| x-ratelimit-remaining | 4998 |
| x-ratelimit-remaining | 4998 |

Scenario: apk conf backend based AI ratelimit token detail comes in the body.
Given The system is ready
And I have a valid subscription
When I use the APK Conf file "artifacts/apk-confs/backend_based_airl_conf.yaml"
And the definition file "artifacts/definitions/employees_api.json"
And make the API deployment request
Then the response status code should be 200
Then I set headers
| Authorization | bearer ${accessToken} |
And I wait for next minute strictly
And I send "GET" request to "https://default.gw.wso2.com:9095/backend-based-airl/1.0.0/employee?send=body" with body ""
Then the response status code should be 200
And the response headers should contain
| x-ratelimit-remaining | 4999 |
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/backend-based-airl/1.0.0/employee?send=body" with body ""
Then the response status code should be 200
And the response headers should contain
| x-ratelimit-remaining | 4699 |
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/backend-based-airl/1.0.0/employee?send=body&prompt_tokens=40000" with body ""
Then the response status code should be 200
And the response headers should contain
| x-ratelimit-remaining | 4399 |
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/backend-based-airl/1.0.0/employee?send=body&prompt_tokens=40000" with body ""
Then the response status code should be 429
And I wait for next minute strictly
And I send "GET" request to "https://default.gw.wso2.com:9095/backend-based-airl/1.0.0/employee?send=body&completion_tokens=40000" with body ""
Then the response status code should be 200
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/backend-based-airl/1.0.0/employee?send=body" with body ""
Then the response status code should be 429
And I wait for next minute strictly
And I send "GET" request to "https://default.gw.wso2.com:9095/backend-based-airl/1.0.0/employee?send=body&total_tokens=40000" with body ""
Then the response status code should be 200
And I wait for 3 seconds
And I send "GET" request to "https://default.gw.wso2.com:9095/backend-based-airl/1.0.0/employee?send=body" with body ""
Then the response status code should be 429

Scenario Outline: Undeploy API
Given The system is ready
And I have a valid subscription
When I undeploy the API whose ID is "<apiID>"
Then the response status code should be <expectedStatusCode>

Examples:
| apiID | expectedStatusCode |
| backend-based-airl | 202 |

0 comments on commit c108237

Please sign in to comment.