• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

couchbase / sync_gateway / 413

16 May 2025 01:54PM UTC coverage: 64.096% (+0.03%) from 64.068%
413

push

jenkins

web-flow
CBG-4441 switch cache to use int64 from time.Time (#7526)

49 of 59 new or added lines in 5 files covered. (83.05%)

6 existing lines in 3 files now uncovered.

36717 of 57284 relevant lines covered (64.1%)

0.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/tools/cache_perf_tool/processEntry.go
1
// Copyright 2025-Present Couchbase, Inc.
2
//
3
// Use of this software is governed by the Business Source License included
4
// in the file licenses/BSL-Couchbase.txt.  As of the Change Date specified
5
// in that file, in accordance with the Business Source License, use of this
6
// software will be governed by the Apache License, Version 2.0, included in
7
// the file licenses/APL2.txt.
8

9
package main
10

11
import (
12
        "context"
13
        "strconv"
14
        "testing"
15
        "time"
16

17
        "github.com/couchbase/sync_gateway/channels"
18
        "github.com/couchbase/sync_gateway/db"
19
)
20

21
type processEntryGen struct {
22
        seqAlloc       *syncSeqMock
23
        delays         []time.Duration
24
        dbCtx          *db.DatabaseContext
25
        t              *testing.T
26
        numNodes       int
27
        batchSize      int
28
        numChansPerDoc int
29
        totalChans     int
30
}
31

32
func (p *processEntryGen) spawnDocCreationGoroutine(ctx context.Context) {
×
33
        for i := 0; i < p.numNodes; i++ {
×
34
                // create new sgw node abstraction
×
35
                sgNode := &sgwNode{nodeID: i, seqAlloc: newSequenceAllocator(p.batchSize, p.seqAlloc)}
×
36
                // delay list should be same length as num sgw nodes
×
37
                go p.nodeWrites(ctx, sgNode, p.delays[i])
×
38
        }
×
39
}
40

41
func (p *processEntryGen) nodeWrites(ctx context.Context, node *sgwNode, delay time.Duration) {
×
42
        docCount := uint64(0)
×
43
        numGoroutines.Add(1)
×
44
        defer numGoroutines.Add(-1)
×
45
        // create map of configured channels, initialised channels are names test-x where x is integer between 0 and total
×
46
        // number of system channels. Thus to assign to channels we can increment through channels initialised
×
47
        chanCountZeroWait := 0
×
48
        chanCountWait := 0
×
49
        var chanMap channels.ChannelMap
×
50
        if delay.Nanoseconds() == 0 {
×
51
                // mutate as fast as possible
×
52
                for {
×
53
                        chanMap = make(channels.ChannelMap, p.numChansPerDoc)
×
54
                        for range p.numChansPerDoc {
×
55
                                if chanCountZeroWait == p.totalChans {
×
56
                                        // when count gets to total number configured channels we rest index to 0
×
57
                                        chanCountZeroWait = 0
×
58
                                }
×
59
                                chanName := "test-" + strconv.Itoa(chanCountZeroWait)
×
60
                                chanMap[chanName] = nil
×
61
                                chanCountZeroWait++
×
62
                        }
63
                        select {
×
64
                        case <-ctx.Done():
×
65
                                return
×
66
                        default:
×
NEW
67
                                timeStamp := channels.NewFeedTimestampFromNow()
×
68
                                sgwSeqno := node.seqAlloc.nextSeq()
×
69
                                docCount++
×
70
                                logEntry := &db.LogEntry{
×
71
                                        Sequence:     sgwSeqno,
×
72
                                        DocID:        "key-" + strconv.FormatUint(docCount, 10) + "-" + strconv.FormatUint(sgwSeqno, 10),
×
73
                                        RevID:        "1-abc",
×
74
                                        Flags:        0,
×
75
                                        TimeReceived: timeStamp,
×
76
                                        Channels:     chanMap,
×
77
                                        CollectionID: 0,
×
78
                                }
×
79
                                p.dbCtx.CallProcessEntry(p.t, ctx, logEntry)
×
80
                        }
81
                }
82
        }
83

84
        ticker := time.NewTicker(delay)
×
85
        defer ticker.Stop()
×
86
        for {
×
87
                chanMap = make(channels.ChannelMap, p.numChansPerDoc)
×
88
                for range p.numChansPerDoc {
×
89
                        if chanCountWait == p.totalChans {
×
90
                                // when count gets to total number configured channels we rest index to 0
×
91
                                chanCountWait = 0
×
92
                        }
×
93
                        chanName := "test-" + strconv.Itoa(chanCountWait)
×
94
                        chanMap[chanName] = nil
×
95
                        chanCountWait++
×
96
                }
97
                select {
×
98
                case <-ctx.Done():
×
99
                        return
×
100
                case <-ticker.C:
×
NEW
101
                        timeStamp := channels.NewFeedTimestampFromNow()
×
102
                        docCount++
×
103
                        sgwSeqno := node.seqAlloc.nextSeq()
×
104
                        logEntry := &db.LogEntry{
×
105
                                Sequence:     sgwSeqno,
×
106
                                DocID:        "key-" + strconv.FormatUint(docCount, 10) + "-" + strconv.FormatUint(sgwSeqno, 10),
×
107
                                RevID:        "1-abc",
×
108
                                Flags:        0,
×
109
                                TimeReceived: timeStamp,
×
110
                                Channels:     chanMap,
×
111
                                CollectionID: 0,
×
112
                        }
×
113
                        p.dbCtx.CallProcessEntry(p.t, ctx, logEntry)
×
114
                }
115
        }
116
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc