Skip to content

Commit a29b026

Browse files
committed
add perf benchmark policy
1 parent ce9f888 commit a29b026

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1296
-0
lines changed

Diff for: perf-proxies/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# API proxy for Performance Benchmark
2+
3+
This directory contains the API proxy and Sharedflow used to performance test
4+
Apigee X and Apigee hybrid instances.
5+
6+
## About this sample proxy
7+
8+
This API proxy uses the following policies
9+
10+
* Access Control
11+
* Access Entity
12+
* Validate OAuth
13+
* Validate API Key
14+
* JavaScript
15+
* Assign Message
16+
* Quota
17+
* XMLThreat Protection
18+
* GenerateAccessToken
19+
* Python Callout
20+
* XSLT
21+
* XMLToJSON
22+
* Raise-Fault
23+
* FlowCallout
24+
* ServiceCallout
25+
* GenerateJWT
26+
* VerifyJWT
27+
28+
The API Proxy is available on the basePath `/hybridperf`

Diff for: perf-proxies/proxy/apiproxy/hybrid_perf.xml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<APIProxy revision="25" name="hybrid_perf">
2+
<DisplayName>hybrid_perf</DisplayName>
3+
<Description>Performance Test App</Description>
4+
<CreatedAt>1596042552317</CreatedAt>
5+
<LastModifiedAt>1596042660545</LastModifiedAt>
6+
<BasePaths>/hybridperf</BasePaths>
7+
<Policies>
8+
<Policy>ValidMessage</Policy>
9+
<Policy>LimitBySlowQuota</Policy>
10+
<Policy>RejectURI</Policy>
11+
<Policy>LimitByIP</Policy>
12+
<Policy>SetPayload_AccessEntity_ApiProduct</Policy>
13+
<Policy>ValidateOAuth</Policy>
14+
<Policy>ValidateKey</Policy>
15+
<Policy>getURL</Policy>
16+
<Policy>AccessEntity_AppName</Policy>
17+
<Policy>SetPayload_AccessEntity_AppID</Policy>
18+
<Policy>SetPayload_AccessEntity_AppName</Policy>
19+
<Policy>JSHeader</Policy>
20+
<Policy>putURL</Policy>
21+
<Policy>RemoveQueryParams</Policy>
22+
<Policy>LimitByQuota</Policy>
23+
<Policy>AccessEntity_Developer</Policy>
24+
<Policy>SetCacheHeader</Policy>
25+
<Policy>ResponseCache</Policy>
26+
<Policy>XMLThreat</Policy>
27+
<Policy>GenerateAccessToken</Policy>
28+
<Policy>EncodeURI</Policy>
29+
<Policy>PYHeader</Policy>
30+
<Policy>GenerateRandomNumber</Policy>
31+
<Policy>PYParse</Policy>
32+
<Policy>AccessEntity_AppID</Policy>
33+
<Policy>SetPayload_AccessEntity_Developer</Policy>
34+
<Policy>XSLT</Policy>
35+
<Policy>AccessEntity_ApiProduct</Policy>
36+
<Policy>XMLToJSON</Policy>
37+
<Policy>assign-header</Policy>
38+
<Policy>Raise-Fault</Policy>
39+
<Policy>FlowCallout</Policy>
40+
<Policy>ServiceCallout</Policy>
41+
<Policy>SC-BuildRequest</Policy>
42+
<Policy>ExtractSCResponse</Policy>
43+
<Policy>AssignSCResponse</Policy>
44+
<Policy>ScJSON</Policy>
45+
<Policy>GenerateJWT</Policy>
46+
<Policy>VerifyJWT</Policy>
47+
<Policy>RF-MissingParam</Policy>
48+
<Policy>AM-PrivateKey</Policy>
49+
<Policy>AM-Response</Policy>
50+
<Policy>AM-JwtAuthorization</Policy>
51+
<Policy>add-cors</Policy>
52+
<Policy>ResponsePayload</Policy>
53+
</Policies>
54+
<ProxyEndpoints>
55+
<ProxyEndpoint>proxy</ProxyEndpoint>
56+
</ProxyEndpoints>
57+
<Resources>
58+
<Resource>py://pyparse.py</Resource>
59+
<Resource>py://encodeuri.py</Resource>
60+
<Resource>py://pyheader.py</Resource>
61+
<Resource>jsc://RandomNumber.js</Resource>
62+
<Resource>xsl://weatherxsl</Resource>
63+
<Resource>js://jsheader.js</Resource>
64+
</Resources>
65+
<TargetServers></TargetServers>
66+
<TargetEndpoints>
67+
<TargetEndpoint>static</TargetEndpoint>
68+
</TargetEndpoints>
69+
</APIProxy>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-JwtAuthorization">
3+
<DisplayName>AM-JwtAuthorization</DisplayName>
4+
<Properties/>
5+
<Add>
6+
<Headers/>
7+
<Header name="Authorization">Bearer {output-jwt}</Header>
8+
</Add>
9+
<AssignVariable>
10+
<Name>public.publickey</Name>
11+
<!-- better to have this stored in the KVM, but this is a demo -->
12+
<Value>
13+
-----BEGIN PUBLIC KEY-----
14+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwQNvdXmQMHaCj+cKOhaB
15+
SVGMsgElLuAoU4yiHv/NFepQOKt5m3gcyK3t1sE2nMWebTQH1QLC9fANROeXVpJn
16+
05E57LffR3RFp7bFT8dI6OG7xlpypUcw1KEx6D2uTRQ29GStq2/nM+HNu6RtHJi4
17+
C+Z3dIUsW7nV0FjVZIsCxA1z/fPFVy8rGERaRR+tWHTm5U2jKXEw3ileUv7LGgWM
18+
UMmxuqW2qyrkbVNC+gyI2AKmUV9bo/qLa0BrFxUrK2nRJlxmGnSA09s5CGKix2hP
19+
GxBCvO4wHQ1Wt1PZzDO/fKlkxYiCdALLn8VwKS3JqgInnPUDl1tRi6fDEhL3lKFP
20+
JwIDAQAB
21+
-----END PUBLIC KEY-----
22+
</Value>
23+
</AssignVariable>
24+
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
25+
<AssignTo createNew="false" transport="http" type="request"/>
26+
</AssignMessage>
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-PrivateKey">
3+
<DisplayName>AM-PrivateKey</DisplayName>
4+
<Properties/>
5+
<AssignVariable>
6+
<Name>private.privatekey</Name>
7+
<!-- better to have this stored in the KVM, but this is a demo -->
8+
<Value>
9+
-----BEGIN PRIVATE KEY-----
10+
MIIEvAIBADANBgkqhkiG9w0BAQ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iDgkjKje+Vd3GvCHQ0T21wV6XwxV4pZe2mUvLsbLAwJBNIpE
27+
nZXXFgDM4wKBgDHiYleHIBTBgy3gJRyHtSPg4hZMIAia19/qwT2EZ4pNgvUffIps
28+
ie43SOs5PLr7a9+QSrzKpj8GzRy/zY+Xijn8fmnK75BO21bOxJYqk7jzuOwfhAPV
29+
GfgP6Iyx0FOiCcUiWCnfoTHzkz+qRWjnfowIg9sW13bYReDzxvVUgpDxAoGAX0nX
30+
+dCGxC69Gy8Oom/kgbjojBI0SZi3yYOhh6ciVTdZIYSk97/KlkJmEIIs3lP8+81c
31+
rShmz+ViTQESKHbNI4knZf8QYqYh9rQiWpR9d8PFY7T8zlkazQuUcMAy/VvALuku
32+
+67c3GXlmg/nu8xI6SGfok+quGSVz2nFQCyRIZ0CgYBLt/uYBJokcuC5uNsy84uZ
33+
WqEjrJem/JjPsmlJFOxSfMWPPeXFwno8o4qoFpPyxUN9rPPTC4wIusWDvfXX1eHB
34+
yc4C9HX8qjg2nn1oVLO7CVEIxmrwUNcoS+wiyYJIhygViege6lshS5DjpQc4UQh+
35+
SXJJ2CgUNZdFEN8y0L3JXA==
36+
-----END PRIVATE KEY-----
37+
</Value>
38+
</AssignVariable>
39+
</AssignMessage>

Diff for: perf-proxies/proxy/apiproxy/policies/AM-Response.xml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-Response">
3+
<DisplayName>AM-Response</DisplayName>
4+
<Properties/>
5+
<!-- <AssignTo createNew='false' transport='http' type='response'></AssignTo> -->
6+
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
7+
<Set>
8+
<Payload contentType="application/json">{
9+
"status" : "ok",
10+
"jwt" : "{output-jwt}"
11+
}</Payload>
12+
<StatusCode>200</StatusCode>
13+
</Set>
14+
</AssignMessage>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<AccessEntity enabled="true" continueOnError="false" async="false" name="AccessEntity_ApiProduct">
2+
<EntityType value="apiproduct"/>
3+
<EntityIdentifier ref="request.queryparam.id" />
4+
</AccessEntity>
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<AccessEntity enabled="true" continueOnError="false" async="false" name="AccessEntity_AppID">
2+
<EntityType value="app"/>
3+
<EntityIdentifier ref="request.queryparam.id" type="appid"/>
4+
</AccessEntity>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<AccessEntity enabled="true" continueOnError="false" async="false" name="AccessEntity_AppName">
2+
<EntityType value="app"/>
3+
<EntityIdentifier ref="request.queryparam.id" type="appname"/>
4+
</AccessEntity>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<AccessEntity enabled="true" continueOnError="false" async="false" name="AccessEntity_Developer">
2+
<EntityType value="developer"/>
3+
<EntityIdentifier ref="request.queryparam.id" />
4+
</AccessEntity>
5+
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<AssignMessage async="false" continueOnError="false" enabled="true" name="AssignSCResponse">
3+
<DisplayName>AssignSCResponse</DisplayName>
4+
<Properties/>
5+
<Set>
6+
<Payload contentType="application/json" variablePrefix="@" variableSuffix="#">
7+
@scjsonres#
8+
</Payload>
9+
</Set>
10+
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
11+
<AssignTo createNew="false" transport="http" type="response"/>
12+
</AssignMessage>

Diff for: perf-proxies/proxy/apiproxy/policies/EncodeURI.xml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Script enabled="true" continueOnError="false" async="false" name="EncodeURI">
3+
<DisplayName>EncodeURI</DisplayName>
4+
<FaultRules/>
5+
<Properties/>
6+
<ResourceURL>py://encodeuri.py</ResourceURL>
7+
</Script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<ExtractVariables async="false" continueOnError="true" enabled="true" name="ExtractSCResponse">
3+
<DisplayName>ExtractSCResponse</DisplayName>
4+
<Properties/>
5+
<Source clearPayload="false">SCResponse</Source>
6+
<JSONPayload>
7+
<Variable name="scjsonres" type="nodeset">
8+
<JSONPath>$.</JSONPath>
9+
</Variable>
10+
</JSONPayload>
11+
</ExtractVariables>

Diff for: perf-proxies/proxy/apiproxy/policies/FlowCallout.xml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<FlowCallout async="false" continueOnError="false" enabled="true" name="FlowCallout">
3+
<DisplayName>FlowCallout</DisplayName>
4+
<FaultRules/>
5+
<Properties/>
6+
<SharedFlowBundle>hybridperf-sfassignmessage</SharedFlowBundle>
7+
</FlowCallout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<OAuthV2 enabled="true" continueOnError="false" async="false" name="GenerateAccessToken">
3+
<DisplayName>GenerateAccessToken</DisplayName>
4+
<FaultRules/>
5+
<Properties/>
6+
<Attributes/>
7+
<ExpiresIn>86400000</ExpiresIn>
8+
<ExternalAuthorization>false</ExternalAuthorization>
9+
<GrantType>request.queryparam.grant_type</GrantType>
10+
<Operation>GenerateAccessToken</Operation>
11+
<GenerateResponse enabled="true">
12+
<Format>FORM_PARAM</Format>
13+
</GenerateResponse>
14+
<SupportedGrantTypes>
15+
<GrantType>client_credentials</GrantType>
16+
</SupportedGrantTypes>
17+
<Tokens/>
18+
</OAuthV2>

Diff for: perf-proxies/proxy/apiproxy/policies/GenerateJWT.xml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<GenerateJWT async="false" continueOnError="false" enabled="true" name="GenerateJWT">
3+
<DisplayName>GenerateJWT</DisplayName>
4+
<Algorithm>RS256</Algorithm>
5+
<PrivateKey>
6+
<Value ref="private.privatekey"/>
7+
<Id>optional-unique-identifier-for-privatekey-here</Id>
8+
</PrivateKey>
9+
<!-- including the optional Id element tells Apigee to generate a unique identifier for the JWT -->
10+
<Id/>
11+
<Subject ref="request.queryparam.subject"/>
12+
<!-- issuer can be specified by ref= as well -->
13+
<Issuer>urn://apigee-edge-JWT-policy-demonstration</Issuer>
14+
<Audience>urn://Apigee</Audience>
15+
<!-- specifying expiry is recommended but optional -->
16+
<ExpiresIn>60m</ExpiresIn>
17+
<OutputVariable>output-jwt</OutputVariable>
18+
</GenerateJWT>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="GenerateRandomNumber">
3+
<DisplayName>GenerateRandomNumber</DisplayName>
4+
<FaultRules/>
5+
<Properties/>
6+
<ResourceURL>jsc://RandomNumber.js</ResourceURL>
7+
</Javascript>

Diff for: perf-proxies/proxy/apiproxy/policies/JSHeader.xml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Script enabled="true" continueOnError="false" async="false" name="JSHeader">
3+
<DisplayName>JSHeader</DisplayName>
4+
<FaultRules/>
5+
<Properties/>
6+
<ResourceURL>js://jsheader.js</ResourceURL>
7+
</Script>

Diff for: perf-proxies/proxy/apiproxy/policies/LimitByIP.xml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<SpikeArrest enabled="true" continueOnError="false" async="false" name="LimitByIP">
3+
<DisplayName>LimitByIP</DisplayName>
4+
<FaultRules/>
5+
<Properties/>
6+
<Identifier ref="client.ip"/>
7+
<Rate>50000ps</Rate>
8+
</SpikeArrest>
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Quota enabled="true" continueOnError="false" async="false" name="LimitByQuota">
3+
<DisplayName>LimitByQuota</DisplayName>
4+
<FaultRules/>
5+
<Properties/>
6+
<Identifier ref="request.queryparam.quota"/>
7+
<Allow count="5000000"/>
8+
<Interval>1</Interval>
9+
<Distributed>true</Distributed>
10+
<PreciseAtSecondsLevel>false</PreciseAtSecondsLevel>
11+
<Synchronous>false</Synchronous>
12+
<TimeUnit>minute</TimeUnit>
13+
</Quota>
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Quota enabled="true" continueOnError="false" async="false" name="LimitBySlowQuota">
3+
<DisplayName>LimitBySlowQuota</DisplayName>
4+
<FaultRules/>
5+
<Properties/>
6+
<Identifier ref="request.queryparam.quota"/>
7+
<Allow count="5000000"/>
8+
<Interval>1</Interval>
9+
<Distributed>true</Distributed>
10+
<PreciseAtSecondsLevel>false</PreciseAtSecondsLevel>
11+
<Synchronous>true</Synchronous>
12+
<TimeUnit>minute</TimeUnit>
13+
</Quota>

Diff for: perf-proxies/proxy/apiproxy/policies/PYHeader.xml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Script enabled="true" continueOnError="false" async="false" name="PYHeader">
3+
<DisplayName>PYHeader</DisplayName>
4+
<FaultRules/>
5+
<Properties/>
6+
<ResourceURL>py://pyheader.py</ResourceURL>
7+
</Script>

Diff for: perf-proxies/proxy/apiproxy/policies/PYParse.xml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Script enabled="true" continueOnError="false" async="false" name="PYParse">
3+
<DisplayName>PYParse</DisplayName>
4+
<FaultRules/>
5+
<Properties/>
6+
<ResourceURL>py://pyparse.py</ResourceURL>
7+
</Script>
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<RaiseFault name="RF-MissingParam">
3+
<FaultResponse>
4+
<Set>
5+
<Headers/>
6+
<Payload contentType="text/plain">Missing form Parameter</Payload>
7+
<StatusCode>400</StatusCode>
8+
<ReasonPhrase>Bad Request</ReasonPhrase>
9+
</Set>
10+
</FaultResponse>
11+
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
12+
</RaiseFault>

Diff for: perf-proxies/proxy/apiproxy/policies/Raise-Fault.xml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<RaiseFault async="false" continueOnError="false" enabled="true" name="Raise-Fault">
3+
<DisplayName>Raise-Fault</DisplayName>
4+
<Properties/>
5+
<FaultResponse>
6+
<Set>
7+
<Headers/>
8+
<Payload contentType="text/plain">
9+
Good job Google
10+
</Payload>
11+
<StatusCode>200</StatusCode>
12+
<ReasonPhrase>Ok</ReasonPhrase>
13+
</Set>
14+
</FaultResponse>
15+
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
16+
</RaiseFault>

0 commit comments

Comments
 (0)