Skip to content
Merged

Dev2 #152

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
2 changes: 2 additions & 0 deletions source/constructs/lib/ecs-image-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ function getOrCreateVpc(scope: Construct): ec2.IVpc {
vpcFromLookup.publicSubnets.forEach((subnet) => {
publicSubnetIds.push(subnet.subnetId);
});
// TODO: Try to use vpcFromLookup instead
const vpc = ec2.Vpc.fromVpcAttributes(scope, 'VpcFromAttributes', {
availabilityZones: vpcFromLookup.availabilityZones,
vpcId: vpcFromLookup.vpcId,
Expand All @@ -181,6 +182,7 @@ function getOrCreateVpc(scope: Construct): ec2.IVpc {

function getTaskSubnets(scope: Construct, vpc: ec2.IVpc): ec2.ISubnet[] {
const subnetIds: string[] = scope.node.tryGetContext('subnet_ids');
// TODO: use filter subnets from vpc
let subnets: ec2.ISubnet[] = [];
if (subnetIds) {
subnetIds.forEach((subnetId, index) => {
Expand Down
11 changes: 10 additions & 1 deletion source/new-image-handler/test/bench/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# Benchmark test

## curl.sh make http requests to urls in parallel
## curl.sh: make http requests to urls in parallel

```
# edit urls.txt

$ ./curl.sh urls.txt
$ N=10 ./curl.sh urls.txt # make 10 http requests simultaneously
```

## vegeta: http load test tools

install https://github.com/tsenart/vegeta firstly

```
# edit vegeta-urls.txt
cat vegeta-urls.txt | vegeta attack -duration=1m -rate=300 -timeout=300s -format=http | vegeta report
```
1 change: 1 addition & 0 deletions source/new-image-handler/test/bench/vegeta-urls.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GET http://<HOST>/example.jpg?x-oss-process=image/resize,s_300/quality,q_80/auto-orient,0/interlace,1/format,jpg
46 changes: 45 additions & 1 deletion source/new-image-handler/test/e2e/mkhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,48 @@
</html>
'''
PATHS = [
# resize
'example.jpg?x-oss-process=image/resize,w_100',
'example.jpg?x-oss-process=image/resize,h_50',
'example.jpg?x-oss-process=image/resize,w_100,m_lfit',
'example.jpg?x-oss-process=image/resize,w_100,m_mfit',
'example.jpg?x-oss-process=image/resize,w_100,h_67,m_fill',
'example.jpg?x-oss-process=image/resize,w_100,m_pad',
'example.jpg?x-oss-process=image/resize,h_100,w_100,m_fixed',
'example.jpg?x-oss-process=image/resize,h_100,m_lfit',
'example.jpg?x-oss-process=image/resize,l_100',
'example.jpg?x-oss-process=image/resize,m_fixed,h_100,w_100',
'example.jpg?x-oss-process=image/resize,m_fill,h_100,w_100',
'example.jpg?x-oss-process=image/resize,m_pad,h_100,w_100,color_FF0000',
'example.jpg?x-oss-process=image/resize,p_50',
# circle
'example.jpg?x-oss-process=image/circle,r_100',
# crop
'example.jpg?x-oss-process=image/crop,x_100,y_50',
'example.jpg?x-oss-process=image/crop,x_100,y_50,w_100,h_100',
'example.jpg?x-oss-process=image/crop,x_10,y_10,w_200,h_200,g_se',
# indexcrop
'example.jpg?x-oss-process=image/indexcrop,x_100,i_0',
# rounded-corners
'example.jpg?x-oss-process=image/rounded-corners,r_30',
'example.jpg?x-oss-process=image/crop,w_100,h_100/rounded-corners,r_10/format,png',
# rotate
'example.jpg?x-oss-process=image/rotate,70',
# blur
'example.jpg?x-oss-process=image/blur,r_3,s_2',
# bright
'example.jpg?x-oss-process=image/bright,50',
'example.jpg?x-oss-process=image/bright,-50',
# sharpen
'example.jpg?x-oss-process=image/sharpen,100',
# contrast
'example.jpg?x-oss-process=image/contrast,-50',
'example.jpg?x-oss-process=image/contrast,50',
# quality
'example.jpg?x-oss-process=image/resize,w_100/quality,q_30',
'example.jpg?x-oss-process=image/resize,w_100/quality,Q_30',
# interlace
'example.jpg?x-oss-process=image/resize,w_200/interlace,1',
# watermark
'example.jpg?x-oss-process=image/watermark,text_SGVsbG8gV29ybGQ',
'example.jpg?x-oss-process=image/watermark,text_SGVsbG8gV29ybGQ,g_nw',
Expand Down Expand Up @@ -62,7 +104,9 @@ def row(i, a, b):
])


s = TEMPLATE.format(body='\n'.join([row(i, EP_A + p, EP_B + p) for i, p in enumerate(PATHS)]))
s = TEMPLATE.format(body='\n'.join([
row(i, os.path.join(EP_A, p), os.path.join(EP_B, p)) for i, p in enumerate(PATHS)
]))
fname = 'index.html'

with open(fname, 'w') as fp:
Expand Down