[Groonga-commit] groonga/gcs [master] Add ACS response recorder

Back to archive index

Yoji SHIDARA null+****@clear*****
Thu Nov 8 19:13:17 JST 2012


Yoji SHIDARA	2012-11-08 19:13:17 +0900 (Thu, 08 Nov 2012)

  New Revision: 78999f2bc6b7f3360cd6139fd679e0c5e84331d1
  https://github.com/groonga/gcs/commit/78999f2bc6b7f3360cd6139fd679e0c5e84331d1

  Log:
    Add ACS response recorder

  Added files:
    tools/acs/.gitkeep
    tools/acs/CreateDomain-with-short-domain-name.txt
    tools/acs/DescribeDomains.txt
    tools/run-scenarios.js
    tools/scenarios.json

  Added: tools/acs/.gitkeep (+0 -0) 100644
===================================================================
--- /dev/null
+++ tools/acs/.gitkeep    2012-11-08 19:13:17 +0900 (e69de29)

  Added: tools/acs/CreateDomain-with-short-domain-name.txt (+14 -0) 100644
===================================================================
--- /dev/null
+++ tools/acs/CreateDomain-with-short-domain-name.txt    2012-11-08 19:13:17 +0900 (b94bbc3)
@@ -0,0 +1,14 @@
+HTTP/1.1 400 Bad Request
+x-amzn-requestid: de548fc6-298c-11e2-8f15-e551e85874bd
+content-type: text/xml
+content-length: 389
+date: Thu, 08 Nov 2012 10:12:57 GMT
+
+<ErrorResponse xmlns="http://cloudsearch.amazonaws.com/doc/2011-02-01">
+  <Error>
+    <Type>Sender</Type>
+    <Code>ValidationError</Code>
+    <Message>1 validation error detected: Value 'aa' at 'domainName' failed to satisfy constraint: Member must have length greater than or equal to 3</Message>
+  </Error>
+  <RequestId>de548fc6-298c-11e2-8f15-e551e85874bd</RequestId>
+</ErrorResponse>

  Added: tools/acs/DescribeDomains.txt (+14 -0) 100644
===================================================================
--- /dev/null
+++ tools/acs/DescribeDomains.txt    2012-11-08 19:13:17 +0900 (1072834)
@@ -0,0 +1,14 @@
+HTTP/1.1 200 OK
+x-amzn-requestid: de4b67f9-298c-11e2-a392-a97ede14f4ce
+content-type: text/xml
+content-length: 293
+date: Thu, 08 Nov 2012 10:12:57 GMT
+
+<DescribeDomainsResponse xmlns="http://cloudsearch.amazonaws.com/doc/2011-02-01">
+  <DescribeDomainsResult>
+    <DomainStatusList/>
+  </DescribeDomainsResult>
+  <ResponseMetadata>
+    <RequestId>de4b67f9-298c-11e2-a392-a97ede14f4ce</RequestId>
+  </ResponseMetadata>
+</DescribeDomainsResponse>

  Added: tools/run-scenarios.js (+52 -0) 100755
===================================================================
--- /dev/null
+++ tools/run-scenarios.js    2012-11-08 19:13:17 +0900 (4878c49)
@@ -0,0 +1,52 @@
+#!/usr/bin/env node
+
+/*
+ Set these environment variables:
+   * AWS_ACCESS_KEY_ID
+   * AWS_SECRET_ACCESS_KEY
+*/
+
+var awssum = require('awssum');
+var CloudSearch = awssum.load('amazon/cloudsearch').CloudSearch;
+var fs = require('fs');
+
+cs = new CloudSearch({
+  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
+  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
+});
+
+var scenarios = JSON.parse(fs.readFileSync(__dirname + '/scenarios.json'));
+
+CloudSearch.prototype.extractBody = function(options) {
+  return 'blob';
+};
+
+var baseDir = __dirname + '/acs';
+scenarios.forEach(function(scenario) {
+  console.log('Processing ' + scenario.name);
+  var filename = scenario.name.replace(/[^a-zA-Z0-9]+/g, '-') + '.txt';
+  cs[scenario.params.Action].call(cs, scenario.params, function(error, data) {
+    var response = error || data;
+    var statusCodeTable = {
+      404: 'Not Found',
+      400: 'Bad Request',
+      200: 'OK'
+    };
+
+    var statusCode = response.StatusCode;
+    if (!statusCodeTable[statusCode]) {
+      throw "Unknown status code " + statusCode;
+    }
+
+    var output = '';
+    output += 'HTTP/1.1 ' + statusCode + ' ' + statusCodeTable[statusCode] + '\r\n';
+    for (var key in response.Headers) {
+      output += key + ': ' + response.Headers[key] + '\r\n';
+    };
+    output += '\r\n';
+    output += response.Body.toString();
+    var destPath = baseDir + '/' + filename, output;
+    fs.writeFile(destPath, output);
+    console.log('Wrote ' + destPath);
+  });
+});

  Added: tools/scenarios.json (+10 -0) 100644
===================================================================
--- /dev/null
+++ tools/scenarios.json    2012-11-08 19:13:17 +0900 (040bb7c)
@@ -0,0 +1,10 @@
+[
+  {
+    "name": "DescribeDomains",
+    "params": {"Action": "DescribeDomains"}
+  },
+  {
+    "name": "CreateDomain with short domain name",
+    "params": {"Action": "CreateDomain", "DomainName": "aa"}
+  }
+]
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index