GithubHelp home page GithubHelp logo

jesseobrien / fakeiot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gravitational/fakeiot

0.0 1.0 0.0 1.53 MB

Fake IOT test cluster used for Full Stack Coding challenge

License: Apache License 2.0

Go 100.00%

fakeiot's Introduction

Fakeiot

Fake IOT test cluster is a client side implementation for Gravitational Full Stack Engineer coding challenge.

Protocol

Request Format

Every time a user logs in into imaginary Fake IOT device, it connects to the metrics server and issues the following JSON POST request:

HTTP POST /metrics

{
  "account_id": "781df840-09da-42f4-ba29-996d2ff76a73",
  "user_id": "bf506b23-8c4e-4c8e-af95-e331dba766ab",
  "timestamp": "2019-03-03T18:02:30.424878129Z"
}
  • account_id is UUID of the user account.
  • user_id is UUID of the user
  • timestamp is an RFC3339 timestamp of the login in UTC timezone.

Authentication

Client uses Bearer Auth headers to authenticate the request.

Transport Security

The fakeiot client will only connect to the target server if it trusts the server's x509 certificate to establish a TLS connection and use valid HTTPS.

You could use Letsencrypt for your test server, or generate your own certificate and tell fakeiot to trust the cert's certificate authority using --ca-cert command line flag.

Tool Usage

Building

fakeiot could be installed using go:

$ go install github.com/gravitational/fakeiot

Running Tests

Once you create your first server, we recommend to run a set of compliance tests on it:

$ fakeiot --token=shmoken --url="https://127.0.0.1:8443" --ca-cert=./fixtures/ca-cert.pem test
2019-03-03T10:18:56-08:00 INFO [RUNNER]    Starting compliance tests. runner/runner.go:110
2019-03-03T10:18:56-08:00 INFO [RUNNER]    [PASS] Sending OK request. runner/runner.go:137
2019-03-03T10:18:56-08:00 INFO [RUNNER]    [PASS] Sending Bogus request. runner/runner.go:164
2019-03-03T10:18:56-08:00 INFO [RUNNER]    [PASS] Sending Bogus request. runner/runner.go:164
2019-03-03T10:18:56-08:00 INFO             Fake IOT program run successfully. fakeiot/main.go:45

Running A Demo

To generate some traffic, you can run a simulation:

# 3 users log in sequentially over 10 seconds with 1 second frequency
$ fakeiot --token=shmoken --url="https://127.0.0.1:8443" --ca-cert=./fixtures/ca-cert.pem run --period=10s --freq=1s --users=3

Try generating more traffic to see how your server performs

# 3 users log in sequentially over 10 seconds with 1 second frequency
$ fakeiot --token=shmoken --url="https://127.0.0.1:8443" --ca-cert=./fixtures/ca-cert.pem run --period=10s --freq=1s --users=100

Feedback

If you have any feedback, please create an issue in this repository.

Good luck!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.