Skip to content

Commit f2779e7

Browse files
author
Tim Middleton
committed
more updates
1 parent d16407c commit f2779e7

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

.github/workflows/build-kind.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
kubectl port-forward -n $NAMESPACE pod/$POD 8080:8080 > build/_output/test-logs/port-forward.log 2>&1 &
9595
PORT_FORWARD_PID=$!
9696
# run curl requests
97-
while : ; do curl -s -v http://localhost:8080/api/schools?q=[1-2] | jq length; sleep 0.5; done > build/_output/test-logs/curl.log 2>&1 &
97+
while : ; do curl -s -v http://127.0.0.1:8080/api/schools?q=[1-2] | jq length; sleep 0.5; done > build/_output/test-logs/curl.log 2>&1 &
9898
CURL_PID=$!
9999
# Start the rolling restart
100100
./scripts/kind/roll-cluster.sh | tee build/_output/test-logs/rolling-restart.log

coherence/session.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ func (s *Session) GetReadyTimeout() time.Duration {
484484
func (s *Session) ensureConnection() error {
485485
s.connectMutex.Lock()
486486
defer s.connectMutex.Unlock()
487-
logMessage(DEBUG, "ensureConnection()")
488487

489488
if s.firstConnectAttempted {
490489
// We have previously tried to connect so check that the connect state is connected

test/e2e/kind/main.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var (
4444
func main() {
4545
var (
4646
count = 250_000
47-
testType = "runTest"
47+
testType = "runSchoolsTest"
4848
err error
4949
)
5050
if err = initializeCoherence(); err != nil {
@@ -63,7 +63,7 @@ func main() {
6363
if testType == "load" {
6464
err = populateSchoolsCache(count)
6565
} else {
66-
err = runTest()
66+
err = runSchoolsTest()
6767
}
6868
if err != nil {
6969
log.Fatalf("failed to run %s: %v", testType, err)
@@ -90,7 +90,7 @@ func initializeCoherence() error {
9090
return err
9191
}
9292

93-
func runTest() error {
93+
func runSchoolsTest() error {
9494
http.HandleFunc("/api/schools", schoolsHandler)
9595

9696
fmt.Println("Server running on port 8080")
@@ -102,6 +102,16 @@ func runTest() error {
102102
func schoolsHandler(w http.ResponseWriter, r *http.Request) {
103103
ctx := context.Background()
104104

105+
defer func() {
106+
if session.IsClosed() {
107+
log.Printf("Session [%s] is closed, calling initializeCoherence()", session.ID())
108+
err := initializeCoherence()
109+
if err != nil {
110+
log.Fatalf("failed to initialize coherence: %v", err)
111+
}
112+
}
113+
}()
114+
105115
switch r.Method {
106116

107117
case http.MethodGet:
@@ -117,14 +127,13 @@ func schoolsHandler(w http.ResponseWriter, r *http.Request) {
117127

118128
var people = make([]School, 0)
119129

120-
if session.IsClosed() {
121-
log.Printf("Session [%s] is closed, calling initializeCoherence()", session.ID())
122-
err := initializeCoherence()
123-
if err != nil {
124-
log.Printf("failed to initialize coherence: %v", err)
125-
http.Error(w, "not connected", http.StatusInternalServerError)
126-
return
127-
}
130+
log.Println("Health check via size()")
131+
_, err := schoolsCache.Size(ctx)
132+
if err != nil {
133+
session.Close()
134+
log.Printf("failed to do health check: %v", err)
135+
http.Error(w, err.Error(), http.StatusInternalServerError)
136+
return
128137
}
129138

130139
for ch := range schoolsCache.ValuesFilter(ctx, marketSegmentFilter) {

0 commit comments

Comments
 (0)