Skip to content

Commit

Permalink
fixed unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
okankoAMZ committed Nov 13, 2024
1 parent b551012 commit a1a0f2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
Expand Down Expand Up @@ -73,7 +74,13 @@ func WithTLSConfig(tlsConfig *tls.Config, httpsListenAddr string) Option {
s.setRouter(httpsRouter)

s.httpsServer = &http.Server{Addr: httpsListenAddr, Handler: httpsRouter, ReadHeaderTimeout: 90 * time.Second, TLSConfig: tlsConfig}
s.server.Shutdown(context.Background())
err := s.server.Shutdown(context.Background())
if err != nil {
s.logger.Error(err, "Failed to shutdown http server")
}
if errors.Is(err, http.ErrServerClosed) {
s.logger.Info("Http server is already closed")
}
s.server = s.httpsServer
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,14 +835,14 @@ func createTestTLSServer(listenAddr string) (*Server, *tls.Config, error) {
if err != nil {
return nil, nil, err
}
httpOptions := []Option{}
httpOptions = append(httpOptions, WithTLSConfig(tlsConfig, listenAddr))

//generate ca bundle
bundle, err := readCABundle(caBundle)
if err != nil {
return nil, nil, err
}
httpOptions := []Option{}
httpOptions = append(httpOptions, WithTLSConfig(tlsConfig, listenAddr))

allocator := &mockAllocator{targetItems: map[string]*target.Item{
"a": target.NewItem("job1", "", model.LabelSet{}, ""),
}}
Expand Down

0 comments on commit a1a0f2c

Please sign in to comment.