Giter Club home page Giter Club logo

test-http-server's Introduction

test-http-server

  • 8080/tcp を listen する
    • LISTEN_ADDR, PORT で指定可能 (デフォルトが 0.0.0.0:8080)
  • Request Header を body で返す
  • Request の URL を .json で終わらせると json で返す
  • Query String の sleep=time.Duration で指定の時間 sleep する
  • Query String の stress=time.Duration で指定の時間 CPU を使いまくる
    • Qeury String の cores=int で使用する core の数を指定する
    • 未指定 or 0 の場合はプロセスから見える core の数
  • リクエストごとに uuid を生成して response に入れる
  • サーバー側の timestamp を response に入れる
    • sleep させた場合、sleep 後の時刻
  • /stream で sleep しながら chunked response を返す

container image

docker pull ghcr.io/yteraoka/test-http-server:0.1.0

実行例

$ curl -s "http://localhost:8080/"

[Request]
Method: GET
Host: localhost:8080
RequestURI: /
Proto: HTTP/1.1
Content-Length: 0
Close: false
RemoteAddr: 127.0.0.1:60166

[Received Headers]
Accept: */*
User-Agent: curl/7.84.0

[Server Generated]
uuid: 1f7af804-c7ef-421e-88c0-4d9ce2cb8f0c
time: 2022-08-14 20:27:51.662474 +0900 JST m=+9.493387384
$ curl -s "http://localhost:8080/a.json" | jq .
{
  "generated": {
    "time": "2022-08-14 20:28:04.423643 +0900 JST m=+22.254587266",
    "uuid": "df58179b-417d-4aa9-a5a7-dabc70c728da"
  },
  "headers": {
    "Accept": [
      "*/*"
    ],
    "User-Agent": [
      "curl/7.84.0"
    ]
  },
  "request": {
    "close": false,
    "content-length": 0,
    "method": "GET",
    "proto": "HTTP/1.1",
    "remote-addr": "127.0.0.1:60168",
    "uri": "/a.json"
  }
}
$ curl -sw "%{time_total}\n" -o /dev/null "http://localhost:8080/?sleep=5s"                                      [main]
5.005371
$ curl -sw "%{http_code}\n" -o /dev/null "http://localhost:8080/?status=404"                                     [main]
404
$ curl -sw "%{time_total}\n" -o /dev/null "http://localhost:8080/?stress=10s&cores=2"                            [main]
10.005560

test-http-server's People

Contributors

yteraoka avatar renovate[bot] avatar dependabot[bot] avatar

Watchers

 avatar James Cloos avatar  avatar  avatar

Forkers

hassaku3939

test-http-server's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

asdf
.tool-versions
  • golang 1.22.5
  • helm 3.15.3
dockerfile
Dockerfile
  • golang 1.22.5
github-actions
.github/workflows/build-and-push.yaml
  • actions/checkout v4
  • docker/metadata-action v5
  • sigstore/cosign-installer v3.5.0
  • docker/setup-qemu-action v3
  • docker/setup-buildx-action v3
  • docker/login-action v3
  • docker/login-action v3
  • docker/build-push-action v6
.github/workflows/build-test.yaml
  • actions/checkout v4
  • hadolint/hadolint-action v3.1.0
  • actions/checkout v4
  • docker/setup-buildx-action v3
  • docker/build-push-action v6
  • erzz/dockle-action v1
.github/workflows/goreleaser.yml
  • actions/checkout v4
  • actions/setup-go v5
  • goreleaser/goreleaser-action v6
.github/workflows/lint.yaml
  • actions/checkout v4
  • reviewdog/action-golangci-lint v2
gomod
go.mod
  • go 1.20
  • github.com/google/uuid v1.6.0
  • github.com/rs/zerolog v1.32.0
helm-values
chart/test-http-server/values.yaml

  • Check this box to trigger a request for Renovate to run again on this repository

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.