feat(monitor-ci/415): get oss-e2es working locally in UI repo (#24098)

* feat(monitor-ci/415): get oss-e2es working locally in UI repo

* chore: remove old, unused artifact directories

* fix: handle import cycle caused by trying to use the onboarding client

---------

Co-authored-by: Jeffrey Smith II <jsmith@influxdata.com>
pull/24103/head
wiedld 2023-02-22 06:28:46 -08:00 committed by GitHub
parent 260d88b45d
commit 4fc73ea221
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 6 deletions

View File

@ -925,7 +925,7 @@ func (m *Launcher) run(ctx context.Context, opts *InfluxdOpts) (err error) {
}
// If we are in testing mode we allow all data to be flushed and removed.
if opts.Testing {
httpHandler = http.DebugFlush(ctx, httpHandler, m.flushers)
httpHandler = http.Debug(ctx, httpHandler, m.flushers, onboardSvc)
}
if !opts.ReportingDisabled {

View File

@ -2,7 +2,10 @@ package http
import (
"context"
"encoding/json"
"net/http"
"github.com/influxdata/influxdb/v2"
)
// Flusher flushes data from a store to reset; used for testing.
@ -10,15 +13,39 @@ type Flusher interface {
Flush(ctx context.Context)
}
// DebugFlush clears all services for testing.
func DebugFlush(ctx context.Context, next http.Handler, f Flusher) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
func Debug(ctx context.Context, next http.Handler, f Flusher, service influxdb.OnboardingService) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/debug/flush" {
// DebugFlush clears all services for testing.
f.Flush(ctx)
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
return
}
if r.URL.Path == "/debug/provision" {
data := &influxdb.OnboardingRequest{
User: "dev_user",
Password: "password",
Org: "InfluxData",
Bucket: "project",
}
res, err := service.OnboardInitialUser(ctx, data)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error()))
return
}
body, err := json.Marshal(res)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error()))
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(body)
return
}
next.ServeHTTP(w, r)
})
}
}

View File

@ -169,7 +169,7 @@ earlyTermination() {
}
# make dir for artifacts
mkdir -p monitor-ci/test-artifacts/results/{build-oss-image,oss-e2e,build-image,cloud-e2e,cloud-e2e-firefox,cloud-e2e-k8s-idpe,cloud-lighthouse,smoke,build-prod-image,deploy}/{shared,oss,cloud}
mkdir -p monitor-ci/test-artifacts/results/{build-oss-image,oss-e2e,build-image,cloud-e2e,cloud-lighthouse,smoke,build-prod-image,deploy}/{shared,oss,cloud}
# get monitor-ci pipelines we've already run on this SHA
found_passing_pipeline=0