1*cc02d7e2SAndroid Build Coastguard Worker /* 2*cc02d7e2SAndroid Build Coastguard Worker * 3*cc02d7e2SAndroid Build Coastguard Worker * Copyright 2019 gRPC authors. 4*cc02d7e2SAndroid Build Coastguard Worker * 5*cc02d7e2SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 6*cc02d7e2SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 7*cc02d7e2SAndroid Build Coastguard Worker * You may obtain a copy of the License at 8*cc02d7e2SAndroid Build Coastguard Worker * 9*cc02d7e2SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 10*cc02d7e2SAndroid Build Coastguard Worker * 11*cc02d7e2SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 12*cc02d7e2SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 13*cc02d7e2SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*cc02d7e2SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 15*cc02d7e2SAndroid Build Coastguard Worker * limitations under the License. 16*cc02d7e2SAndroid Build Coastguard Worker * 17*cc02d7e2SAndroid Build Coastguard Worker */ 18*cc02d7e2SAndroid Build Coastguard Worker 19*cc02d7e2SAndroid Build Coastguard Worker #import <Foundation/Foundation.h> 20*cc02d7e2SAndroid Build Coastguard Worker #import <XCTest/XCTest.h> 21*cc02d7e2SAndroid Build Coastguard Worker 22*cc02d7e2SAndroid Build Coastguard Worker NS_ASSUME_NONNULL_BEGIN 23*cc02d7e2SAndroid Build Coastguard Worker 24*cc02d7e2SAndroid Build Coastguard Worker /* Default test timeout in seconds for interopt test. */ 25*cc02d7e2SAndroid Build Coastguard Worker FOUNDATION_EXPORT const NSTimeInterval GRPCInteropTestTimeoutDefault; 26*cc02d7e2SAndroid Build Coastguard Worker 27*cc02d7e2SAndroid Build Coastguard Worker // Block typedef for waiting for a target group of expectations via XCTWaiter. 28*cc02d7e2SAndroid Build Coastguard Worker typedef void (^GRPCTestWaiter)(NSArray<XCTestExpectation *> *expectations, NSTimeInterval timeout); 29*cc02d7e2SAndroid Build Coastguard Worker 30*cc02d7e2SAndroid Build Coastguard Worker // Block typedef for asserting a given expression value with optional retry. 31*cc02d7e2SAndroid Build Coastguard Worker typedef void (^GRPCTestAssert)(BOOL expressionValue, NSString *message); 32*cc02d7e2SAndroid Build Coastguard Worker 33*cc02d7e2SAndroid Build Coastguard Worker // Block typedef for a test run. Test run should call waiter to wait for a group of expectations 34*cc02d7e2SAndroid Build Coastguard Worker // with timeout. Test run can also optionally invoke assertBlock to report assertion failure. 35*cc02d7e2SAndroid Build Coastguard Worker // Failed assertion will be retried up to maximum retry. 36*cc02d7e2SAndroid Build Coastguard Worker typedef void (^GRPCTestRunBlock)(GRPCTestWaiter waiterBlock, GRPCTestAssert assertBlock); 37*cc02d7e2SAndroid Build Coastguard Worker 38*cc02d7e2SAndroid Build Coastguard Worker /** 39*cc02d7e2SAndroid Build Coastguard Worker * Common utility to fetch plain text local interop server address. 40*cc02d7e2SAndroid Build Coastguard Worker * 41*cc02d7e2SAndroid Build Coastguard Worker * @return Interop test server address including host and port. 42*cc02d7e2SAndroid Build Coastguard Worker */ 43*cc02d7e2SAndroid Build Coastguard Worker FOUNDATION_EXPORT NSString *GRPCGetLocalInteropTestServerAddressPlainText(void); 44*cc02d7e2SAndroid Build Coastguard Worker 45*cc02d7e2SAndroid Build Coastguard Worker /** 46*cc02d7e2SAndroid Build Coastguard Worker * Common utility to fetch ssl local interop server address. 47*cc02d7e2SAndroid Build Coastguard Worker * 48*cc02d7e2SAndroid Build Coastguard Worker * @return Interop test server address including host and port. 49*cc02d7e2SAndroid Build Coastguard Worker */ 50*cc02d7e2SAndroid Build Coastguard Worker FOUNDATION_EXPORT NSString *GRPCGetLocalInteropTestServerAddressSSL(void); 51*cc02d7e2SAndroid Build Coastguard Worker 52*cc02d7e2SAndroid Build Coastguard Worker /** 53*cc02d7e2SAndroid Build Coastguard Worker * Common utility to fetch remote interop test server address. 54*cc02d7e2SAndroid Build Coastguard Worker * 55*cc02d7e2SAndroid Build Coastguard Worker * @return Interop test server address including host and port. 56*cc02d7e2SAndroid Build Coastguard Worker */ 57*cc02d7e2SAndroid Build Coastguard Worker FOUNDATION_EXPORT NSString *GRPCGetRemoteInteropTestServerAddress(void); 58*cc02d7e2SAndroid Build Coastguard Worker 59*cc02d7e2SAndroid Build Coastguard Worker /** 60*cc02d7e2SAndroid Build Coastguard Worker * Common utility to print interop server address information to console via NSLog. 61*cc02d7e2SAndroid Build Coastguard Worker */ 62*cc02d7e2SAndroid Build Coastguard Worker FOUNDATION_EXPORT void GRPCPrintInteropTestServerDebugInfo(void); 63*cc02d7e2SAndroid Build Coastguard Worker 64*cc02d7e2SAndroid Build Coastguard Worker /** 65*cc02d7e2SAndroid Build Coastguard Worker * Common utility to run a test block until success, up to predefined number of repeats. 66*cc02d7e2SAndroid Build Coastguard Worker * @param testCase Associated test case run for reporting test failures. 67*cc02d7e2SAndroid Build Coastguard Worker * @param testBlock Target test block to be invoked by the utility function. The block will be 68*cc02d7e2SAndroid Build Coastguard Worker * invoked synchronously before the function returns. 69*cc02d7e2SAndroid Build Coastguard Worker * @return YES if test run succeeded within the repeat limit. NO otherwise. 70*cc02d7e2SAndroid Build Coastguard Worker */ 71*cc02d7e2SAndroid Build Coastguard Worker FOUNDATION_EXPORT BOOL GRPCTestRunWithFlakeRepeats(XCTestCase *testCase, 72*cc02d7e2SAndroid Build Coastguard Worker GRPCTestRunBlock testBlock); 73*cc02d7e2SAndroid Build Coastguard Worker 74*cc02d7e2SAndroid Build Coastguard Worker /** 75*cc02d7e2SAndroid Build Coastguard Worker * Common utility to reset gRPC call's active connections. 76*cc02d7e2SAndroid Build Coastguard Worker */ 77*cc02d7e2SAndroid Build Coastguard Worker FOUNDATION_EXPORT void GRPCResetCallConnections(void); 78*cc02d7e2SAndroid Build Coastguard Worker 79*cc02d7e2SAndroid Build Coastguard Worker NS_ASSUME_NONNULL_END 80