Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add perf benchmark policy #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions perf-proxies/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# API proxy for Performance Benchmark

This directory contains the API proxy and Sharedflow used to performance test
Apigee X and Apigee hybrid instances.

## About this sample proxy

This API proxy uses the following policies

* Access Control
* Access Entity
* Validate OAuth
* Validate API Key
* JavaScript
* Assign Message
* Quota
* XMLThreat Protection
* GenerateAccessToken
* Python Callout
* XSLT
* XMLToJSON
* Raise-Fault
* FlowCallout
* ServiceCallout
* GenerateJWT
* VerifyJWT

The API Proxy is available on the basePath `/hybridperf`
69 changes: 69 additions & 0 deletions perf-proxies/proxy/apiproxy/hybrid_perf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<APIProxy revision="25" name="hybrid_perf">
<DisplayName>hybrid_perf</DisplayName>
<Description>Performance Test App</Description>
<CreatedAt>1596042552317</CreatedAt>
<LastModifiedAt>1596042660545</LastModifiedAt>
<BasePaths>/hybridperf</BasePaths>
<Policies>
<Policy>ValidMessage</Policy>
<Policy>LimitBySlowQuota</Policy>
<Policy>RejectURI</Policy>
<Policy>LimitByIP</Policy>
<Policy>SetPayload_AccessEntity_ApiProduct</Policy>
<Policy>ValidateOAuth</Policy>
<Policy>ValidateKey</Policy>
<Policy>getURL</Policy>
<Policy>AccessEntity_AppName</Policy>
<Policy>SetPayload_AccessEntity_AppID</Policy>
<Policy>SetPayload_AccessEntity_AppName</Policy>
<Policy>JSHeader</Policy>
<Policy>putURL</Policy>
<Policy>RemoveQueryParams</Policy>
<Policy>LimitByQuota</Policy>
<Policy>AccessEntity_Developer</Policy>
<Policy>SetCacheHeader</Policy>
<Policy>ResponseCache</Policy>
<Policy>XMLThreat</Policy>
<Policy>GenerateAccessToken</Policy>
<Policy>EncodeURI</Policy>
<Policy>PYHeader</Policy>
<Policy>GenerateRandomNumber</Policy>
<Policy>PYParse</Policy>
<Policy>AccessEntity_AppID</Policy>
<Policy>SetPayload_AccessEntity_Developer</Policy>
<Policy>XSLT</Policy>
<Policy>AccessEntity_ApiProduct</Policy>
<Policy>XMLToJSON</Policy>
<Policy>assign-header</Policy>
<Policy>Raise-Fault</Policy>
<Policy>FlowCallout</Policy>
<Policy>ServiceCallout</Policy>
<Policy>SC-BuildRequest</Policy>
<Policy>ExtractSCResponse</Policy>
<Policy>AssignSCResponse</Policy>
<Policy>ScJSON</Policy>
<Policy>GenerateJWT</Policy>
<Policy>VerifyJWT</Policy>
<Policy>RF-MissingParam</Policy>
<Policy>AM-PrivateKey</Policy>
<Policy>AM-Response</Policy>
<Policy>AM-JwtAuthorization</Policy>
<Policy>add-cors</Policy>
<Policy>ResponsePayload</Policy>
</Policies>
<ProxyEndpoints>
<ProxyEndpoint>proxy</ProxyEndpoint>
</ProxyEndpoints>
<Resources>
<Resource>py://pyparse.py</Resource>
<Resource>py://encodeuri.py</Resource>
<Resource>py://pyheader.py</Resource>
<Resource>jsc://RandomNumber.js</Resource>
<Resource>xsl://weatherxsl</Resource>
<Resource>js://jsheader.js</Resource>
</Resources>
<TargetServers></TargetServers>
<TargetEndpoints>
<TargetEndpoint>static</TargetEndpoint>
</TargetEndpoints>
</APIProxy>
26 changes: 26 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/AM-JwtAuthorization.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-JwtAuthorization">
<DisplayName>AM-JwtAuthorization</DisplayName>
<Properties/>
<Add>
<Headers/>
<Header name="Authorization">Bearer {output-jwt}</Header>
</Add>
<AssignVariable>
<Name>public.publickey</Name>
<!-- better to have this stored in the KVM, but this is a demo -->
<Value>
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwQNvdXmQMHaCj+cKOhaB
SVGMsgElLuAoU4yiHv/NFepQOKt5m3gcyK3t1sE2nMWebTQH1QLC9fANROeXVpJn
05E57LffR3RFp7bFT8dI6OG7xlpypUcw1KEx6D2uTRQ29GStq2/nM+HNu6RtHJi4
C+Z3dIUsW7nV0FjVZIsCxA1z/fPFVy8rGERaRR+tWHTm5U2jKXEw3ileUv7LGgWM
UMmxuqW2qyrkbVNC+gyI2AKmUV9bo/qLa0BrFxUrK2nRJlxmGnSA09s5CGKix2hP
GxBCvO4wHQ1Wt1PZzDO/fKlkxYiCdALLn8VwKS3JqgInnPUDl1tRi6fDEhL3lKFP
JwIDAQAB
-----END PUBLIC KEY-----
</Value>
</AssignVariable>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
39 changes: 39 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/AM-PrivateKey.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-PrivateKey">
<DisplayName>AM-PrivateKey</DisplayName>
<Properties/>
<AssignVariable>
<Name>private.privatekey</Name>
<!-- better to have this stored in the KVM, but this is a demo -->
<Value>
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDBA291eZAwdoKP
5wo6FoFJUYyyASUu4ChTjKIe/80V6lA4q3mbeBzIre3WwTacxZ5tNAfVAsL18A1E
55dWkmfTkTnst99HdEWntsVPx0jo4bvGWnKlRzDUoTHoPa5NFDb0ZK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Hzkz+qRWjnfowIg9sW13bYReDzxvVUgpDxAoGAX0nX
+dCGxC69Gy8Oom/kgbjojBI0SZi3yYOhh6ciVTdZIYSk97/KlkJmEIIs3lP8+81c
rShmz+ViTQESKHbNI4knZf8QYqYh9rQiWpR9d8PFY7T8zlkazQuUcMAy/VvALuku
+67c3GXlmg/nu8xI6SGfok+quGSVz2nFQCyRIZ0CgYBLt/uYBJokcuC5uNsy84uZ
WqEjrJem/JjPsmlJFOxSfMWPPeXFwno8o4qoFpPyxUN9rPPTC4wIusWDvfXX1eHB
yc4C9HX8qjg2nn1oVLO7CVEIxmrwUNcoS+wiyYJIhygViege6lshS5DjpQc4UQh+
SXJJ2CgUNZdFEN8y0L3JXA==
-----END PRIVATE KEY-----
</Value>
</AssignVariable>
</AssignMessage>
14 changes: 14 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/AM-Response.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-Response">
<DisplayName>AM-Response</DisplayName>
<Properties/>
<!-- <AssignTo createNew='false' transport='http' type='response'></AssignTo> -->
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<Set>
<Payload contentType="application/json">{
"status" : "ok",
"jwt" : "{output-jwt}"
}</Payload>
<StatusCode>200</StatusCode>
</Set>
</AssignMessage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<AccessEntity enabled="true" continueOnError="false" async="false" name="AccessEntity_ApiProduct">
<EntityType value="apiproduct"/>
<EntityIdentifier ref="request.queryparam.id" />
</AccessEntity>

4 changes: 4 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/AccessEntity_AppID.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<AccessEntity enabled="true" continueOnError="false" async="false" name="AccessEntity_AppID">
<EntityType value="app"/>
<EntityIdentifier ref="request.queryparam.id" type="appid"/>
</AccessEntity>
4 changes: 4 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/AccessEntity_AppName.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<AccessEntity enabled="true" continueOnError="false" async="false" name="AccessEntity_AppName">
<EntityType value="app"/>
<EntityIdentifier ref="request.queryparam.id" type="appname"/>
</AccessEntity>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<AccessEntity enabled="true" continueOnError="false" async="false" name="AccessEntity_Developer">
<EntityType value="developer"/>
<EntityIdentifier ref="request.queryparam.id" />
</AccessEntity>

12 changes: 12 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/AssignSCResponse.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AssignSCResponse">
<DisplayName>AssignSCResponse</DisplayName>
<Properties/>
<Set>
<Payload contentType="application/json" variablePrefix="@" variableSuffix="#">
@scjsonres#
</Payload>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="response"/>
</AssignMessage>
7 changes: 7 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/EncodeURI.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Script enabled="true" continueOnError="false" async="false" name="EncodeURI">
<DisplayName>EncodeURI</DisplayName>
<FaultRules/>
<Properties/>
<ResourceURL>py://encodeuri.py</ResourceURL>
</Script>
11 changes: 11 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/ExtractSCResponse.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="true" enabled="true" name="ExtractSCResponse">
<DisplayName>ExtractSCResponse</DisplayName>
<Properties/>
<Source clearPayload="false">SCResponse</Source>
<JSONPayload>
<Variable name="scjsonres" type="nodeset">
<JSONPath>$.</JSONPath>
</Variable>
</JSONPayload>
</ExtractVariables>
7 changes: 7 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/FlowCallout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlowCallout async="false" continueOnError="false" enabled="true" name="FlowCallout">
<DisplayName>FlowCallout</DisplayName>
<FaultRules/>
<Properties/>
<SharedFlowBundle>hybridperf-sfassignmessage</SharedFlowBundle>
</FlowCallout>
18 changes: 18 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/GenerateAccessToken.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OAuthV2 enabled="true" continueOnError="false" async="false" name="GenerateAccessToken">
<DisplayName>GenerateAccessToken</DisplayName>
<FaultRules/>
<Properties/>
<Attributes/>
<ExpiresIn>86400000</ExpiresIn>
<ExternalAuthorization>false</ExternalAuthorization>
<GrantType>request.queryparam.grant_type</GrantType>
<Operation>GenerateAccessToken</Operation>
<GenerateResponse enabled="true">
<Format>FORM_PARAM</Format>
</GenerateResponse>
<SupportedGrantTypes>
<GrantType>client_credentials</GrantType>
</SupportedGrantTypes>
<Tokens/>
</OAuthV2>
18 changes: 18 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/GenerateJWT.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<GenerateJWT async="false" continueOnError="false" enabled="true" name="GenerateJWT">
<DisplayName>GenerateJWT</DisplayName>
<Algorithm>RS256</Algorithm>
<PrivateKey>
<Value ref="private.privatekey"/>
<Id>optional-unique-identifier-for-privatekey-here</Id>
</PrivateKey>
<!-- including the optional Id element tells Apigee to generate a unique identifier for the JWT -->
<Id/>
<Subject ref="request.queryparam.subject"/>
<!-- issuer can be specified by ref= as well -->
<Issuer>urn://apigee-edge-JWT-policy-demonstration</Issuer>
<Audience>urn://Apigee</Audience>
<!-- specifying expiry is recommended but optional -->
<ExpiresIn>60m</ExpiresIn>
<OutputVariable>output-jwt</OutputVariable>
</GenerateJWT>
7 changes: 7 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/GenerateRandomNumber.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="GenerateRandomNumber">
<DisplayName>GenerateRandomNumber</DisplayName>
<FaultRules/>
<Properties/>
<ResourceURL>jsc://RandomNumber.js</ResourceURL>
</Javascript>
7 changes: 7 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/JSHeader.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Script enabled="true" continueOnError="false" async="false" name="JSHeader">
<DisplayName>JSHeader</DisplayName>
<FaultRules/>
<Properties/>
<ResourceURL>js://jsheader.js</ResourceURL>
</Script>
8 changes: 8 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/LimitByIP.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SpikeArrest enabled="true" continueOnError="false" async="false" name="LimitByIP">
<DisplayName>LimitByIP</DisplayName>
<FaultRules/>
<Properties/>
<Identifier ref="client.ip"/>
<Rate>50000ps</Rate>
</SpikeArrest>
13 changes: 13 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/LimitByQuota.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Quota enabled="true" continueOnError="false" async="false" name="LimitByQuota">
<DisplayName>LimitByQuota</DisplayName>
<FaultRules/>
<Properties/>
<Identifier ref="request.queryparam.quota"/>
<Allow count="5000000"/>
<Interval>1</Interval>
<Distributed>true</Distributed>
<PreciseAtSecondsLevel>false</PreciseAtSecondsLevel>
<Synchronous>false</Synchronous>
<TimeUnit>minute</TimeUnit>
</Quota>
13 changes: 13 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/LimitBySlowQuota.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Quota enabled="true" continueOnError="false" async="false" name="LimitBySlowQuota">
<DisplayName>LimitBySlowQuota</DisplayName>
<FaultRules/>
<Properties/>
<Identifier ref="request.queryparam.quota"/>
<Allow count="5000000"/>
<Interval>1</Interval>
<Distributed>true</Distributed>
<PreciseAtSecondsLevel>false</PreciseAtSecondsLevel>
<Synchronous>true</Synchronous>
<TimeUnit>minute</TimeUnit>
</Quota>
7 changes: 7 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/PYHeader.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Script enabled="true" continueOnError="false" async="false" name="PYHeader">
<DisplayName>PYHeader</DisplayName>
<FaultRules/>
<Properties/>
<ResourceURL>py://pyheader.py</ResourceURL>
</Script>
7 changes: 7 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/PYParse.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Script enabled="true" continueOnError="false" async="false" name="PYParse">
<DisplayName>PYParse</DisplayName>
<FaultRules/>
<Properties/>
<ResourceURL>py://pyparse.py</ResourceURL>
</Script>
12 changes: 12 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/RF-MissingParam.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RaiseFault name="RF-MissingParam">
<FaultResponse>
<Set>
<Headers/>
<Payload contentType="text/plain">Missing form Parameter</Payload>
<StatusCode>400</StatusCode>
<ReasonPhrase>Bad Request</ReasonPhrase>
</Set>
</FaultResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>
16 changes: 16 additions & 0 deletions perf-proxies/proxy/apiproxy/policies/Raise-Fault.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RaiseFault async="false" continueOnError="false" enabled="true" name="Raise-Fault">
<DisplayName>Raise-Fault</DisplayName>
<Properties/>
<FaultResponse>
<Set>
<Headers/>
<Payload contentType="text/plain">
Good job Google
</Payload>
<StatusCode>200</StatusCode>
<ReasonPhrase>Ok</ReasonPhrase>
</Set>
</FaultResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>
Loading