fakeiot

command module
v0.0.0-...-226beff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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!

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址