heirloom 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/.gitignore +1 -0
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +4 -1
  5. data/README.md +9 -0
  6. data/heirloom.gemspec +8 -2
  7. data/lib/heirloom.rb +9 -0
  8. data/lib/heirloom/acl/s3.rb +1 -1
  9. data/lib/heirloom/aws/simpledb.rb +25 -2
  10. data/lib/heirloom/catalog.rb +37 -0
  11. data/lib/heirloom/cli.rb +36 -3
  12. data/lib/heirloom/cli/authorize.rb +5 -1
  13. data/lib/heirloom/cli/catalog.rb +5 -1
  14. data/lib/heirloom/cli/cleanup.rb +74 -0
  15. data/lib/heirloom/cli/destroy.rb +5 -1
  16. data/lib/heirloom/cli/download.rb +5 -1
  17. data/lib/heirloom/cli/list.rb +5 -1
  18. data/lib/heirloom/cli/rotate.rb +5 -1
  19. data/lib/heirloom/cli/setup.rb +5 -1
  20. data/lib/heirloom/cli/show.rb +5 -1
  21. data/lib/heirloom/cli/tag.rb +5 -1
  22. data/lib/heirloom/cli/teardown.rb +21 -11
  23. data/lib/heirloom/cli/upload.rb +5 -1
  24. data/lib/heirloom/exceptions.rb +3 -0
  25. data/lib/heirloom/logger.rb +6 -1
  26. data/lib/heirloom/version.rb +1 -1
  27. data/spec/acl/s3_spec.rb +3 -2
  28. data/spec/aws/simpledb_spec.rb +35 -1
  29. data/spec/catalog_spec.rb +45 -2
  30. data/spec/cli/teardown_spec.rb +60 -28
  31. data/spec/cli_spec.rb +12 -0
  32. data/spec/fixtures/cassettes/Heirloom_AWS_SimpleDB/select/should_be_able_to_offset_results.yml +81 -0
  33. data/spec/fixtures/cassettes/Heirloom_AWS_SimpleDB/select/should_get_results.yml +34 -0
  34. data/spec/fixtures/cassettes/Heirloom_AWS_SimpleDB/select/should_yield_when_requested.yml +81 -0
  35. data/spec/fixtures/create_test_data.sh +28 -0
  36. data/spec/heirloom_spec.rb +11 -0
  37. data/spec/integration/authorize_spec.rb +79 -0
  38. data/spec/integration/cleanup_spec.rb +77 -0
  39. data/spec/logger_spec.rb +1 -1
  40. data/spec/spec_helper.rb +89 -5
  41. data/watchr.rb +101 -0
  42. metadata +84 -35
  43. data/.rvmrc +0 -1
@@ -0,0 +1,34 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://sdb.us-west-1.amazonaws.com/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: AWSAccessKeyId=<AWSACCESSKEYID>&Action=Select&ConsistentRead=false&SelectExpression=select%20%2A%20from%20%60heirloom_test_data%60%20where%20built_at%20%3E%20%272000-01-01T00%3A00%3A00.000Z%27%20order%20by%20built_at%20desc&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2013-05-24T22%3A59%3A42Z&Version=2009-04-15&Signature=3TEKgadY9t0b%2BB0O2dYcX3V3yV1X2rPGBOzxGfkh%2FNU%3D
9
+ headers:
10
+ User-Agent:
11
+ - fog/1.10.1
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded; charset=utf-8
14
+ response:
15
+ status:
16
+ code: 200
17
+ message:
18
+ headers:
19
+ Content-Type:
20
+ - text/xml
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Date:
24
+ - Fri, 24 May 2013 22:59:14 GMT
25
+ Server:
26
+ - Amazon SimpleDB
27
+ body:
28
+ encoding: US-ASCII
29
+ string: ! '<?xml version="1.0"?>
30
+
31
+ <SelectResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"><SelectResult><Item><Name>v10</Name><Attribute><Name>id</Name><Value>v10</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:35:06Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v10.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v10.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v10.tar.gz</Value></Attribute></Item><Item><Name>v9</Name><Attribute><Name>id</Name><Value>v9</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:59Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v9.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v9.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v9.tar.gz</Value></Attribute><Attribute><Name>preserve</Name><Value>true</Value></Attribute></Item><Item><Name>v8</Name><Attribute><Name>id</Name><Value>v8</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:54Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v8.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v8.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v8.tar.gz</Value></Attribute></Item><Item><Name>v7</Name><Attribute><Name>id</Name><Value>v7</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:49Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v7.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v7.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v7.tar.gz</Value></Attribute></Item><Item><Name>v6</Name><Attribute><Name>id</Name><Value>v6</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:42Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v6.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v6.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v6.tar.gz</Value></Attribute><Attribute><Name>preserve</Name><Value>true</Value></Attribute></Item><Item><Name>v5</Name><Attribute><Name>id</Name><Value>v5</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:37Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v5.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v5.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v5.tar.gz</Value></Attribute></Item><Item><Name>v4</Name><Attribute><Name>id</Name><Value>v4</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:31Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v4.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v4.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v4.tar.gz</Value></Attribute></Item><Item><Name>v3</Name><Attribute><Name>id</Name><Value>v3</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:23Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v3.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v3.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v3.tar.gz</Value></Attribute><Attribute><Name>preserve</Name><Value>true</Value></Attribute></Item><Item><Name>v2</Name><Attribute><Name>id</Name><Value>v2</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:18Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v2.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v2.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v2.tar.gz</Value></Attribute></Item><Item><Name>v1</Name><Attribute><Name>id</Name><Value>v1</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:12Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v1.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v1.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v1.tar.gz</Value></Attribute></Item></SelectResult><ResponseMetadata><RequestId>ca106a7b-ec9a-c18a-cb06-ca5a0e1b2d96</RequestId><BoxUsage>0.0001051540</BoxUsage></ResponseMetadata></SelectResponse>'
32
+ http_version:
33
+ recorded_at: Fri, 24 May 2013 22:59:42 GMT
34
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,81 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://sdb.us-west-1.amazonaws.com/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: AWSAccessKeyId=<AWSACCESSKEYID>&Action=Select&ConsistentRead=false&SelectExpression=select%20%2A%20from%20%60heirloom_test_data%60%20where%20built_at%20%3E%20%272000-01-01T00%3A00%3A00.000Z%27%20order%20by%20built_at%20desc%20limit%202&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2013-05-24T22%3A59%3A43Z&Version=2009-04-15&Signature=lzxP75rECq29CImypSCEOnvjd2csFHst9%2FjpteCF%2Fo0%3D
9
+ headers:
10
+ User-Agent:
11
+ - fog/1.10.1
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded; charset=utf-8
14
+ response:
15
+ status:
16
+ code: 200
17
+ message:
18
+ headers:
19
+ Content-Type:
20
+ - text/xml
21
+ Transfer-Encoding:
22
+ - chunked
23
+ Date:
24
+ - Fri, 24 May 2013 22:59:15 GMT
25
+ Server:
26
+ - Amazon SimpleDB
27
+ body:
28
+ encoding: US-ASCII
29
+ string: ! '<?xml version="1.0"?>
30
+
31
+ <SelectResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"><SelectResult><Item><Name>v10</Name><Attribute><Name>id</Name><Value>v10</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:35:06Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v10.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v10.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v10.tar.gz</Value></Attribute></Item><Item><Name>v9</Name><Attribute><Name>id</Name><Value>v9</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:59Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v9.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v9.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v9.tar.gz</Value></Attribute><Attribute><Name>preserve</Name><Value>true</Value></Attribute></Item><NextToken>rO0ABXNyACdjb20uYW1hem9uLnNkcy5RdWVyeVByb2Nlc3Nvci5Nb3JlVG9rZW7racXLnINNqwMA
32
+
33
+ C0kAFGluaXRpYWxDb25qdW5jdEluZGV4WgAOaXNQYWdlQm91bmRhcnlKAAxsYXN0RW50aXR5SURa
34
+
35
+ AApscnFFbmFibGVkSQAPcXVlcnlDb21wbGV4aXR5SgATcXVlcnlTdHJpbmdDaGVja3N1bUkACnVu
36
+
37
+ aW9uSW5kZXhaAA11c2VRdWVyeUluZGV4TAANY29uc2lzdGVudExTTnQAEkxqYXZhL2xhbmcvU3Ry
38
+
39
+ aW5nO0wAEmxhc3RBdHRyaWJ1dGVWYWx1ZXEAfgABTAAJc29ydE9yZGVydAAvTGNvbS9hbWF6b24v
40
+
41
+ c2RzL1F1ZXJ5UHJvY2Vzc29yL1F1ZXJ5JFNvcnRPcmRlcjt4cAAAAAAAAAAAAAAAAAkAAAAAAQAA
42
+
43
+ AABg70EkAAAAAAFwdAAUMjAxMy0wNS0yNFQyMjozNDo1OVp+cgAtY29tLmFtYXpvbi5zZHMuUXVl
44
+
45
+ cnlQcm9jZXNzb3IuUXVlcnkkU29ydE9yZGVyAAAAAAAAAAASAAB4cgAOamF2YS5sYW5nLkVudW0A
46
+
47
+ AAAAAAAAABIAAHhwdAAKREVTQ0VORElOR3g=</NextToken></SelectResult><ResponseMetadata><RequestId>fc271d38-5ebe-a4f9-3d1e-782ed45e8496</RequestId><BoxUsage>0.0000320052</BoxUsage></ResponseMetadata></SelectResponse>'
48
+ http_version:
49
+ recorded_at: Fri, 24 May 2013 22:59:43 GMT
50
+ - request:
51
+ method: post
52
+ uri: https://sdb.us-west-1.amazonaws.com/
53
+ body:
54
+ encoding: US-ASCII
55
+ string: AWSAccessKeyId=<AWSACCESSKEYID>&Action=Select&ConsistentRead=false&NextToken=rO0ABXNyACdjb20uYW1hem9uLnNkcy5RdWVyeVByb2Nlc3Nvci5Nb3JlVG9rZW7racXLnINNqwMA%0AC0kAFGluaXRpYWxDb25qdW5jdEluZGV4WgAOaXNQYWdlQm91bmRhcnlKAAxsYXN0RW50aXR5SURa%0AAApscnFFbmFibGVkSQAPcXVlcnlDb21wbGV4aXR5SgATcXVlcnlTdHJpbmdDaGVja3N1bUkACnVu%0AaW9uSW5kZXhaAA11c2VRdWVyeUluZGV4TAANY29uc2lzdGVudExTTnQAEkxqYXZhL2xhbmcvU3Ry%0AaW5nO0wAEmxhc3RBdHRyaWJ1dGVWYWx1ZXEAfgABTAAJc29ydE9yZGVydAAvTGNvbS9hbWF6b24v%0Ac2RzL1F1ZXJ5UHJvY2Vzc29yL1F1ZXJ5JFNvcnRPcmRlcjt4cAAAAAAAAAAAAAAAAAkAAAAAAQAA%0AAABg70EkAAAAAAFwdAAUMjAxMy0wNS0yNFQyMjozNDo1OVp%2BcgAtY29tLmFtYXpvbi5zZHMuUXVl%0AcnlQcm9jZXNzb3IuUXVlcnkkU29ydE9yZGVyAAAAAAAAAAASAAB4cgAOamF2YS5sYW5nLkVudW0A%0AAAAAAAAAABIAAHhwdAAKREVTQ0VORElOR3g%3D&SelectExpression=select%20%2A%20from%20%60heirloom_test_data%60%20where%20built_at%20%3E%20%272000-01-01T00%3A00%3A00.000Z%27%20order%20by%20built_at%20desc&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2013-05-24T22%3A59%3A43Z&Version=2009-04-15&Signature=4zMNfubmGc4NXg%2FUJxWUrZcMT%2BRAsdlDz4cUDj01hJw%3D
56
+ headers:
57
+ User-Agent:
58
+ - fog/1.10.1
59
+ Content-Type:
60
+ - application/x-www-form-urlencoded; charset=utf-8
61
+ response:
62
+ status:
63
+ code: 200
64
+ message:
65
+ headers:
66
+ Content-Type:
67
+ - text/xml
68
+ Transfer-Encoding:
69
+ - chunked
70
+ Date:
71
+ - Fri, 24 May 2013 22:59:15 GMT
72
+ Server:
73
+ - Amazon SimpleDB
74
+ body:
75
+ encoding: US-ASCII
76
+ string: ! '<?xml version="1.0"?>
77
+
78
+ <SelectResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/"><SelectResult><Item><Name>v8</Name><Attribute><Name>id</Name><Value>v8</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:54Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v8.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v8.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v8.tar.gz</Value></Attribute></Item><Item><Name>v7</Name><Attribute><Name>id</Name><Value>v7</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:49Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v7.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v7.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v7.tar.gz</Value></Attribute></Item><Item><Name>v6</Name><Attribute><Name>id</Name><Value>v6</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:42Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v6.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v6.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v6.tar.gz</Value></Attribute><Attribute><Name>preserve</Name><Value>true</Value></Attribute></Item><Item><Name>v5</Name><Attribute><Name>id</Name><Value>v5</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:37Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v5.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v5.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v5.tar.gz</Value></Attribute></Item><Item><Name>v4</Name><Attribute><Name>id</Name><Value>v4</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:31Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v4.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v4.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v4.tar.gz</Value></Attribute></Item><Item><Name>v3</Name><Attribute><Name>id</Name><Value>v3</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:23Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v3.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v3.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v3.tar.gz</Value></Attribute><Attribute><Name>preserve</Name><Value>true</Value></Attribute></Item><Item><Name>v2</Name><Attribute><Name>id</Name><Value>v2</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:18Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v2.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v2.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v2.tar.gz</Value></Attribute></Item><Item><Name>v1</Name><Attribute><Name>id</Name><Value>v1</Value></Attribute><Attribute><Name>encrypted</Name><Value>false</Value></Attribute><Attribute><Name>built_at</Name><Value>2013-05-24T22:34:12Z</Value></Attribute><Attribute><Name>bucket_prefix</Name><Value>heirloom-integration-tests</Value></Attribute><Attribute><Name>built_by</Name><Value>dvaughn1@sdgl114414452</Value></Attribute><Attribute><Name>us-west-1-s3-url</Name><Value>s3://heirloom-integration-tests-us-west-1/test_data/v1.tar.gz</Value></Attribute><Attribute><Name>us-west-1-http-url</Name><Value>http://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v1.tar.gz</Value></Attribute><Attribute><Name>us-west-1-https-url</Name><Value>https://s3-us-west-1.amazonaws.com/heirloom-integration-tests-us-west-1/test_data/v1.tar.gz</Value></Attribute></Item></SelectResult><ResponseMetadata><RequestId>c33e0bf1-ac14-4040-ab97-a71603c723ef</RequestId><BoxUsage>0.0000868648</BoxUsage></ResponseMetadata></SelectResponse>'
79
+ http_version:
80
+ recorded_at: Fri, 24 May 2013 22:59:43 GMT
81
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env bash
2
+
3
+ if [ -z "$HEIRLOOM_INTEGRATION_BUCKET_PREFIX" ]
4
+ then
5
+ echo "Set HEIRLOOM_INTEGRATION_BUCKET_PREFIX to run integration data setup."
6
+ echo "This value will be used as the bucket prefix and name."
7
+ exit 1
8
+ fi
9
+
10
+ TMPDIR=`mktemp -d /tmp/heirloom.XXXXXX` || exit 1
11
+
12
+ heirloom setup -n $HEIRLOOM_INTEGRATION_BUCKET_PREFIX -b $HEIRLOOM_INTEGRATION_BUCKET_PREFIX -e integration -f
13
+
14
+ echo 'Hello World!' > $TMPDIR/index.html
15
+
16
+ for i in {1..10}
17
+ do
18
+ heirloom upload -n $HEIRLOOM_INTEGRATION_BUCKET_PREFIX -d $TMPDIR -i v$i -e integration
19
+ let "m = $i % 3"
20
+ if [ "$m" == "0" ]
21
+ then
22
+ heirloom tag -n $HEIRLOOM_INTEGRATION_BUCKET_PREFIX -i v$i -a preserve -u true -e integration
23
+ fi
24
+ done
25
+
26
+ rm -rf $TMPDIR
27
+
28
+
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Heirloom do
4
+
5
+ it "should have a global logger" do
6
+ expect {
7
+ Heirloom.log
8
+ }.not_to raise_error
9
+ end
10
+
11
+ end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+ require 'heirloom/cli'
3
+ require 'heirloom/logger'
4
+
5
+ describe "authorize", :integration => true do
6
+
7
+ before do
8
+ @bucket_prefix = ENV['HEIRLOOM_INTEGRATION_BUCKET_PREFIX']
9
+ @name = @bucket_prefix
10
+ @domain = "heirloom_#{@name}"
11
+ end
12
+
13
+ it "should require accounts, id, and name" do
14
+ reset_env
15
+
16
+ @output = capture(:stdout) do
17
+
18
+ expect {
19
+ Heirloom::CLI::Authorize.new.authorize
20
+ }.to raise_error SystemExit
21
+
22
+ end
23
+
24
+ @output.should =~ /Option 'accounts' required but not specified./
25
+ @output.should =~ /Option 'id' required but not specified./
26
+ @output.should =~ /Option 'name' required but not specified./
27
+ end
28
+
29
+ context "performing authorization of non-existent account" do
30
+
31
+ before do
32
+ @tmp_dir = create_temp_heirloom_content
33
+ reset_env(
34
+ :bucket_prefix => @bucket_prefix,
35
+ :force => true,
36
+ :metadata_region => 'us-west-1',
37
+ :name => @name,
38
+ :region => ['us-west-1']
39
+ )
40
+ Heirloom::CLI::Setup.new.setup
41
+ # give the bucket a chance to propagate
42
+ wait_for_aws
43
+
44
+ reset_env(
45
+ :name => @name,
46
+ :id => "v1",
47
+ :directory => @tmp_dir
48
+ )
49
+ Heirloom::CLI::Upload.new.upload
50
+ end
51
+
52
+ after do
53
+ reset_env(
54
+ :name => @name,
55
+ :force => true,
56
+ :keep_buckets => true
57
+ )
58
+ Heirloom::CLI::Teardown.new.teardown
59
+ FileUtils.remove_entry @tmp_dir
60
+ end
61
+
62
+ it "should try to authorize but fail" do
63
+ reset_env(
64
+ :name => @name,
65
+ :id => "v1",
66
+ :accounts => ["X" * 64]
67
+ )
68
+ expect {
69
+ Heirloom::CLI::Authorize.new.authorize
70
+ }.to raise_error(Excon::Errors::BadRequest) { |err|
71
+ err.response.status.should == 400
72
+ err.response.body.should =~ /InvalidArgument/
73
+ err.response.body.should =~ /Invalid id/
74
+ }
75
+ end
76
+
77
+ end
78
+
79
+ end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+ require 'heirloom/cli'
3
+ require 'heirloom/logger'
4
+
5
+ describe "cleanup", :integration => true do
6
+
7
+ before do
8
+ @bucket_prefix = ENV['HEIRLOOM_INTEGRATION_BUCKET_PREFIX']
9
+ @name = @bucket_prefix
10
+ @domain = "heirloom_#{@name}"
11
+ end
12
+
13
+ it "should require name" do
14
+ reset_env
15
+
16
+ Heirloom.log.should_receive(:error)
17
+ .with("Option 'name' required but not specified.")
18
+
19
+ expect {
20
+ Heirloom::CLI::Cleanup.new.cleanup
21
+ }.to raise_error SystemExit
22
+
23
+ end
24
+
25
+ context "setting up and tearing down" do
26
+
27
+ before do
28
+ @tmp_dir = create_temp_heirloom_content
29
+
30
+ reset_env(
31
+ :bucket_prefix => @bucket_prefix,
32
+ :force => true,
33
+ :metadata_region => 'us-west-1',
34
+ :name => @name,
35
+ :region => ['us-west-1']
36
+ )
37
+ Heirloom::CLI::Setup.new.setup
38
+ # give the bucket a chance to propagate
39
+ wait_for_aws
40
+
41
+ @sdb = Heirloom::AWS::SimpleDB.new :config => (Heirloom::Config.new :environment => 'integration')
42
+ end
43
+
44
+ after do
45
+ reset_env(
46
+ :name => @name,
47
+ :force => true,
48
+ :keep_buckets => true
49
+ )
50
+ Heirloom::CLI::Teardown.new.teardown
51
+ FileUtils.remove_entry @tmp_dir
52
+ end
53
+
54
+ it "should delete some number of archives from an heirloom" do
55
+ (1..3).each do |i|
56
+ reset_env(
57
+ :id => "v#{i}",
58
+ :name => @name,
59
+ :directory => @tmp_dir,
60
+ :metadata_region => 'us-west-1'
61
+ )
62
+ Heirloom::CLI::Upload.new.upload
63
+ end
64
+
65
+ reset_env(
66
+ :name => @name,
67
+ :keep => 2
68
+ )
69
+ Heirloom::CLI::Cleanup.new.cleanup
70
+ wait_for_aws
71
+
72
+ @sdb.count(@domain).should == 2
73
+ end
74
+
75
+ end
76
+
77
+ end
@@ -11,7 +11,7 @@ describe Heirloom do
11
11
 
12
12
  it "should create a new logger object when one is not passed" do
13
13
  logger_mock = mock 'logger'
14
- Logger.should_receive(:new).with(STDOUT).and_return logger_mock
14
+ Logger.should_receive(:new).with($stdout).and_return logger_mock
15
15
  logger_mock.should_receive(:info).with 'a message'
16
16
  logger_mock.should_receive(:datetime_format=).with '%Y-%m-%dT%H:%M:%S%z'
17
17
  logger_mock.should_receive(:formatter=)
@@ -1,26 +1,110 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start do
4
+ add_filter '/spec'
5
+ end if ENV["COVERAGE"]
6
+
7
+ require 'hashie'
1
8
  require 'rubygems'
2
9
  require 'bundler/setup'
10
+ require 'vcr'
3
11
 
4
12
  require 'heirloom'
5
13
 
14
+ HEIRLOOM_INT_BP = ENV['HEIRLOOM_INTEGRATION_BUCKET_PREFIX']
15
+ RUN_INTEGRATION_TESTS = HEIRLOOM_INT_BP && !HEIRLOOM_INT_BP.empty?
16
+
6
17
  module SpecHelpers
7
18
 
8
- def mock_config(args={})
9
- args[:logger] ||= stub :debug => true, :info => true, :warn => true, :error => true
19
+ def mock_log
20
+ mock 'log', :debug => true, :info => true, :warn => true, :error => true, :level= => true
21
+ end
22
+
23
+ def mock_config(args = {})
24
+ args[:logger] ||= mock_log
10
25
  args[:access_key] ||= 'key'
11
26
  args[:secret_key] ||= 'secret'
12
27
  args[:metadata_region] ||= 'us-west-1'
13
28
  args[:use_iam_profile] ||= false
14
29
 
15
- config_mock = mock 'config'
16
- config_mock.stub args
30
+ Hashie::Mash.new args
31
+ end
17
32
 
18
- config_mock
33
+ end
34
+
35
+ module IntegrationHelpers
36
+ def integration_or_mock_config
37
+ if RUN_INTEGRATION_TESTS && File.exists?("#{ENV['HOME']}/.heirloom.yml")
38
+ begin
39
+ Heirloom::Config.new(:environment => 'integration', :logger => mock_log)
40
+ rescue SystemExit
41
+ mock_config
42
+ end
43
+ else
44
+ mock_config
45
+ end
46
+ end
47
+
48
+ def wait_for_aws(num_seconds = 5)
49
+ sleep num_seconds
50
+ end
51
+
52
+ def create_temp_heirloom_content
53
+ tmp_dir = Dir.mktmpdir
54
+ File.open(File.join(tmp_dir, 'index.html'), 'w') do |f|
55
+ f.write 'Hello World!'
56
+ end
57
+ tmp_dir
58
+ end
59
+
60
+ def reset_env(opts = {})
61
+ opts[:environment] = 'integration'
62
+ opts[:log_level] = 'debug'
63
+ opts[:metadata_region] = 'us-west-1'
64
+
65
+ Trollop.stub :options => opts
66
+ end
67
+
68
+ def capture(*streams)
69
+ streams.map! { |stream| stream.to_s }
70
+ begin
71
+ result = StringIO.new
72
+ streams.each { |stream| eval "$#{stream} = result" }
73
+ yield
74
+ ensure
75
+ streams.each { |stream| eval "$#{stream} = #{stream.upcase}" }
76
+ end
77
+ result.string
78
+ end
79
+
80
+ end
81
+
82
+ VCR.configure do |config|
83
+
84
+ config.allow_http_connections_when_no_cassette = true
85
+ config.cassette_library_dir = 'spec/fixtures/cassettes'
86
+ config.hook_into :excon
87
+ config.configure_rspec_metadata!
88
+
89
+ if RUN_INTEGRATION_TESTS
90
+ heirloom_integration_config = Heirloom::Config.new(:environment => 'integration')
91
+ config.filter_sensitive_data('<AWSACCESSKEYID>') do
92
+ heirloom_integration_config.access_key
93
+ end
94
+ config.filter_sensitive_data('<AWSSECRETKEY>') do
95
+ heirloom_integration_config.secret_key
96
+ end
19
97
  end
20
98
 
21
99
  end
22
100
 
23
101
  RSpec.configure do |config|
24
102
  config.include SpecHelpers
103
+ config.include IntegrationHelpers
104
+
105
+ # https://www.relishapp.com/vcr/vcr/v/2-4-0/docs/test-frameworks/usage-with-rspec-metadata!
106
+ config.treat_symbols_as_metadata_keys_with_true_values = true
107
+
108
+ config.filter_run_excluding :integration => true unless ENV['HEIRLOOM_INTEGRATION_BUCKET_PREFIX']
25
109
  end
26
110
 
@@ -0,0 +1,101 @@
1
+ # Derived from:
2
+ # https://gist.github.com/darylf/1175908
3
+
4
+ # Combined from:
5
+ # [1] http://www.rubyinside.com/how-to-rails-3-and-rspec-2-4336.html
6
+ # [2] https://gist.github.com/600976
7
+
8
+ unless defined?(GROWL)
9
+ $stderr.sync=true
10
+ $stdout.sync=true
11
+ ENV["WATCHR"] = "1"
12
+ GROWL=`which growlnotify`.chomp
13
+ IMAGE_DIR=File.expand_path("~/.watchr_images/")
14
+ end
15
+
16
+ def growl(message,title=nil,image=nil)
17
+ return if GROWL.empty?
18
+ title ||= "Watchr Test Results"
19
+ message.gsub! /\[[0-9]+?m/, ''
20
+ image ||= message =~ /^0 failure/ ? "#{IMAGE_DIR}/pass.png" : "#{IMAGE_DIR}/fail.png"
21
+ options = "-n Watchr --image '#{image}' -m '#{message}' '#{title}'"
22
+ puts "#{GROWL} #{options}"
23
+ run "#{GROWL} #{options}"
24
+ end
25
+
26
+ def run(cmd,verbose=true)
27
+ puts("# #{cmd}")
28
+ ret=[]
29
+ IO.popen(cmd) do |output|
30
+ while line = output.gets do
31
+ puts line if verbose
32
+ ret << line
33
+ end
34
+ end
35
+ ret #join("\n")
36
+ end
37
+
38
+ def generate_message(result)
39
+ message = "Error finding results..."
40
+ if result.join("\n") =~ /.*(\d+) example(s?), (\d+) failure(s?).*/
41
+ message = "#{$3} failure"
42
+ message += "s" unless $3 == "1"
43
+ end
44
+ message
45
+ end
46
+
47
+ def run_suite
48
+ system("clear")
49
+ results = run "rake spec"
50
+ growl generate_message(results)
51
+ puts
52
+ end
53
+
54
+ def run_spec(file)
55
+ unless File.exist?(file)
56
+ puts "#{file} does not exist"
57
+ return
58
+ end
59
+
60
+ puts "Running #{file}"
61
+ results = run "bundle exec rspec #{file}"
62
+ growl generate_message(results)
63
+ puts
64
+ end
65
+
66
+ watch("spec/.*/*_spec.rb") do |match|
67
+ run_spec match[0]
68
+ end
69
+
70
+ watch("spec/.*/.*/*_spec.rb") do |match|
71
+ run_spec match[0]
72
+ end
73
+
74
+ watch("lib/(.*).rb") do |match|
75
+ run_spec %{spec/#{match[1]}_spec.rb}
76
+ end
77
+
78
+ watch("lib/heirloom/(.*).rb") do |match|
79
+ run_spec %{spec/#{match[1]}_spec.rb}
80
+ end
81
+
82
+
83
+ # Ctrl-\
84
+ Signal.trap 'QUIT' do
85
+ puts " --- Running all tests ---\n\n"
86
+ run_suite
87
+ end
88
+
89
+ # Ctrl-C
90
+ Signal.trap 'INT' do
91
+ if @interrupted then
92
+ abort("\n")
93
+ else
94
+ puts "Interrupt a second time to quit"
95
+ @interrupted = true
96
+ Kernel.sleep 1.5
97
+ # raise Interrupt, nil # let the run loop catch it
98
+ run_suite
99
+ @interrupted = false
100
+ end
101
+ end