Skip to content

Commit 8e6e66b

Browse files
authored
Merge pull request #71 from RealFax/dev
Dev
2 parents e9d1c47 + 1f311e3 commit 8e6e66b

File tree

4 files changed

+5
-133
lines changed

4 files changed

+5
-133
lines changed

internal/rqd/raft_log_apply_test.go

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
package rqd_test
22

33
import (
4-
"bytes"
5-
"context"
4+
"github.com/RealFax/RedQueen/api/serverpb"
65
red "github.com/RealFax/RedQueen/internal/rqd"
7-
"github.com/RealFax/RedQueen/pkg/collapsar"
8-
"io"
9-
"strconv"
106
"testing"
11-
"time"
12-
13-
"github.com/hashicorp/raft"
14-
"google.golang.org/protobuf/proto"
15-
16-
"github.com/RealFax/RedQueen/api/serverpb"
177
)
188

199
var raftLogPayloadMessage = &serverpb.RaftLogPayload{
@@ -30,56 +20,6 @@ func TestRaftLogPayloadKey(t *testing.T) {
3020
t.Logf("Payload key: %d", red.RaftLogPayloadKey(raftLogPayloadMessage))
3121
}
3222

33-
func TestRaftMultipleLogApply_Apply(t *testing.T) {
34-
rm := red.NewRaftMultipleLogApply(
35-
context.Background(),
36-
3,
37-
time.Millisecond*300,
38-
time.Millisecond*300,
39-
func(cmd []byte, timeout time.Duration) raft.ApplyFuture {
40-
r, err := collapsar.NewReader(bytes.NewReader(cmd[4:]))
41-
if err != nil {
42-
t.Fatal(err)
43-
}
44-
45-
for {
46-
pack, rErr := r.Next()
47-
if rErr != nil {
48-
if rErr == io.EOF {
49-
break
50-
}
51-
t.Fatal(err)
52-
}
53-
m := &serverpb.RaftLogPayload{}
54-
if err = proto.Unmarshal(pack, m); err != nil {
55-
t.Fatal(err)
56-
}
57-
t.Log(m.String())
58-
}
59-
return nil
60-
})
61-
62-
for i := 0; i < 3; i++ {
63-
ctx := context.Background()
64-
if err := rm.Apply(&ctx, raftLogPayloadMessage, 0); err != nil {
65-
t.Fatal(err)
66-
}
67-
}
68-
69-
time.Sleep(time.Second * 1)
70-
71-
for i := 0; i < 3; i++ {
72-
ctx := context.Background()
73-
raftLogPayloadMessage.Key = []byte("test_key" + strconv.Itoa(i))
74-
if err := rm.Apply(&ctx, raftLogPayloadMessage, 0); err != nil {
75-
t.Fatal(err)
76-
}
77-
}
78-
79-
time.Sleep(time.Second * 1)
80-
81-
}
82-
8323
func BenchmarkRaftLogPayloadKey(b *testing.B) {
8424
for i := 0; i < b.N; i++ {
8525
red.RaftLogPayloadKey(raftLogPayloadMessage)

pkg/collapsar/writer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ func (a *writer) onFullTrigger() {
2121
if atomic.LoadUint32(&a.state) == 0 || atomic.LoadInt32(&a.max) != atomic.LoadInt32(&a.size) {
2222
return
2323
}
24-
_ = a.Close()
24+
25+
a.mu.Lock()
26+
close(a.onFull)
27+
a.mu.Unlock()
2528
}
2629

2730
func (a *writer) Encode(w io.Writer) error {

pkg/httputil/handler_test.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

pkg/tlsutil/tls_test.go

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)