AWS-XRay
view release on metacpan or search on metacpan
t/10_plugin_ec2_v1.t view on Meta::CPAN
if ($env->{REQUEST_METHOD} ne 'GET') {
return [405, [], ['Method Not Allowed']];
}
my $path = $env->{PATH_INFO};
if ($path eq '/meta-data/instance-id') {
return [200, [], ['i-1234567890abcdef0']];
}
if ($path eq '/meta-data/placement/availability-zone') {
return [200, [], ['ap-northeast-1a']];
}
return [404, [], ['Not Found']];
}
);
},
max_wait => 10, # seconds
);
use AWS::XRay::Plugin::EC2;
$AWS::XRay::Plugin::EC2::_base_url = "http://127.0.0.1:" . $app_server->port;
sub myApp {
capture "remote1", sub { };
t/10_plugin_ec2_v2.t view on Meta::CPAN
$server->run(
sub {
my $env = shift;
my $method = $env->{REQUEST_METHOD};
my $path = $env->{PATH_INFO};
if ($method eq 'PUT') {
if (!$env->{HTTP_X_AWS_EC2_METADATA_TOKEN_TTL_SECONDS}) {
return [400, [], ['Bad Request']];
}
if ($path ne '/api/token') {
return [404, [], ['Not Found']];
}
return [200, [], [$token]];
}
if ($method eq 'GET') {
if (($env->{HTTP_X_AWS_EC2_METADATA_TOKEN} || '') ne $token) {
return [401, [], ['Unauthorized']];
}
if ($path eq '/meta-data/instance-id') {
return [200, [], ['i-1234567890abcdef0']];
}
if ($path eq '/meta-data/placement/availability-zone') {
return [200, [], ['ap-northeast-1a']];
}
return [404, [], ['Not Found']];
}
return [405, [], ['Method Not Allowed']];
}
);
},
max_wait => 10, # seconds
);
use AWS::XRay::Plugin::EC2;
$AWS::XRay::Plugin::EC2::_base_url = "http://127.0.0.1:" . $app_server->port;
( run in 1.950 second using v1.01-cache-2.11-cpan-39bf76dae61 )