Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2023-08-24 07:18:07 +0300
committerAsh McKenzie <amckenzie@gitlab.com>2023-08-29 09:22:55 +0300
commitde9031b2abb50714e09eb7c143cb5d43f4cd626a (patch)
tree184e893273a4e50641aba49014a6d4f04f1c6aee
parent1ba2d88ea59b734e7a4f4518c25d69414045a222 (diff)
Allow a margin of 5 bytes for Bytes
-rw-r--r--internal/gitaly/service/ssh/upload_pack.go4
-rw-r--r--internal/gitaly/service/ssh/upload_pack_test.go17
-rw-r--r--proto/go/gitalypb/ssh.pb.go2
-rw-r--r--proto/ssh.proto2
4 files changed, 16 insertions, 9 deletions
diff --git a/internal/gitaly/service/ssh/upload_pack.go b/internal/gitaly/service/ssh/upload_pack.go
index ec1656566..e3c8b45ce 100644
--- a/internal/gitaly/service/ssh/upload_pack.go
+++ b/internal/gitaly/service/ssh/upload_pack.go
@@ -214,7 +214,7 @@ func (s *server) SSHUploadPackWithSidechannel(ctx context.Context, req *gitalypb
stdout := sidebandWriter.Writer(stream.BandStdout)
stderr := sidebandWriter.Writer(stream.BandStderr)
- stats, writtenBytes, _, err := s.sshUploadPack(ctx, req, conn, stdout, stderr)
+ stats, responseBytes, _, err := s.sshUploadPack(ctx, req, conn, stdout, stderr)
if err != nil {
return nil, structerr.NewInternal("%w", err)
}
@@ -224,6 +224,6 @@ func (s *server) SSHUploadPackWithSidechannel(ctx context.Context, req *gitalypb
return &gitalypb.SSHUploadPackWithSidechannelResponse{
PackfileNegotiationStatistics: stats.ToProto(),
- Bytes: writtenBytes,
+ Bytes: responseBytes,
}, nil
}
diff --git a/internal/gitaly/service/ssh/upload_pack_test.go b/internal/gitaly/service/ssh/upload_pack_test.go
index 2086d17d2..0c12e9fd7 100644
--- a/internal/gitaly/service/ssh/upload_pack_test.go
+++ b/internal/gitaly/service/ssh/upload_pack_test.go
@@ -183,7 +183,6 @@ func TestUploadPackWithSidechannel_client(t *testing.T) {
request *gitalypb.SSHUploadPackWithSidechannelRequest
client func(clientConn *sidechannel.ClientConn, cancelContext func()) error
expectedErr error
- protoEqualOpt cmp.Option
expectedResponse *gitalypb.SSHUploadPackWithSidechannelResponse
}{
{
@@ -206,8 +205,8 @@ func TestUploadPackWithSidechannel_client(t *testing.T) {
Caps: []string{"multi_ack"},
Wants: 1,
},
+ Bytes: int64(554),
},
- protoEqualOpt: protocmp.IgnoreFields(&gitalypb.SSHUploadPackWithSidechannelResponse{}, "bytes"),
},
{
desc: "successful clone with protocol v2",
@@ -233,8 +232,8 @@ func TestUploadPackWithSidechannel_client(t *testing.T) {
Packets: 5,
Wants: 1,
},
+ Bytes: int64(536),
},
- protoEqualOpt: protocmp.IgnoreFields(&gitalypb.SSHUploadPackWithSidechannelResponse{}, "bytes"),
},
{
desc: "client talks protocol v0 but v2 is requested",
@@ -329,8 +328,8 @@ func TestUploadPackWithSidechannel_client(t *testing.T) {
},
expectedResponse: &gitalypb.SSHUploadPackWithSidechannelResponse{
PackfileNegotiationStatistics: &gitalypb.PackfileNegotiationStatistics{},
+ Bytes: int64(154),
},
- protoEqualOpt: protocmp.IgnoreFields(&gitalypb.SSHUploadPackWithSidechannelResponse{}, "bytes"),
},
{
desc: "short write",
@@ -439,7 +438,11 @@ func TestUploadPackWithSidechannel_client(t *testing.T) {
tc.expectedResponse.PackfileNegotiationStatistics.PayloadSize = response.PackfileNegotiationStatistics.PayloadSize
}
- testhelper.ProtoEqual(t, tc.expectedResponse, response, tc.protoEqualOpt)
+ opt := protocmp.FilterField(new(gitalypb.SSHUploadPackWithSidechannelResponse), "bytes", cmp.Comparer(func(x, y int64) bool {
+ return differenceWithinMargin(x, y, 24)
+ }))
+
+ testhelper.ProtoEqual(t, tc.expectedResponse, response, opt)
})
}
}
@@ -821,3 +824,7 @@ func recvUntilError(t *testing.T, stream gitalypb.SSHService_SSHUploadPackClient
}
}
}
+
+func differenceWithinMargin(x, y int64, margin int) bool {
+ return x-y <= int64(margin)
+}
diff --git a/proto/go/gitalypb/ssh.pb.go b/proto/go/gitalypb/ssh.pb.go
index 0dbcad2bc..ed401e7ab 100644
--- a/proto/go/gitalypb/ssh.pb.go
+++ b/proto/go/gitalypb/ssh.pb.go
@@ -239,7 +239,7 @@ type SSHUploadPackWithSidechannelResponse struct {
// Packfile negotiation statistics.
PackfileNegotiationStatistics *PackfileNegotiationStatistics `protobuf:"bytes,1,opt,name=packfile_negotiation_statistics,json=packfileNegotiationStatistics,proto3" json:"packfile_negotiation_statistics,omitempty"`
- // The number of bytes
+ // The number of response bytes
Bytes int64 `protobuf:"varint,2,opt,name=bytes,proto3" json:"bytes,omitempty"`
}
diff --git a/proto/ssh.proto b/proto/ssh.proto
index 15d8d9cc8..1e5739251 100644
--- a/proto/ssh.proto
+++ b/proto/ssh.proto
@@ -81,7 +81,7 @@ message SSHUploadPackWithSidechannelRequest {
message SSHUploadPackWithSidechannelResponse {
// Packfile negotiation statistics.
PackfileNegotiationStatistics packfile_negotiation_statistics = 1;
- // The number of bytes
+ // The number of response bytes
int64 bytes = 2;
}