-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_test.go
More file actions
61 lines (50 loc) · 1.23 KB
/
debug_test.go
File metadata and controls
61 lines (50 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// debug_test.go - Minimal test to diagnose issues
package main
import (
"fmt"
"net/http"
"testing"
"time"
)
func TestMinimal_CompilationCheck(t *testing.T) {
t.Log("✅ Test compilation works")
}
func TestMinimal_NewCluster(t *testing.T) {
tempDir := t.TempDir()
cluster := NewCluster(ClusterOpts{
ID: "test-node",
DataDir: tempDir,
HTTPDataPort: 40000,
DiscoveryPort: 57001,
})
if cluster == nil {
t.Fatal("NewCluster returned nil")
}
t.Log("✅ NewCluster works")
}
func TestMinimal_StartStop(t *testing.T) {
tempDir := t.TempDir()
cluster := NewCluster(ClusterOpts{
ID: "test-node",
DataDir: tempDir,
HTTPDataPort: 40001,
DiscoveryPort: 57002,
})
// Start the cluster
cluster.Start()
t.Log("✅ Cluster started")
// FIXME: check the cluster has started, PROPERLY
WaitForConditionT(t, "Cluster startup", func() bool {
client := &http.Client{Timeout: 1 * time.Second}
baseURL := fmt.Sprintf("http://localhost:%d", cluster.HTTPDataPort)
resp, err := client.Get(baseURL + "/status")
if err != nil {
return false
}
resp.Body.Close()
return resp.StatusCode == http.StatusOK
}, 50, 2000)
// Stop the cluster
cluster.Stop()
t.Log("✅ Cluster stopped")
}