mirror of https://github.com/grpc/grpc.git
commit
18541a1cee
69 changed files with 809 additions and 204 deletions
@ -0,0 +1,91 @@ |
||||
#region Copyright notice and license |
||||
|
||||
// Copyright 2015, Google Inc. |
||||
// All rights reserved. |
||||
// |
||||
// Redistribution and use in source and binary forms, with or without |
||||
// modification, are permitted provided that the following conditions are |
||||
// met: |
||||
// |
||||
// * Redistributions of source code must retain the above copyright |
||||
// notice, this list of conditions and the following disclaimer. |
||||
// * Redistributions in binary form must reproduce the above |
||||
// copyright notice, this list of conditions and the following disclaimer |
||||
// in the documentation and/or other materials provided with the |
||||
// distribution. |
||||
// * Neither the name of Google Inc. nor the names of its |
||||
// contributors may be used to endorse or promote products derived from |
||||
// this software without specific prior written permission. |
||||
// |
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
#endregion |
||||
|
||||
using System; |
||||
using Grpc.Core; |
||||
using Grpc.Core.Internal; |
||||
using Grpc.Core.Utils; |
||||
using NUnit.Framework; |
||||
|
||||
namespace Grpc.Core.Tests |
||||
{ |
||||
public class ChannelTest |
||||
{ |
||||
[TestFixtureTearDown] |
||||
public void CleanupClass() |
||||
{ |
||||
GrpcEnvironment.Shutdown(); |
||||
} |
||||
|
||||
[Test] |
||||
public void Constructor_RejectsInvalidParams() |
||||
{ |
||||
Assert.Throws(typeof(NullReferenceException), () => new Channel(null, Credentials.Insecure)); |
||||
} |
||||
|
||||
[Test] |
||||
public void State_IdleAfterCreation() |
||||
{ |
||||
using (var channel = new Channel("localhost", Credentials.Insecure)) |
||||
{ |
||||
Assert.AreEqual(ChannelState.Idle, channel.State); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void WaitForStateChangedAsync_InvalidArgument() |
||||
{ |
||||
using (var channel = new Channel("localhost", Credentials.Insecure)) |
||||
{ |
||||
Assert.Throws(typeof(ArgumentException), () => channel.WaitForStateChangedAsync(ChannelState.FatalFailure)); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void Target() |
||||
{ |
||||
using (var channel = new Channel("127.0.0.1", Credentials.Insecure)) |
||||
{ |
||||
Assert.IsTrue(channel.Target.Contains("127.0.0.1")); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void Dispose_IsIdempotent() |
||||
{ |
||||
var channel = new Channel("localhost", Credentials.Insecure); |
||||
channel.Dispose(); |
||||
channel.Dispose(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,69 @@ |
||||
#region Copyright notice and license |
||||
|
||||
// Copyright 2015, Google Inc. |
||||
// All rights reserved. |
||||
// |
||||
// Redistribution and use in source and binary forms, with or without |
||||
// modification, are permitted provided that the following conditions are |
||||
// met: |
||||
// |
||||
// * Redistributions of source code must retain the above copyright |
||||
// notice, this list of conditions and the following disclaimer. |
||||
// * Redistributions in binary form must reproduce the above |
||||
// copyright notice, this list of conditions and the following disclaimer |
||||
// in the documentation and/or other materials provided with the |
||||
// distribution. |
||||
// * Neither the name of Google Inc. nor the names of its |
||||
// contributors may be used to endorse or promote products derived from |
||||
// this software without specific prior written permission. |
||||
// |
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
#endregion |
||||
|
||||
using System; |
||||
|
||||
namespace Grpc.Core |
||||
{ |
||||
/// <summary> |
||||
/// Connectivity state of a channel. |
||||
/// Based on grpc_connectivity_state from grpc/grpc.h |
||||
/// </summary> |
||||
public enum ChannelState |
||||
{ |
||||
/// <summary> |
||||
/// Channel is idle |
||||
/// </summary> |
||||
Idle, |
||||
|
||||
/// <summary> |
||||
/// Channel is connecting |
||||
/// </summary> |
||||
Connecting, |
||||
|
||||
/// <summary> |
||||
/// Channel is ready for work |
||||
/// </summary> |
||||
Ready, |
||||
|
||||
/// <summary> |
||||
/// Channel has seen a failure but expects to recover |
||||
/// </summary> |
||||
TransientFailure, |
||||
|
||||
/// <summary> |
||||
/// Channel has seen a failure that it cannot recover from |
||||
/// </summary> |
||||
FatalFailure |
||||
} |
||||
} |
@ -0,0 +1,71 @@ |
||||
# Copyright 2015, Google Inc. |
||||
# All rights reserved. |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
"""Common code used throughout tests of gRPC.""" |
||||
|
||||
import collections |
||||
|
||||
|
||||
def metadata_transmitted(original_metadata, transmitted_metadata): |
||||
"""Judges whether or not metadata was acceptably transmitted. |
||||
|
||||
gRPC is allowed to insert key-value pairs into the metadata values given by |
||||
applications and to reorder key-value pairs with different keys but it is not |
||||
allowed to alter existing key-value pairs or to reorder key-value pairs with |
||||
the same key. |
||||
|
||||
Args: |
||||
original_metadata: A metadata value used in a test of gRPC. |
||||
transmitted_metadata: A metadata value corresponding to original_metadata |
||||
after having been transmitted via gRPC. |
||||
|
||||
Returns: |
||||
A boolean indicating whether transmitted_metadata accurately reflects |
||||
original_metadata after having been transmitted via gRPC. |
||||
""" |
||||
original = collections.defaultdict(list) |
||||
for key, value in original_metadata: |
||||
original[key].append(value) |
||||
transmitted = collections.defaultdict(list) |
||||
for key, value in transmitted_metadata: |
||||
transmitted[key].append(value) |
||||
|
||||
for key, values in original.iteritems(): |
||||
transmitted_values = transmitted[key] |
||||
transmitted_iterator = iter(transmitted_values) |
||||
try: |
||||
for value in values: |
||||
while True: |
||||
transmitted_value = next(transmitted_iterator) |
||||
if value == transmitted_value: |
||||
break |
||||
except StopIteration: |
||||
return False |
||||
else: |
||||
return True |
@ -1 +1 @@ |
||||
Subproject commit 3df69d3aefde7671053d4e3c242b228e5d79c83f |
||||
Subproject commit 33dd08320648ac71d7d9d732be774ed3818dccc5 |
@ -1,11 +1,17 @@ |
||||
buildgen: contains the template renderer for our build system. |
||||
buildgen: template renderer for our build system. |
||||
|
||||
distpackages: contains script to generate debian packages. |
||||
distpackages: script to generate debian packages. |
||||
|
||||
dockerfile: contains all of the docker files to test gRPC. |
||||
distrib: scripts to distribute language-specific packages. |
||||
|
||||
gce_setup: contains boilerplate for running the docker files under GCE. |
||||
dockerfile: Docker files to test gRPC. |
||||
|
||||
jenkins: support for running tests on Jenkins |
||||
doxygen: gRPC C/C++ documentation generation via Doxygen. |
||||
|
||||
run_tests: contains python scripts to properly run the tests in parallel. |
||||
gce_setup: boilerplate to run the Docker files under GCE. |
||||
|
||||
jenkins: support for running tests on Jenkins. |
||||
|
||||
profile_analyzer: pretty printer for gRPC profiling data. |
||||
|
||||
run_tests: scripts to run gRPC tests in parallel. |
||||
|
Loading…
Reference in new issue