Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

RSpec for AWSフルマネージドサービス

464 views

Published on

GMOペパボ × Sansan合同勉強会@fukuoka での発表資料
https://sansan.connpass.com/event/71727/

Published in: Technology
  • Be the first to comment

  • Be the first to like this

RSpec for AWSフルマネージドサービス

  1. 1. RSpec for 
 AWS 

  2. 2. ① 名刺をスキャン ③ OCR処理&オペレーター⼊⼒ OCRとオペレーターによる多重⼊⼒ ④ データベース化 • テキストデータ • 画像データ ⑤ アプリケーションで活⽤ 名刺の検索・閲覧・編集 ②データ送信 インターネット お客様 Database 名刺を “資産”として管理 名刺を 資産として管理 ⼊⼒サービス クラウドサー ビス
  3. 3. 150万⼈が利⽤する、名刺を軸にしたビジネスSNS
  4. 4. 4 
 28 

  5. 5.
  6. 6. 🤔
  7. 7. 
 150 
 1 
 10%
  8. 8.
  9. 9. D I DKPI D D N B P P A B/I N W D W RecommendationFeed AWS 💊 AWS100
  10. 10. 😌
  11. 11. (CI)
  12. 12. $ Aws.config[:stub_responses] = true
  13. 13. it ‘true true ’ do expect(true).to eq true end
  14. 14. 
 ~/.aws/credentials aws_access_key_id=[staging key] aws_secret_access_key=[staging secret]
  15. 15. bundle exec rake db migrate:reset 🎉
  16. 16.
  17. 17. Aurora DynamoDB ElastiCache Elasticsearch Service SQS CloudSearch S3Redshift
  18. 18. Aurora Mysql5.6 Redshift Postgres DynamoDB DynamoDB Local SQS ElasticMQ S3 FakeS3 Elasticsearch Service Elasticsearch ElastiCache Memcached & Redis CloudSearch nozama-cloudsearch
  19. 19. 
 ~/config/initializers/aws.rb if Rails.env.test? || Rails.env.development? Aws.config[:dynamodb] = { endpoint: 'http://localhost:8000', access_key_id: 'fake_akid', secret_access_key: ‘fake_secret’, } … end
  20. 20. 🎉 
 https://qiita.com/yotaro/items/caff6dc4c6b6ed2b19ee
  21. 21. 
 
 
 config.before(:suite) do … WebMock.disable_net_connect!( allow_localhost: true, allow: [‘http://127.0.0.1:8000'], # DynamoDB Local ) end
  22. 22. 
 😅
  23. 23. '
  24. 24. 4010
  25. 25. 🐎 
 
 

  26. 26. 🔖 RSpec.configure do |config| config.prepend_before(:each, :dynamodb) do # dynamodb # ... end end describe 'DynamoDB ', :dynamodb do # dynamodb … end describe 'DynamoDB ' do # dynamodb # item … end
  27. 27. 📝 module UsedTableRecorder def used_tables @used_tables ||= [] end def clear_used_tables @used_tables = [] end [:put_item, :update_item].each do|method| define_method method do|*args, &block| request_item = args[0] used_tables << request_item[:table_name] super(*args, &block) end end [:batch_write_item].each do|method| define_method method do|*args, &block| request_items = args[0][:request_items] used_tables.concat(request_items.keys) super(*args, &block) end end end client = Aws::DynamoDB::Client.new( stub_responses: false ) client.extend(UsedTableRecorder) RSpec.configure do |config| config.prepend_before(:each, :dynamo db) do # truncate_tables = client.used_tables.uniq.compact # ... end end
  28. 28. 😄 4010 13
  29. 29. 😍
  30. 30. '
  31. 31.
  32. 32. version: '2' services: dynamodb: image: ['ECR image '] ports: - "8000:8000" restart: always elasticmq: image: ['ECR image '] ports: - "9324:9324" restart: always redis: image: redis:alpine ports: - "6379:6379" restart: always mysqld: image: mysql:5.6 ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: rootpass restart: always elasticsearch: image: elasticsearch:5.3 ports: - "9200:9200" - "9300:9300" environment: - "ES_JAVA_OPTS=-Xms300m -Xmx500m" restart: always fakes3: image: ['ECR image '] ports: - "4569:4569" restart: always fakes3test: image: ['ECR image '] ports: - "4570:4569" restart: always memcached: image: memcached:alpine ports: - "11211:11211" restart: always cloudsearch: image: ['ECR image '] links: - mongo:mongo_for_cs_1 - elasticsearch:elasticsearch_for_cs_1 ports: - "15808:15808" restart: always mongo: image: mongo ports: - "27017:27017" restart: always postgres: image: postgres:alpine ports: - "5432:5432" restart: always
  33. 33. AWS Service Fake Docker Hub
 Image Aurora Mysql5.6 Redshift Postgres DynamoDB DynamoDB Local ✕ SQS ElasticMQ ✕ S3 FakeS3 ✕ Elasticsearch Service Elasticsearch ElastiCache Memcached & Redis CloudSearch nozama-cloudsearch ✕
  34. 34. 😍
  35. 35.
  36. 36. Eight
  37. 37. Your business network

×