Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 35 lines (32 sloc) 0.755 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
require 'socket'
require 'json'
s = UDPSocket.new

# HOST = '192.168.245'
HOST = 'localhost'

N = 70
ACCOUNTS = ['romano', 'japijane', 'depto51']
EVENTS = ['pageview', 'request', 'apievent', 'order']
STATUSES = ['draft', 'draft', 'draft', 'checkout', 'closed']

# app, account/shop, user/token
1.upto N do |i|
  msg = JSON.dump(
    type: EVENTS[rand(EVENTS.size)],
    time: Time.now.to_s,
    data: {
      app: "app-#{i}",
      tz: (rand * 10).round,
      account: ACCOUNTS[rand(ACCOUNTS.size)],
      status: STATUSES[rand(STATUSES.size)],
      user: "user-#{i}",
      resource_id: i,
      browser: {
        os: 'Mac',
        name: 'Chrome',
        version: 23
      }
    }
  )
  s.send(msg, 0, HOST, 5555)
  p [:send, msg]
  sleep 0.1
end
Something went wrong with that request. Please try again.