mirror of https://github.com/grpc/grpc.git
commit
a7888f0f1a
81 changed files with 2143 additions and 573 deletions
@ -0,0 +1,154 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2019 gRPC authors. |
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef GRPC_INTERNAL_COMPILER_CPP_PLUGIN_H |
||||||
|
#define GRPC_INTERNAL_COMPILER_CPP_PLUGIN_H |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
#include <sstream> |
||||||
|
|
||||||
|
#include "src/compiler/config.h" |
||||||
|
|
||||||
|
#include "src/compiler/cpp_generator.h" |
||||||
|
#include "src/compiler/generator_helpers.h" |
||||||
|
#include "src/compiler/protobuf_plugin.h" |
||||||
|
|
||||||
|
// Cpp Generator for Protobug IDL
|
||||||
|
class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { |
||||||
|
public: |
||||||
|
CppGrpcGenerator() {} |
||||||
|
virtual ~CppGrpcGenerator() {} |
||||||
|
|
||||||
|
virtual bool Generate(const grpc::protobuf::FileDescriptor* file, |
||||||
|
const grpc::string& parameter, |
||||||
|
grpc::protobuf::compiler::GeneratorContext* context, |
||||||
|
grpc::string* error) const { |
||||||
|
if (file->options().cc_generic_services()) { |
||||||
|
*error = |
||||||
|
"cpp grpc proto compiler plugin does not work with generic " |
||||||
|
"services. To generate cpp grpc APIs, please set \"" |
||||||
|
"cc_generic_service = false\"."; |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
grpc_cpp_generator::Parameters generator_parameters; |
||||||
|
generator_parameters.use_system_headers = true; |
||||||
|
generator_parameters.generate_mock_code = false; |
||||||
|
generator_parameters.include_import_headers = false; |
||||||
|
|
||||||
|
ProtoBufFile pbfile(file); |
||||||
|
|
||||||
|
if (!parameter.empty()) { |
||||||
|
std::vector<grpc::string> parameters_list = |
||||||
|
grpc_generator::tokenize(parameter, ","); |
||||||
|
for (auto parameter_string = parameters_list.begin(); |
||||||
|
parameter_string != parameters_list.end(); parameter_string++) { |
||||||
|
std::vector<grpc::string> param = |
||||||
|
grpc_generator::tokenize(*parameter_string, "="); |
||||||
|
if (param[0] == "services_namespace") { |
||||||
|
generator_parameters.services_namespace = param[1]; |
||||||
|
} else if (param[0] == "use_system_headers") { |
||||||
|
if (param[1] == "true") { |
||||||
|
generator_parameters.use_system_headers = true; |
||||||
|
} else if (param[1] == "false") { |
||||||
|
generator_parameters.use_system_headers = false; |
||||||
|
} else { |
||||||
|
*error = grpc::string("Invalid parameter: ") + *parameter_string; |
||||||
|
return false; |
||||||
|
} |
||||||
|
} else if (param[0] == "grpc_search_path") { |
||||||
|
generator_parameters.grpc_search_path = param[1]; |
||||||
|
} else if (param[0] == "generate_mock_code") { |
||||||
|
if (param[1] == "true") { |
||||||
|
generator_parameters.generate_mock_code = true; |
||||||
|
} else if (param[1] != "false") { |
||||||
|
*error = grpc::string("Invalid parameter: ") + *parameter_string; |
||||||
|
return false; |
||||||
|
} |
||||||
|
} else if (param[0] == "gmock_search_path") { |
||||||
|
generator_parameters.gmock_search_path = param[1]; |
||||||
|
} else if (param[0] == "additional_header_includes") { |
||||||
|
generator_parameters.additional_header_includes = |
||||||
|
grpc_generator::tokenize(param[1], ":"); |
||||||
|
} else if (param[0] == "message_header_extension") { |
||||||
|
generator_parameters.message_header_extension = param[1]; |
||||||
|
} else if (param[0] == "include_import_headers") { |
||||||
|
if (param[1] == "true") { |
||||||
|
generator_parameters.include_import_headers = true; |
||||||
|
} else if (param[1] != "false") { |
||||||
|
*error = grpc::string("Invalid parameter: ") + *parameter_string; |
||||||
|
return false; |
||||||
|
} |
||||||
|
} else { |
||||||
|
*error = grpc::string("Unknown parameter: ") + *parameter_string; |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
grpc::string file_name = grpc_generator::StripProto(file->name()); |
||||||
|
|
||||||
|
grpc::string header_code = |
||||||
|
grpc_cpp_generator::GetHeaderPrologue(&pbfile, generator_parameters) + |
||||||
|
grpc_cpp_generator::GetHeaderIncludes(&pbfile, generator_parameters) + |
||||||
|
grpc_cpp_generator::GetHeaderServices(&pbfile, generator_parameters) + |
||||||
|
grpc_cpp_generator::GetHeaderEpilogue(&pbfile, generator_parameters); |
||||||
|
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> header_output( |
||||||
|
context->Open(file_name + ".grpc.pb.h")); |
||||||
|
grpc::protobuf::io::CodedOutputStream header_coded_out(header_output.get()); |
||||||
|
header_coded_out.WriteRaw(header_code.data(), header_code.size()); |
||||||
|
|
||||||
|
grpc::string source_code = |
||||||
|
grpc_cpp_generator::GetSourcePrologue(&pbfile, generator_parameters) + |
||||||
|
grpc_cpp_generator::GetSourceIncludes(&pbfile, generator_parameters) + |
||||||
|
grpc_cpp_generator::GetSourceServices(&pbfile, generator_parameters) + |
||||||
|
grpc_cpp_generator::GetSourceEpilogue(&pbfile, generator_parameters); |
||||||
|
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> source_output( |
||||||
|
context->Open(file_name + ".grpc.pb.cc")); |
||||||
|
grpc::protobuf::io::CodedOutputStream source_coded_out(source_output.get()); |
||||||
|
source_coded_out.WriteRaw(source_code.data(), source_code.size()); |
||||||
|
|
||||||
|
if (!generator_parameters.generate_mock_code) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
grpc::string mock_code = |
||||||
|
grpc_cpp_generator::GetMockPrologue(&pbfile, generator_parameters) + |
||||||
|
grpc_cpp_generator::GetMockIncludes(&pbfile, generator_parameters) + |
||||||
|
grpc_cpp_generator::GetMockServices(&pbfile, generator_parameters) + |
||||||
|
grpc_cpp_generator::GetMockEpilogue(&pbfile, generator_parameters); |
||||||
|
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> mock_output( |
||||||
|
context->Open(file_name + "_mock.grpc.pb.h")); |
||||||
|
grpc::protobuf::io::CodedOutputStream mock_coded_out(mock_output.get()); |
||||||
|
mock_coded_out.WriteRaw(mock_code.data(), mock_code.size()); |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
private: |
||||||
|
// Insert the given code into the given file at the given insertion point.
|
||||||
|
void Insert(grpc::protobuf::compiler::GeneratorContext* context, |
||||||
|
const grpc::string& filename, const grpc::string& insertion_point, |
||||||
|
const grpc::string& code) const { |
||||||
|
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output( |
||||||
|
context->OpenForInsert(filename, insertion_point)); |
||||||
|
grpc::protobuf::io::CodedOutputStream coded_out(output.get()); |
||||||
|
coded_out.WriteRaw(code.data(), code.size()); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // GRPC_INTERNAL_COMPILER_CPP_PLUGIN_H
|
@ -0,0 +1,240 @@ |
|||||||
|
#region Copyright notice and license |
||||||
|
|
||||||
|
// Copyright 2019 The gRPC Authors |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
// you may not use this file except in compliance with the License. |
||||||
|
// You may obtain a copy of the License at |
||||||
|
// |
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Grpc.Core; |
||||||
|
using Grpc.Core.Internal; |
||||||
|
using Grpc.Core.Utils; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
using System.Runtime.InteropServices; |
||||||
|
|
||||||
|
#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY |
||||||
|
using System.Buffers; |
||||||
|
#endif |
||||||
|
|
||||||
|
namespace Grpc.Core.Internal.Tests |
||||||
|
{ |
||||||
|
public class DefaultDeserializationContextTest |
||||||
|
{ |
||||||
|
FakeBufferReaderManager fakeBufferReaderManager; |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
fakeBufferReaderManager = new FakeBufferReaderManager(); |
||||||
|
} |
||||||
|
|
||||||
|
[TearDown] |
||||||
|
public void Cleanup() |
||||||
|
{ |
||||||
|
fakeBufferReaderManager.Dispose(); |
||||||
|
} |
||||||
|
|
||||||
|
#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY |
||||||
|
[TestCase] |
||||||
|
public void PayloadAsReadOnlySequence_ZeroSegmentPayload() |
||||||
|
{ |
||||||
|
var context = new DefaultDeserializationContext(); |
||||||
|
context.Initialize(fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List<byte[]> {})); |
||||||
|
|
||||||
|
Assert.AreEqual(0, context.PayloadLength); |
||||||
|
|
||||||
|
var sequence = context.PayloadAsReadOnlySequence(); |
||||||
|
|
||||||
|
Assert.AreEqual(ReadOnlySequence<byte>.Empty, sequence); |
||||||
|
Assert.IsTrue(sequence.IsEmpty); |
||||||
|
Assert.IsTrue(sequence.IsSingleSegment); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(0)] |
||||||
|
[TestCase(1)] |
||||||
|
[TestCase(10)] |
||||||
|
[TestCase(100)] |
||||||
|
[TestCase(1000)] |
||||||
|
public void PayloadAsReadOnlySequence_SingleSegmentPayload(int segmentLength) |
||||||
|
{ |
||||||
|
var origBuffer = GetTestBuffer(segmentLength); |
||||||
|
var context = new DefaultDeserializationContext(); |
||||||
|
context.Initialize(fakeBufferReaderManager.CreateSingleSegmentBufferReader(origBuffer)); |
||||||
|
|
||||||
|
Assert.AreEqual(origBuffer.Length, context.PayloadLength); |
||||||
|
|
||||||
|
var sequence = context.PayloadAsReadOnlySequence(); |
||||||
|
|
||||||
|
Assert.AreEqual(origBuffer.Length, sequence.Length); |
||||||
|
Assert.AreEqual(origBuffer.Length, sequence.First.Length); |
||||||
|
Assert.IsTrue(sequence.IsSingleSegment); |
||||||
|
CollectionAssert.AreEqual(origBuffer, sequence.First.ToArray()); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(0, 5, 10)] |
||||||
|
[TestCase(1, 1, 1)] |
||||||
|
[TestCase(10, 100, 1000)] |
||||||
|
[TestCase(100, 100, 10)] |
||||||
|
[TestCase(1000, 1000, 1000)] |
||||||
|
public void PayloadAsReadOnlySequence_MultiSegmentPayload(int segmentLen1, int segmentLen2, int segmentLen3) |
||||||
|
{ |
||||||
|
var origBuffer1 = GetTestBuffer(segmentLen1); |
||||||
|
var origBuffer2 = GetTestBuffer(segmentLen2); |
||||||
|
var origBuffer3 = GetTestBuffer(segmentLen3); |
||||||
|
int totalLen = origBuffer1.Length + origBuffer2.Length + origBuffer3.Length; |
||||||
|
|
||||||
|
var context = new DefaultDeserializationContext(); |
||||||
|
context.Initialize(fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List<byte[]> { origBuffer1, origBuffer2, origBuffer3 })); |
||||||
|
|
||||||
|
Assert.AreEqual(totalLen, context.PayloadLength); |
||||||
|
|
||||||
|
var sequence = context.PayloadAsReadOnlySequence(); |
||||||
|
|
||||||
|
Assert.AreEqual(totalLen, sequence.Length); |
||||||
|
|
||||||
|
var segmentEnumerator = sequence.GetEnumerator(); |
||||||
|
|
||||||
|
Assert.IsTrue(segmentEnumerator.MoveNext()); |
||||||
|
CollectionAssert.AreEqual(origBuffer1, segmentEnumerator.Current.ToArray()); |
||||||
|
|
||||||
|
Assert.IsTrue(segmentEnumerator.MoveNext()); |
||||||
|
CollectionAssert.AreEqual(origBuffer2, segmentEnumerator.Current.ToArray()); |
||||||
|
|
||||||
|
Assert.IsTrue(segmentEnumerator.MoveNext()); |
||||||
|
CollectionAssert.AreEqual(origBuffer3, segmentEnumerator.Current.ToArray()); |
||||||
|
|
||||||
|
Assert.IsFalse(segmentEnumerator.MoveNext()); |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
[TestCase] |
||||||
|
public void NullPayloadNotAllowed() |
||||||
|
{ |
||||||
|
var context = new DefaultDeserializationContext(); |
||||||
|
Assert.Throws(typeof(InvalidOperationException), () => context.Initialize(fakeBufferReaderManager.CreateNullPayloadBufferReader())); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase] |
||||||
|
public void PayloadAsNewByteBuffer_ZeroSegmentPayload() |
||||||
|
{ |
||||||
|
var context = new DefaultDeserializationContext(); |
||||||
|
context.Initialize(fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List<byte[]> {})); |
||||||
|
|
||||||
|
Assert.AreEqual(0, context.PayloadLength); |
||||||
|
|
||||||
|
var payload = context.PayloadAsNewBuffer(); |
||||||
|
Assert.AreEqual(0, payload.Length); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(0)] |
||||||
|
[TestCase(1)] |
||||||
|
[TestCase(10)] |
||||||
|
[TestCase(100)] |
||||||
|
[TestCase(1000)] |
||||||
|
public void PayloadAsNewByteBuffer_SingleSegmentPayload(int segmentLength) |
||||||
|
{ |
||||||
|
var origBuffer = GetTestBuffer(segmentLength); |
||||||
|
var context = new DefaultDeserializationContext(); |
||||||
|
context.Initialize(fakeBufferReaderManager.CreateSingleSegmentBufferReader(origBuffer)); |
||||||
|
|
||||||
|
Assert.AreEqual(origBuffer.Length, context.PayloadLength); |
||||||
|
|
||||||
|
var payload = context.PayloadAsNewBuffer(); |
||||||
|
CollectionAssert.AreEqual(origBuffer, payload); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(0, 5, 10)] |
||||||
|
[TestCase(1, 1, 1)] |
||||||
|
[TestCase(10, 100, 1000)] |
||||||
|
[TestCase(100, 100, 10)] |
||||||
|
[TestCase(1000, 1000, 1000)] |
||||||
|
public void PayloadAsNewByteBuffer_MultiSegmentPayload(int segmentLen1, int segmentLen2, int segmentLen3) |
||||||
|
{ |
||||||
|
var origBuffer1 = GetTestBuffer(segmentLen1); |
||||||
|
var origBuffer2 = GetTestBuffer(segmentLen2); |
||||||
|
var origBuffer3 = GetTestBuffer(segmentLen3); |
||||||
|
|
||||||
|
var context = new DefaultDeserializationContext(); |
||||||
|
context.Initialize(fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List<byte[]> { origBuffer1, origBuffer2, origBuffer3 })); |
||||||
|
|
||||||
|
var payload = context.PayloadAsNewBuffer(); |
||||||
|
|
||||||
|
var concatenatedOrigBuffers = new List<byte>(); |
||||||
|
concatenatedOrigBuffers.AddRange(origBuffer1); |
||||||
|
concatenatedOrigBuffers.AddRange(origBuffer2); |
||||||
|
concatenatedOrigBuffers.AddRange(origBuffer3); |
||||||
|
|
||||||
|
Assert.AreEqual(concatenatedOrigBuffers.Count, context.PayloadLength); |
||||||
|
Assert.AreEqual(concatenatedOrigBuffers.Count, payload.Length); |
||||||
|
CollectionAssert.AreEqual(concatenatedOrigBuffers, payload); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase] |
||||||
|
public void GetPayloadMultipleTimesIsIllegal() |
||||||
|
{ |
||||||
|
var origBuffer = GetTestBuffer(100); |
||||||
|
var context = new DefaultDeserializationContext(); |
||||||
|
context.Initialize(fakeBufferReaderManager.CreateSingleSegmentBufferReader(origBuffer)); |
||||||
|
|
||||||
|
Assert.AreEqual(origBuffer.Length, context.PayloadLength); |
||||||
|
|
||||||
|
var payload = context.PayloadAsNewBuffer(); |
||||||
|
CollectionAssert.AreEqual(origBuffer, payload); |
||||||
|
|
||||||
|
// Getting payload multiple times is illegal |
||||||
|
Assert.Throws(typeof(InvalidOperationException), () => context.PayloadAsNewBuffer()); |
||||||
|
#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY |
||||||
|
Assert.Throws(typeof(InvalidOperationException), () => context.PayloadAsReadOnlySequence()); |
||||||
|
#endif |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase] |
||||||
|
public void ResetContextAndReinitialize() |
||||||
|
{ |
||||||
|
var origBuffer = GetTestBuffer(100); |
||||||
|
var context = new DefaultDeserializationContext(); |
||||||
|
context.Initialize(fakeBufferReaderManager.CreateSingleSegmentBufferReader(origBuffer)); |
||||||
|
|
||||||
|
Assert.AreEqual(origBuffer.Length, context.PayloadLength); |
||||||
|
|
||||||
|
// Reset invalidates context |
||||||
|
context.Reset(); |
||||||
|
|
||||||
|
Assert.AreEqual(0, context.PayloadLength); |
||||||
|
Assert.Throws(typeof(NullReferenceException), () => context.PayloadAsNewBuffer()); |
||||||
|
#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY |
||||||
|
Assert.Throws(typeof(NullReferenceException), () => context.PayloadAsReadOnlySequence()); |
||||||
|
#endif |
||||||
|
|
||||||
|
// Previously reset context can be initialized again |
||||||
|
var origBuffer2 = GetTestBuffer(50); |
||||||
|
context.Initialize(fakeBufferReaderManager.CreateSingleSegmentBufferReader(origBuffer2)); |
||||||
|
|
||||||
|
Assert.AreEqual(origBuffer2.Length, context.PayloadLength); |
||||||
|
CollectionAssert.AreEqual(origBuffer2, context.PayloadAsNewBuffer()); |
||||||
|
} |
||||||
|
|
||||||
|
private byte[] GetTestBuffer(int length) |
||||||
|
{ |
||||||
|
var testBuffer = new byte[length]; |
||||||
|
for (int i = 0; i < testBuffer.Length; i++) |
||||||
|
{ |
||||||
|
testBuffer[i] = (byte) i; |
||||||
|
} |
||||||
|
return testBuffer; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,118 @@ |
|||||||
|
#region Copyright notice and license |
||||||
|
|
||||||
|
// Copyright 2018 The gRPC Authors |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
// you may not use this file except in compliance with the License. |
||||||
|
// You may obtain a copy of the License at |
||||||
|
// |
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
using Grpc.Core.Internal; |
||||||
|
using Grpc.Core.Utils; |
||||||
|
|
||||||
|
namespace Grpc.Core.Internal.Tests |
||||||
|
{ |
||||||
|
// Creates instances of fake IBufferReader. All created instances will become invalid once Dispose is called. |
||||||
|
internal class FakeBufferReaderManager : IDisposable |
||||||
|
{ |
||||||
|
List<GCHandle> pinnedHandles = new List<GCHandle>(); |
||||||
|
bool disposed = false; |
||||||
|
public IBufferReader CreateSingleSegmentBufferReader(byte[] data) |
||||||
|
{ |
||||||
|
return CreateMultiSegmentBufferReader(new List<byte[]> { data }); |
||||||
|
} |
||||||
|
|
||||||
|
public IBufferReader CreateMultiSegmentBufferReader(IEnumerable<byte[]> dataSegments) |
||||||
|
{ |
||||||
|
GrpcPreconditions.CheckState(!disposed); |
||||||
|
GrpcPreconditions.CheckNotNull(dataSegments); |
||||||
|
var segments = new List<GCHandle>(); |
||||||
|
foreach (var data in dataSegments) |
||||||
|
{ |
||||||
|
GrpcPreconditions.CheckNotNull(data); |
||||||
|
segments.Add(GCHandle.Alloc(data, GCHandleType.Pinned)); |
||||||
|
} |
||||||
|
pinnedHandles.AddRange(segments); // all the allocated GCHandles will be freed on Dispose() |
||||||
|
return new FakeBufferReader(segments); |
||||||
|
} |
||||||
|
|
||||||
|
public IBufferReader CreateNullPayloadBufferReader() |
||||||
|
{ |
||||||
|
GrpcPreconditions.CheckState(!disposed); |
||||||
|
return new FakeBufferReader(null); |
||||||
|
} |
||||||
|
|
||||||
|
public void Dispose() |
||||||
|
{ |
||||||
|
if (!disposed) |
||||||
|
{ |
||||||
|
disposed = true; |
||||||
|
for (int i = 0; i < pinnedHandles.Count; i++) |
||||||
|
{ |
||||||
|
pinnedHandles[i].Free(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private class FakeBufferReader : IBufferReader |
||||||
|
{ |
||||||
|
readonly List<GCHandle> bufferSegments; |
||||||
|
readonly int? totalLength; |
||||||
|
readonly IEnumerator<GCHandle> segmentEnumerator; |
||||||
|
|
||||||
|
public FakeBufferReader(List<GCHandle> bufferSegments) |
||||||
|
{ |
||||||
|
this.bufferSegments = bufferSegments; |
||||||
|
this.totalLength = ComputeTotalLength(bufferSegments); |
||||||
|
this.segmentEnumerator = bufferSegments?.GetEnumerator(); |
||||||
|
} |
||||||
|
|
||||||
|
public int? TotalLength => totalLength; |
||||||
|
|
||||||
|
public bool TryGetNextSlice(out Slice slice) |
||||||
|
{ |
||||||
|
GrpcPreconditions.CheckNotNull(bufferSegments); |
||||||
|
if (!segmentEnumerator.MoveNext()) |
||||||
|
{ |
||||||
|
slice = default(Slice); |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
var segment = segmentEnumerator.Current; |
||||||
|
int sliceLen = ((byte[]) segment.Target).Length; |
||||||
|
slice = new Slice(segment.AddrOfPinnedObject(), sliceLen); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
static int? ComputeTotalLength(List<GCHandle> bufferSegments) |
||||||
|
{ |
||||||
|
if (bufferSegments == null) |
||||||
|
{ |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
int sum = 0; |
||||||
|
foreach (var segment in bufferSegments) |
||||||
|
{ |
||||||
|
var data = (byte[]) segment.Target; |
||||||
|
sum += data.Length; |
||||||
|
} |
||||||
|
return sum; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,121 @@ |
|||||||
|
#region Copyright notice and license |
||||||
|
|
||||||
|
// Copyright 2018 The gRPC Authors |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
// you may not use this file except in compliance with the License. |
||||||
|
// You may obtain a copy of the License at |
||||||
|
// |
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Grpc.Core; |
||||||
|
using Grpc.Core.Internal; |
||||||
|
using Grpc.Core.Utils; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace Grpc.Core.Internal.Tests |
||||||
|
{ |
||||||
|
public class FakeBufferReaderManagerTest |
||||||
|
{ |
||||||
|
FakeBufferReaderManager fakeBufferReaderManager; |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
fakeBufferReaderManager = new FakeBufferReaderManager(); |
||||||
|
} |
||||||
|
|
||||||
|
[TearDown] |
||||||
|
public void Cleanup() |
||||||
|
{ |
||||||
|
fakeBufferReaderManager.Dispose(); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase] |
||||||
|
public void NullPayload() |
||||||
|
{ |
||||||
|
var fakeBufferReader = fakeBufferReaderManager.CreateNullPayloadBufferReader(); |
||||||
|
Assert.IsFalse(fakeBufferReader.TotalLength.HasValue); |
||||||
|
Assert.Throws(typeof(ArgumentNullException), () => fakeBufferReader.TryGetNextSlice(out Slice slice)); |
||||||
|
} |
||||||
|
[TestCase] |
||||||
|
public void ZeroSegmentPayload() |
||||||
|
{ |
||||||
|
var fakeBufferReader = fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List<byte[]> {}); |
||||||
|
Assert.AreEqual(0, fakeBufferReader.TotalLength.Value); |
||||||
|
Assert.IsFalse(fakeBufferReader.TryGetNextSlice(out Slice slice)); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(0)] |
||||||
|
[TestCase(1)] |
||||||
|
[TestCase(10)] |
||||||
|
[TestCase(30)] |
||||||
|
[TestCase(100)] |
||||||
|
[TestCase(1000)] |
||||||
|
public void SingleSegmentPayload(int bufferLen) |
||||||
|
{ |
||||||
|
var origBuffer = GetTestBuffer(bufferLen); |
||||||
|
var fakeBufferReader = fakeBufferReaderManager.CreateSingleSegmentBufferReader(origBuffer); |
||||||
|
Assert.AreEqual(origBuffer.Length, fakeBufferReader.TotalLength.Value); |
||||||
|
|
||||||
|
Assert.IsTrue(fakeBufferReader.TryGetNextSlice(out Slice slice)); |
||||||
|
AssertSliceDataEqual(origBuffer, slice); |
||||||
|
|
||||||
|
Assert.IsFalse(fakeBufferReader.TryGetNextSlice(out Slice slice2)); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(0, 5, 10)] |
||||||
|
[TestCase(1, 1, 1)] |
||||||
|
[TestCase(10, 100, 1000)] |
||||||
|
[TestCase(100, 100, 10)] |
||||||
|
[TestCase(1000, 1000, 1000)] |
||||||
|
public void MultiSegmentPayload(int segmentLen1, int segmentLen2, int segmentLen3) |
||||||
|
{ |
||||||
|
var origBuffer1 = GetTestBuffer(segmentLen1); |
||||||
|
var origBuffer2 = GetTestBuffer(segmentLen2); |
||||||
|
var origBuffer3 = GetTestBuffer(segmentLen3); |
||||||
|
var fakeBufferReader = fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List<byte[]> { origBuffer1, origBuffer2, origBuffer3 }); |
||||||
|
|
||||||
|
Assert.AreEqual(origBuffer1.Length + origBuffer2.Length + origBuffer3.Length, fakeBufferReader.TotalLength.Value); |
||||||
|
|
||||||
|
Assert.IsTrue(fakeBufferReader.TryGetNextSlice(out Slice slice1)); |
||||||
|
AssertSliceDataEqual(origBuffer1, slice1); |
||||||
|
|
||||||
|
Assert.IsTrue(fakeBufferReader.TryGetNextSlice(out Slice slice2)); |
||||||
|
AssertSliceDataEqual(origBuffer2, slice2); |
||||||
|
|
||||||
|
Assert.IsTrue(fakeBufferReader.TryGetNextSlice(out Slice slice3)); |
||||||
|
AssertSliceDataEqual(origBuffer3, slice3); |
||||||
|
|
||||||
|
Assert.IsFalse(fakeBufferReader.TryGetNextSlice(out Slice slice4)); |
||||||
|
} |
||||||
|
|
||||||
|
private void AssertSliceDataEqual(byte[] expected, Slice actual) |
||||||
|
{ |
||||||
|
var actualSliceData = new byte[actual.Length]; |
||||||
|
actual.CopyTo(new ArraySegment<byte>(actualSliceData)); |
||||||
|
CollectionAssert.AreEqual(expected, actualSliceData); |
||||||
|
} |
||||||
|
|
||||||
|
// create a buffer of given size and fill it with some data |
||||||
|
private byte[] GetTestBuffer(int length) |
||||||
|
{ |
||||||
|
var testBuffer = new byte[length]; |
||||||
|
for (int i = 0; i < testBuffer.Length; i++) |
||||||
|
{ |
||||||
|
testBuffer[i] = (byte) i; |
||||||
|
} |
||||||
|
return testBuffer; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,151 @@ |
|||||||
|
#region Copyright notice and license |
||||||
|
|
||||||
|
// Copyright 2018 The gRPC Authors |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
// you may not use this file except in compliance with the License. |
||||||
|
// You may obtain a copy of the License at |
||||||
|
// |
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using Grpc.Core; |
||||||
|
using Grpc.Core.Internal; |
||||||
|
using Grpc.Core.Utils; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
using System.Runtime.InteropServices; |
||||||
|
|
||||||
|
#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY |
||||||
|
using System.Buffers; |
||||||
|
#endif |
||||||
|
|
||||||
|
namespace Grpc.Core.Internal.Tests |
||||||
|
{ |
||||||
|
// Converts IBufferReader into instances of ReadOnlySequence<byte> |
||||||
|
// Objects representing the sequence segments are cached to decrease GC load. |
||||||
|
public class ReusableSliceBufferTest |
||||||
|
{ |
||||||
|
FakeBufferReaderManager fakeBufferReaderManager; |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
fakeBufferReaderManager = new FakeBufferReaderManager(); |
||||||
|
} |
||||||
|
|
||||||
|
[TearDown] |
||||||
|
public void Cleanup() |
||||||
|
{ |
||||||
|
fakeBufferReaderManager.Dispose(); |
||||||
|
} |
||||||
|
|
||||||
|
#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY |
||||||
|
[TestCase] |
||||||
|
public void NullPayload() |
||||||
|
{ |
||||||
|
var sliceBuffer = new ReusableSliceBuffer(); |
||||||
|
Assert.Throws(typeof(ArgumentNullException), () => sliceBuffer.PopulateFrom(fakeBufferReaderManager.CreateNullPayloadBufferReader())); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase] |
||||||
|
public void ZeroSegmentPayload() |
||||||
|
{ |
||||||
|
var sliceBuffer = new ReusableSliceBuffer(); |
||||||
|
var sequence = sliceBuffer.PopulateFrom(fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List<byte[]> {})); |
||||||
|
|
||||||
|
Assert.AreEqual(ReadOnlySequence<byte>.Empty, sequence); |
||||||
|
Assert.IsTrue(sequence.IsEmpty); |
||||||
|
Assert.IsTrue(sequence.IsSingleSegment); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase] |
||||||
|
public void SegmentsAreCached() |
||||||
|
{ |
||||||
|
var bufferSegments1 = Enumerable.Range(0, 100).Select((_) => GetTestBuffer(50)).ToList(); |
||||||
|
var bufferSegments2 = Enumerable.Range(0, 100).Select((_) => GetTestBuffer(50)).ToList(); |
||||||
|
|
||||||
|
var sliceBuffer = new ReusableSliceBuffer(); |
||||||
|
|
||||||
|
var sequence1 = sliceBuffer.PopulateFrom(fakeBufferReaderManager.CreateMultiSegmentBufferReader(bufferSegments1)); |
||||||
|
var memoryManagers1 = GetMemoryManagersForSequenceSegments(sequence1); |
||||||
|
|
||||||
|
sliceBuffer.Invalidate(); |
||||||
|
|
||||||
|
var sequence2 = sliceBuffer.PopulateFrom(fakeBufferReaderManager.CreateMultiSegmentBufferReader(bufferSegments2)); |
||||||
|
var memoryManagers2 = GetMemoryManagersForSequenceSegments(sequence2); |
||||||
|
|
||||||
|
// check memory managers are identical objects (i.e. they've been reused) |
||||||
|
CollectionAssert.AreEquivalent(memoryManagers1, memoryManagers2); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase] |
||||||
|
public void MultiSegmentPayload_LotsOfSegments() |
||||||
|
{ |
||||||
|
var bufferSegments = Enumerable.Range(0, ReusableSliceBuffer.MaxCachedSegments + 100).Select((_) => GetTestBuffer(10)).ToList(); |
||||||
|
|
||||||
|
var sliceBuffer = new ReusableSliceBuffer(); |
||||||
|
var sequence = sliceBuffer.PopulateFrom(fakeBufferReaderManager.CreateMultiSegmentBufferReader(bufferSegments)); |
||||||
|
|
||||||
|
int index = 0; |
||||||
|
foreach (var memory in sequence) |
||||||
|
{ |
||||||
|
CollectionAssert.AreEqual(bufferSegments[index], memory.ToArray()); |
||||||
|
index ++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase] |
||||||
|
public void InvalidateMakesSequenceUnusable() |
||||||
|
{ |
||||||
|
var origBuffer = GetTestBuffer(100); |
||||||
|
|
||||||
|
var sliceBuffer = new ReusableSliceBuffer(); |
||||||
|
var sequence = sliceBuffer.PopulateFrom(fakeBufferReaderManager.CreateMultiSegmentBufferReader(new List<byte[]> { origBuffer })); |
||||||
|
|
||||||
|
Assert.AreEqual(origBuffer.Length, sequence.Length); |
||||||
|
|
||||||
|
sliceBuffer.Invalidate(); |
||||||
|
|
||||||
|
// Invalidate with make the returned sequence completely unusable and broken, users must not use it beyond the deserializer functions. |
||||||
|
Assert.Throws(typeof(ArgumentOutOfRangeException), () => { var first = sequence.First; }); |
||||||
|
} |
||||||
|
|
||||||
|
private List<MemoryManager<byte>> GetMemoryManagersForSequenceSegments(ReadOnlySequence<byte> sequence) |
||||||
|
{ |
||||||
|
var result = new List<MemoryManager<byte>>(); |
||||||
|
foreach (var memory in sequence) |
||||||
|
{ |
||||||
|
Assert.IsTrue(MemoryMarshal.TryGetMemoryManager(memory, out MemoryManager<byte> memoryManager)); |
||||||
|
result.Add(memoryManager); |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
#else |
||||||
|
[TestCase] |
||||||
|
public void OnlySupportedOnNetCore() |
||||||
|
{ |
||||||
|
// Test case needs to exist to make C# sanity test happy. |
||||||
|
} |
||||||
|
#endif |
||||||
|
private byte[] GetTestBuffer(int length) |
||||||
|
{ |
||||||
|
var testBuffer = new byte[length]; |
||||||
|
for (int i = 0; i < testBuffer.Length; i++) |
||||||
|
{ |
||||||
|
testBuffer[i] = (byte) i; |
||||||
|
} |
||||||
|
return testBuffer; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,83 @@ |
|||||||
|
#region Copyright notice and license |
||||||
|
|
||||||
|
// Copyright 2018 The gRPC Authors |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
// you may not use this file except in compliance with the License. |
||||||
|
// You may obtain a copy of the License at |
||||||
|
// |
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
using System; |
||||||
|
using Grpc.Core; |
||||||
|
using Grpc.Core.Internal; |
||||||
|
using Grpc.Core.Utils; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
using System.Runtime.InteropServices; |
||||||
|
|
||||||
|
namespace Grpc.Core.Internal.Tests |
||||||
|
{ |
||||||
|
public class SliceTest |
||||||
|
{ |
||||||
|
[TestCase(0)] |
||||||
|
[TestCase(1)] |
||||||
|
[TestCase(10)] |
||||||
|
[TestCase(100)] |
||||||
|
[TestCase(1000)] |
||||||
|
public void SliceFromNativePtr_CopyToArraySegment(int bufferLength) |
||||||
|
{ |
||||||
|
var origBuffer = GetTestBuffer(bufferLength); |
||||||
|
var gcHandle = GCHandle.Alloc(origBuffer, GCHandleType.Pinned); |
||||||
|
try |
||||||
|
{ |
||||||
|
var slice = new Slice(gcHandle.AddrOfPinnedObject(), origBuffer.Length); |
||||||
|
Assert.AreEqual(bufferLength, slice.Length); |
||||||
|
|
||||||
|
var newBuffer = new byte[bufferLength]; |
||||||
|
slice.CopyTo(new ArraySegment<byte>(newBuffer)); |
||||||
|
CollectionAssert.AreEqual(origBuffer, newBuffer); |
||||||
|
} |
||||||
|
finally |
||||||
|
{ |
||||||
|
gcHandle.Free(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase] |
||||||
|
public void SliceFromNativePtr_CopyToArraySegmentTooSmall() |
||||||
|
{ |
||||||
|
var origBuffer = GetTestBuffer(100); |
||||||
|
var gcHandle = GCHandle.Alloc(origBuffer, GCHandleType.Pinned); |
||||||
|
try |
||||||
|
{ |
||||||
|
var slice = new Slice(gcHandle.AddrOfPinnedObject(), origBuffer.Length); |
||||||
|
var tooSmall = new byte[origBuffer.Length - 1]; |
||||||
|
Assert.Catch(typeof(ArgumentException), () => slice.CopyTo(new ArraySegment<byte>(tooSmall))); |
||||||
|
} |
||||||
|
finally |
||||||
|
{ |
||||||
|
gcHandle.Free(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// create a buffer of given size and fill it with some data |
||||||
|
private byte[] GetTestBuffer(int length) |
||||||
|
{ |
||||||
|
var testBuffer = new byte[length]; |
||||||
|
for (int i = 0; i < testBuffer.Length; i++) |
||||||
|
{ |
||||||
|
testBuffer[i] = (byte) i; |
||||||
|
} |
||||||
|
return testBuffer; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,148 @@ |
|||||||
|
#region Copyright notice and license |
||||||
|
|
||||||
|
// Copyright 2019 The gRPC Authors |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
// you may not use this file except in compliance with the License. |
||||||
|
// You may obtain a copy of the License at |
||||||
|
// |
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY |
||||||
|
|
||||||
|
using Grpc.Core.Utils; |
||||||
|
using System; |
||||||
|
using System.Threading; |
||||||
|
|
||||||
|
using System.Buffers; |
||||||
|
|
||||||
|
namespace Grpc.Core.Internal |
||||||
|
{ |
||||||
|
internal class ReusableSliceBuffer |
||||||
|
{ |
||||||
|
public const int MaxCachedSegments = 1024; // ~4MB payload for 4K slices |
||||||
|
|
||||||
|
readonly SliceSegment[] cachedSegments = new SliceSegment[MaxCachedSegments]; |
||||||
|
int populatedSegmentCount; |
||||||
|
|
||||||
|
public ReadOnlySequence<byte> PopulateFrom(IBufferReader bufferReader) |
||||||
|
{ |
||||||
|
populatedSegmentCount = 0; |
||||||
|
long offset = 0; |
||||||
|
SliceSegment prevSegment = null; |
||||||
|
while (bufferReader.TryGetNextSlice(out Slice slice)) |
||||||
|
{ |
||||||
|
// Initialize cached segment if still null or just allocate a new segment if we already reached MaxCachedSegments |
||||||
|
var current = populatedSegmentCount < cachedSegments.Length ? cachedSegments[populatedSegmentCount] : new SliceSegment(); |
||||||
|
if (current == null) |
||||||
|
{ |
||||||
|
current = cachedSegments[populatedSegmentCount] = new SliceSegment(); |
||||||
|
} |
||||||
|
|
||||||
|
current.Reset(slice, offset); |
||||||
|
prevSegment?.SetNext(current); |
||||||
|
|
||||||
|
populatedSegmentCount ++; |
||||||
|
offset += slice.Length; |
||||||
|
prevSegment = current; |
||||||
|
} |
||||||
|
|
||||||
|
// Not necessary for ending the ReadOnlySequence, but for making sure we |
||||||
|
// don't keep more than MaxCachedSegments alive. |
||||||
|
prevSegment?.SetNext(null); |
||||||
|
|
||||||
|
if (populatedSegmentCount == 0) |
||||||
|
{ |
||||||
|
return ReadOnlySequence<byte>.Empty; |
||||||
|
} |
||||||
|
|
||||||
|
var firstSegment = cachedSegments[0]; |
||||||
|
var lastSegment = prevSegment; |
||||||
|
return new ReadOnlySequence<byte>(firstSegment, 0, lastSegment, lastSegment.Memory.Length); |
||||||
|
} |
||||||
|
|
||||||
|
public void Invalidate() |
||||||
|
{ |
||||||
|
if (populatedSegmentCount == 0) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
var segment = cachedSegments[0]; |
||||||
|
while (segment != null) |
||||||
|
{ |
||||||
|
segment.Reset(new Slice(IntPtr.Zero, 0), 0); |
||||||
|
var nextSegment = (SliceSegment) segment.Next; |
||||||
|
segment.SetNext(null); |
||||||
|
segment = nextSegment; |
||||||
|
} |
||||||
|
populatedSegmentCount = 0; |
||||||
|
} |
||||||
|
|
||||||
|
// Represents a segment in ReadOnlySequence |
||||||
|
// Segment is backed by Slice and the instances are reusable. |
||||||
|
private class SliceSegment : ReadOnlySequenceSegment<byte> |
||||||
|
{ |
||||||
|
readonly SliceMemoryManager pointerMemoryManager = new SliceMemoryManager(); |
||||||
|
|
||||||
|
public void Reset(Slice slice, long runningIndex) |
||||||
|
{ |
||||||
|
pointerMemoryManager.Reset(slice); |
||||||
|
Memory = pointerMemoryManager.Memory; // maybe not always necessary |
||||||
|
RunningIndex = runningIndex; |
||||||
|
} |
||||||
|
|
||||||
|
public void SetNext(ReadOnlySequenceSegment<byte> next) |
||||||
|
{ |
||||||
|
Next = next; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// Allow creating instances of Memory<byte> from Slice. |
||||||
|
// Represents a chunk of native memory, but doesn't manage its lifetime. |
||||||
|
// Instances of this class are reuseable - they can be reset to point to a different memory chunk. |
||||||
|
// That is important to make the instances cacheable (rather then creating new instances |
||||||
|
// the old ones will be reused to reduce GC pressure). |
||||||
|
private class SliceMemoryManager : MemoryManager<byte> |
||||||
|
{ |
||||||
|
private Slice slice; |
||||||
|
|
||||||
|
public void Reset(Slice slice) |
||||||
|
{ |
||||||
|
this.slice = slice; |
||||||
|
} |
||||||
|
|
||||||
|
public void Reset() |
||||||
|
{ |
||||||
|
Reset(new Slice(IntPtr.Zero, 0)); |
||||||
|
} |
||||||
|
|
||||||
|
public override Span<byte> GetSpan() |
||||||
|
{ |
||||||
|
return slice.ToSpanUnsafe(); |
||||||
|
} |
||||||
|
|
||||||
|
public override MemoryHandle Pin(int elementIndex = 0) |
||||||
|
{ |
||||||
|
throw new NotSupportedException(); |
||||||
|
} |
||||||
|
|
||||||
|
public override void Unpin() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
protected override void Dispose(bool disposing) |
||||||
|
{ |
||||||
|
// NOP |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
#endif |
@ -0,0 +1,68 @@ |
|||||||
|
#region Copyright notice and license |
||||||
|
|
||||||
|
// Copyright 2019 The gRPC Authors |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
// you may not use this file except in compliance with the License. |
||||||
|
// You may obtain a copy of the License at |
||||||
|
// |
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
using System.Threading; |
||||||
|
using Grpc.Core.Utils; |
||||||
|
|
||||||
|
namespace Grpc.Core.Internal |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Slice of native memory. |
||||||
|
/// Rough equivalent of grpc_slice (but doesn't support inlined slices, just a pointer to data and length) |
||||||
|
/// </summary> |
||||||
|
internal struct Slice |
||||||
|
{ |
||||||
|
private readonly IntPtr dataPtr; |
||||||
|
private readonly int length; |
||||||
|
|
||||||
|
public Slice(IntPtr dataPtr, int length) |
||||||
|
{ |
||||||
|
this.dataPtr = dataPtr; |
||||||
|
this.length = length; |
||||||
|
} |
||||||
|
|
||||||
|
public int Length => length; |
||||||
|
|
||||||
|
// copies data of the slice to given span. |
||||||
|
// there needs to be enough space in the destination buffer |
||||||
|
public void CopyTo(ArraySegment<byte> destination) |
||||||
|
{ |
||||||
|
Marshal.Copy(dataPtr, destination.Array, destination.Offset, length); |
||||||
|
} |
||||||
|
|
||||||
|
#if GRPC_CSHARP_SUPPORT_SYSTEM_MEMORY |
||||||
|
public Span<byte> ToSpanUnsafe() |
||||||
|
{ |
||||||
|
unsafe |
||||||
|
{ |
||||||
|
return new Span<byte>((byte*) dataPtr, length); |
||||||
|
} |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Returns a <see cref="System.String"/> that represents the current <see cref="Grpc.Core.Internal.Slice"/>. |
||||||
|
/// </summary> |
||||||
|
public override string ToString() |
||||||
|
{ |
||||||
|
return string.Format("[Slice: dataPtr={0}, length={1}]", dataPtr, length); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/linux/grpc_run_tests_matrix.sh" |
||||||
|
timeout_mins: 60 |
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "**/*sponge_log.*" |
||||||
|
regex: "github/grpc/reports/**" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
env_vars { |
||||||
|
key: "RUN_TESTS_FLAGS" |
||||||
|
value: "-f basictests linux php --inner_jobs 16 -j 2 --internal_ci --max_time=3600" |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/linux/grpc_run_tests_matrix.sh" |
||||||
|
timeout_mins: 60 |
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "**/*sponge_log.*" |
||||||
|
regex: "github/grpc/reports/**" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
env_vars { |
||||||
|
key: "RUN_TESTS_FLAGS" |
||||||
|
value: "-f basictests linux python --inner_jobs 16 -j 2 --internal_ci --max_time=3600" |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/linux/grpc_run_tests_matrix.sh" |
||||||
|
timeout_mins: 60 |
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "**/*sponge_log.*" |
||||||
|
regex: "github/grpc/reports/**" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
env_vars { |
||||||
|
key: "RUN_TESTS_FLAGS" |
||||||
|
value: "-f basictests linux ruby --inner_jobs 16 -j 2 --internal_ci --max_time=3600" |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" |
||||||
|
gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" |
||||||
|
timeout_mins: 120 |
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "**/*sponge_log.*" |
||||||
|
regex: "github/grpc/reports/**" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
env_vars { |
||||||
|
key: "RUN_TESTS_FLAGS" |
||||||
|
value: "-f basictests macos corelang --internal_ci -j 1 --inner_jobs 4 --max_time=3600" |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" |
||||||
|
gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" |
||||||
|
timeout_mins: 60 |
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "**/*sponge_log.*" |
||||||
|
regex: "github/grpc/reports/**" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
env_vars { |
||||||
|
key: "RUN_TESTS_FLAGS" |
||||||
|
value: "-f basictests macos csharp --internal_ci -j 1 --inner_jobs 4 --max_time=3600" |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" |
||||||
|
gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" |
||||||
|
timeout_mins: 60 |
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "**/*sponge_log.*" |
||||||
|
regex: "github/grpc/reports/**" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
env_vars { |
||||||
|
key: "RUN_TESTS_FLAGS" |
||||||
|
value: "-f basictests macos grpc-node --internal_ci -j 1 --inner_jobs 4 --max_time=3600" |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" |
||||||
|
gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" |
||||||
|
timeout_mins: 60 |
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "**/*sponge_log.*" |
||||||
|
regex: "github/grpc/reports/**" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
env_vars { |
||||||
|
key: "RUN_TESTS_FLAGS" |
||||||
|
value: "-f basictests macos php --internal_ci -j 1 --inner_jobs 4 --max_time=3600" |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" |
||||||
|
gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" |
||||||
|
timeout_mins: 60 |
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "**/*sponge_log.*" |
||||||
|
regex: "github/grpc/reports/**" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
env_vars { |
||||||
|
key: "RUN_TESTS_FLAGS" |
||||||
|
value: "-f basictests macos python --internal_ci -j 1 --inner_jobs 4 --max_time=3600" |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/macos/grpc_run_tests_matrix.sh" |
||||||
|
gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" |
||||||
|
timeout_mins: 60 |
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "**/*sponge_log.*" |
||||||
|
regex: "github/grpc/reports/**" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
env_vars { |
||||||
|
key: "RUN_TESTS_FLAGS" |
||||||
|
value: "-f basictests macos ruby --internal_ci -j 1 --inner_jobs 4 --max_time=3600" |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/windows/grpc_run_tests_matrix.bat" |
||||||
|
timeout_mins: 120 |
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "**/*sponge_log.*" |
||||||
|
regex: "github/grpc/reports/**" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
env_vars { |
||||||
|
key: "RUN_TESTS_FLAGS" |
||||||
|
value: "-f basictests windows c -j 1 --inner_jobs 8 --internal_ci --max_time=3600" |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/windows/grpc_run_tests_matrix.bat" |
||||||
|
timeout_mins: 60 |
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "**/*sponge_log.*" |
||||||
|
regex: "github/grpc/reports/**" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
env_vars { |
||||||
|
key: "RUN_TESTS_FLAGS" |
||||||
|
value: "-f basictests windows csharp -j 1 --inner_jobs 8 --internal_ci --max_time=3600" |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/windows/grpc_run_tests_matrix.bat" |
||||||
|
timeout_mins: 60 |
||||||
|
action { |
||||||
|
define_artifacts { |
||||||
|
regex: "**/*sponge_log.*" |
||||||
|
regex: "github/grpc/reports/**" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
env_vars { |
||||||
|
key: "RUN_TESTS_FLAGS" |
||||||
|
value: "-f basictests windows python -j 1 --inner_jobs 8 --internal_ci --max_time=3600" |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
# Copyright 2019 The gRPC Authors |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
# Config file for the internal CI (in protobuf text format) |
||||||
|
|
||||||
|
# Location of the continuous shell script in repository. |
||||||
|
build_file: "grpc/tools/internal_ci/windows/bazel_rbe.bat" |
||||||
|
|
||||||
|
timeout_mins: 60 |
||||||
|
|
||||||
|
gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" |
||||||
|
gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/resultstore_api_key" |
||||||
|
gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/rbe-windows-credentials.json" |
||||||
|
|
||||||
|
bazel_setting { |
||||||
|
# In order for Kokoro to recognize this as a bazel build and publish the bazel resultstore link, |
||||||
|
# the bazel_setting section needs to be present and "upsalite_frontend_address" needs to be |
||||||
|
# set. The rest of configuration from bazel_setting is unused (we configure everything when bazel |
||||||
|
# command is invoked). |
||||||
|
upsalite_frontend_address: "https://source.cloud.google.com" |
||||||
|
} |
Loading…
Reference in new issue