Skip to content

Commit

Permalink
feat(ci) : add server for e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
seipan committed Jun 24, 2024
1 parent 4c0bfdc commit bdd293e
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 0 deletions.
40 changes: 40 additions & 0 deletions testdata/ciserver/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"encoding/json"
"net/http"
)

type HealthResponse struct {
Status string `json:"status"`
Message string `json:"message"`
}

func main() {
http.HandleFunc("/api/v1/health1", health1Handler)
http.HandleFunc("/api/v1/health2", health2Handler)
http.HandleFunc("/api/v1/health3", health3Handler)
http.HandleFunc("/api/v1/health4", health4Handler)

http.ListenAndServe(":8080", nil)
}

func health1Handler(w http.ResponseWriter, r *http.Request) {
response := HealthResponse{Status: "ok", Message: "Service 1 is healthy"}
json.NewEncoder(w).Encode(response)
}

func health2Handler(w http.ResponseWriter, r *http.Request) {
response := HealthResponse{Status: "ok", Message: "Service 2 is healthy"}
json.NewEncoder(w).Encode(response)
}

func health3Handler(w http.ResponseWriter, r *http.Request) {
response := HealthResponse{Status: "ok", Message: "Service 3 is healthy"}
json.NewEncoder(w).Encode(response)
}

func health4Handler(w http.ResponseWriter, r *http.Request) {
response := HealthResponse{Status: "ok", Message: "Service 4 is healthy"}
json.NewEncoder(w).Encode(response)
}
73 changes: 73 additions & 0 deletions testdata/ciserver/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
openapi: 3.0.0
info:
title: Health Check API
version: 1.0.0
paths:
/api/v1/health1:
get:
summary: Health check for service 1
responses:
'200':
description: A successful response
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: "ok"
message:
type: string
example: "Service 1 is healthy"
/api/v1/health2:
get:
summary: Health check for service 2
responses:
'200':
description: A successful response
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: "ok"
message:
type: string
example: "Service 2 is healthy"
/api/v1/health3:
get:
summary: Health check for service 3
responses:
'200':
description: A successful response
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: "ok"
message:
type: string
example: "Service 3 is healthy"
/api/v1/health4:
get:
summary: Health check for service 4
responses:
'200':
description: A successful response
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: "ok"
message:
type: string
example: "Service 4 is healthy"

0 comments on commit bdd293e

Please sign in to comment.