带阿里标识的版本
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// CacheKeyFunctionTest.m
|
||||
// AlicloudHttpDNSTests
|
||||
// TrustHttpDNSTests
|
||||
//
|
||||
// Created by xuyecan on 2024/6/12.
|
||||
// Copyright © 2024 alibaba-inc.com. All rights reserved.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@@ -70,7 +70,7 @@ static NSString *sdnsHost = @"sdns1.onlyforhttpdnstest.run.place";
|
||||
// 清空缓存
|
||||
[self.httpdns.requestManager cleanAllHostMemoryCache];
|
||||
|
||||
// 从db再加载到缓存中
|
||||
// 从db再加载到缓存<EFBFBD><EFBFBD>?
|
||||
[self.httpdns.requestManager syncLoadCacheFromDbToMemory];
|
||||
|
||||
HttpdnsResult *result = [self.httpdns resolveHostSyncNonBlocking:testHost byIpType:HttpdnsQueryIPTypeIpv4];
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// CustomTTLAndCleanCacheTest.m
|
||||
// AlicloudHttpDNS
|
||||
// TrustHttpDNS
|
||||
//
|
||||
// Created by xuyecan on 2024/6/17.
|
||||
// Copyright © 2024 alibaba-inc.com. All rights reserved.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@@ -38,8 +38,8 @@ static int TEST_CUSTOM_TTL_SECOND = 3;
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (int64_t)httpdnsHost:(NSString *)host ipType:(AlicloudHttpDNS_IPType)ipType ttl:(int64_t)ttl {
|
||||
// 为了在并发测试中域名快速过期,将ttl设置为3秒
|
||||
- (int64_t)httpdnsHost:(NSString *)host ipType:(TrustHttpDNS_IPType)ipType ttl:(int64_t)ttl {
|
||||
// 为了在并发测试中域名快速过期,将ttl设置<EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?
|
||||
NSString *testHost = hostNameIpPrefixMap.allKeys.firstObject;
|
||||
if ([host isEqual:testHost]) {
|
||||
return TEST_CUSTOM_TTL_SECOND;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// EnableReuseExpiredIpTest.m
|
||||
// AlicloudHttpDNSTests
|
||||
// TrustHttpDNSTests
|
||||
//
|
||||
// Created by xuyecan on 2024/5/28.
|
||||
// Copyright © 2024 alibaba-inc.com. All rights reserved.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@@ -39,8 +39,8 @@ static int ttlForTest = 3;
|
||||
self.currentTimeStamp = [[NSDate date] timeIntervalSince1970];
|
||||
}
|
||||
|
||||
- (int64_t)httpdnsHost:(NSString *)host ipType:(AlicloudHttpDNS_IPType)ipType ttl:(int64_t)ttl {
|
||||
// 在测试中域名快速过期
|
||||
- (int64_t)httpdnsHost:(NSString *)host ipType:(TrustHttpDNS_IPType)ipType ttl:(int64_t)ttl {
|
||||
// 在测试中域名快速过<EFBFBD><EFBFBD>?
|
||||
return ttlForTest;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ static int ttlForTest = 3;
|
||||
XCTAssertTrue([result2.host isEqualToString:host]);
|
||||
XCTAssertGreaterThan(result2.ttl, 0);
|
||||
XCTAssertLessThanOrEqual(result2.ttl, ttlForTest);
|
||||
// 因为运行复用过期解析结果,因此这里获得的一定是已经过期的
|
||||
// 因为运行复用过期解析结果,因此这里获得的一定是已经过期<EFBFBD><EFBFBD>?
|
||||
XCTAssertGreaterThan([[NSDate date] timeIntervalSince1970], result2.lastUpdatedTimeInterval + result2.ttl);
|
||||
NSString *firstIp2 = [result2 firstIpv4Address];
|
||||
XCTAssertTrue([firstIp2 hasPrefix:ipPrefix]);
|
||||
@@ -81,13 +81,13 @@ static int ttlForTest = 3;
|
||||
// 等待第二次解析触发的请求完成
|
||||
[NSThread sleepForTimeInterval:1];
|
||||
|
||||
// 再次使用nonblocking方法解析,此时应该已经拿到有效结果
|
||||
// 再次使用nonblocking方法解析,此时应该已经拿到有效结<EFBFBD><EFBFBD>?
|
||||
HttpdnsResult *result3 = [self.httpdns resolveHostSyncNonBlocking:host byIpType:HttpdnsQueryIPTypeIpv4];
|
||||
XCTAssertNotNil(result3);
|
||||
XCTAssertTrue([result3.host isEqualToString:host]);
|
||||
XCTAssertGreaterThan(result3.ttl, 0);
|
||||
XCTAssertLessThanOrEqual(result3.ttl, ttlForTest);
|
||||
// 有效结果必定未过期
|
||||
// 有效结果必定未过<EFBFBD><EFBFBD>?
|
||||
XCTAssertLessThan([[NSDate date] timeIntervalSince1970], result3.lastUpdatedTimeInterval + result3.ttl);
|
||||
NSString *firstIp3 = [result3 firstIpv4Address];
|
||||
XCTAssertTrue([firstIp3 hasPrefix:ipPrefix]);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// HttpdnsHostObjectTest.m
|
||||
// AlicloudHttpDNSTests
|
||||
// TrustHttpDNSTests
|
||||
//
|
||||
// Created by xuyecan on 2025/3/14.
|
||||
// Copyright © 2025 alibaba-inc.com. All rights reserved.
|
||||
// Copyright © 2025 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@@ -26,19 +26,19 @@
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
#pragma mark - 基本属性测试
|
||||
#pragma mark - 基本属性测<EFBFBD><EFBFBD>?
|
||||
|
||||
- (void)testHostObjectProperties {
|
||||
// 创建一个HttpdnsHostObject实例
|
||||
HttpdnsHostObject *hostObject = [[HttpdnsHostObject alloc] init];
|
||||
|
||||
// 设置基本属性
|
||||
// 设置基本属<EFBFBD><EFBFBD>?
|
||||
hostObject.host = @"example.com";
|
||||
hostObject.ttl = 60;
|
||||
hostObject.queryTimes = 1;
|
||||
hostObject.clientIP = @"192.168.1.1";
|
||||
|
||||
// 验证属性值
|
||||
// 验证属性<EFBFBD><EFBFBD>?
|
||||
XCTAssertEqualObjects(hostObject.host, @"example.com", @"host属性应该被正确设置");
|
||||
XCTAssertEqual(hostObject.ttl, 60, @"ttl属性应该被正确设置");
|
||||
XCTAssertEqual(hostObject.queryTimes, 1, @"queryTimes属性应该被正确设置");
|
||||
@@ -51,13 +51,13 @@
|
||||
// 创建一个HttpdnsIpObject实例
|
||||
HttpdnsIpObject *ipObject = [[HttpdnsIpObject alloc] init];
|
||||
|
||||
// 设置基本属性
|
||||
// 设置基本属<EFBFBD><EFBFBD>?
|
||||
ipObject.ip = @"1.2.3.4";
|
||||
ipObject.ttl = 300;
|
||||
ipObject.priority = 10;
|
||||
ipObject.detectRT = 50; // 测试新添加的detectRT属性
|
||||
ipObject.detectRT = 50; // 测试新添加的detectRT属<EFBFBD><EFBFBD>?
|
||||
|
||||
// 验证属性值
|
||||
// 验证属性<EFBFBD><EFBFBD>?
|
||||
XCTAssertEqualObjects(ipObject.ip, @"1.2.3.4", @"ip属性应该被正确设置");
|
||||
XCTAssertEqual(ipObject.ttl, 300, @"ttl属性应该被正确设置");
|
||||
XCTAssertEqual(ipObject.priority, 10, @"priority属性应该被正确设置");
|
||||
@@ -68,18 +68,18 @@
|
||||
// 创建一个HttpdnsIpObject实例
|
||||
HttpdnsIpObject *ipObject = [[HttpdnsIpObject alloc] init];
|
||||
|
||||
// 测试默认值
|
||||
// 测试默认<EFBFBD><EFBFBD>?
|
||||
XCTAssertEqual(ipObject.detectRT, -1, @"detectRT的默认值应该是-1");
|
||||
|
||||
// 测试设置检测时间
|
||||
// 测试设置检测时<EFBFBD><EFBFBD>?
|
||||
[ipObject setDetectRT:100];
|
||||
XCTAssertEqual(ipObject.detectRT, 100, @"detectRT应该被正确设置为100");
|
||||
|
||||
// 测试设置为负值
|
||||
// 测试设置为负<EFBFBD><EFBFBD>?
|
||||
[ipObject setDetectRT:-5];
|
||||
XCTAssertEqual(ipObject.detectRT, -1, @"设置负值时detectRT应该被设置为-1");
|
||||
|
||||
// 测试设置为0
|
||||
// 测试设置<EFBFBD><EFBFBD>?
|
||||
[ipObject setDetectRT:0];
|
||||
XCTAssertEqual(ipObject.detectRT, 0, @"detectRT应该被正确设置为0");
|
||||
}
|
||||
@@ -102,15 +102,15 @@
|
||||
ipv6Object.ttl = 600;
|
||||
ipv6Object.detectRT = 80;
|
||||
|
||||
// 添加IP对象到主机对象
|
||||
// 添加IP对象到主机对<EFBFBD><EFBFBD>?
|
||||
[hostObject addIpv4:ipv4Object];
|
||||
[hostObject addIpv6:ipv6Object];
|
||||
|
||||
// 验证IP对象是否被正确添加
|
||||
XCTAssertEqual(hostObject.ipv4List.count, 1, @"应该有1个IPv4对象");
|
||||
XCTAssertEqual(hostObject.ipv6List.count, 1, @"应该有1个IPv6对象");
|
||||
// 验证IP对象是否被正确添<EFBFBD><EFBFBD>?
|
||||
XCTAssertEqual(hostObject.ipv4List.count, 1, @"应该<EFBFBD><EFBFBD>?个IPv4对象");
|
||||
XCTAssertEqual(hostObject.ipv6List.count, 1, @"应该<EFBFBD><EFBFBD>?个IPv6对象");
|
||||
|
||||
// 验证IP对象的属性
|
||||
// 验证IP对象的属<EFBFBD><EFBFBD>?
|
||||
HttpdnsIpObject *retrievedIpv4 = hostObject.ipv4List.firstObject;
|
||||
XCTAssertEqualObjects(retrievedIpv4.ip, @"1.2.3.4", @"IPv4地址应该正确");
|
||||
XCTAssertEqual(retrievedIpv4.detectRT, 50, @"IPv4的detectRT应该正确");
|
||||
@@ -127,7 +127,7 @@
|
||||
HttpdnsHostObject *hostObject = [[HttpdnsHostObject alloc] init];
|
||||
hostObject.host = @"example.com";
|
||||
|
||||
// 创建多个IP对象,具有不同的检测时间
|
||||
// 创建多个IP对象,具有不同的检测时<EFBFBD><EFBFBD>?
|
||||
HttpdnsIpObject *ip1 = [[HttpdnsIpObject alloc] init];
|
||||
ip1.ip = @"1.1.1.1";
|
||||
ip1.detectRT = 100;
|
||||
@@ -142,7 +142,7 @@
|
||||
|
||||
HttpdnsIpObject *ip4 = [[HttpdnsIpObject alloc] init];
|
||||
ip4.ip = @"4.4.4.4";
|
||||
ip4.detectRT = -1; // 未检测
|
||||
ip4.detectRT = -1; // 未检<EFBFBD><EFBFBD>?
|
||||
|
||||
// 添加IP对象到主机对象(顺序不重要)
|
||||
[hostObject addIpv4:ip1];
|
||||
@@ -155,11 +155,11 @@
|
||||
|
||||
// 验证排序结果
|
||||
// 预期顺序:ip2(50ms) -> ip1(100ms) -> ip3(200ms) -> ip4(-1ms)
|
||||
XCTAssertEqual(sortedIps.count, 4, @"应该有4个IP对象");
|
||||
XCTAssertEqualObjects(sortedIps[0].ip, @"2.2.2.2", @"检测时间最短的IP应该排在第一位");
|
||||
XCTAssertEqualObjects(sortedIps[1].ip, @"1.1.1.1", @"检测时间第二短的IP应该排在第二位");
|
||||
XCTAssertEqualObjects(sortedIps[2].ip, @"3.3.3.3", @"检测时间第三短的IP应该排在第三位");
|
||||
XCTAssertEqualObjects(sortedIps[3].ip, @"4.4.4.4", @"未检测的IP应该排在最后");
|
||||
XCTAssertEqual(sortedIps.count, 4, @"应该<EFBFBD><EFBFBD>?个IP对象");
|
||||
XCTAssertEqualObjects(sortedIps[0].ip, @"2.2.2.2", @"检测时间最短的IP应该排在第一<EFBFBD><EFBFBD>?);
|
||||
XCTAssertEqualObjects(sortedIps[1].ip, @"1.1.1.1", @"检测时间第二短的IP应该排在第二<EFBFBD><EFBFBD>?);
|
||||
XCTAssertEqualObjects(sortedIps[2].ip, @"3.3.3.3", @"检测时间第三短的IP应该排在第三<EFBFBD><EFBFBD>?);
|
||||
XCTAssertEqualObjects(sortedIps[3].ip, @"4.4.4.4", @"未检测的IP应该排在最<EFBFBD><EFBFBD>?);
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// ManuallyCleanCacheTest.m
|
||||
// AlicloudHttpDNSTests
|
||||
// TrustHttpDNSTests
|
||||
//
|
||||
// Created by xuyecan on 2024/6/17.
|
||||
// Copyright © 2024 alibaba-inc.com. All rights reserved.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// MultithreadCorrectnessTest.m
|
||||
// AlicloudHttpDNSTests
|
||||
// TrustHttpDNSTests
|
||||
//
|
||||
// Created by xuyecan on 2024/5/26.
|
||||
// Copyright © 2024 alibaba-inc.com. All rights reserved.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@@ -36,7 +36,7 @@
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
// 非阻塞接口不能阻塞调用线程
|
||||
// 非阻塞接口不能阻塞调用线<EFBFBD><EFBFBD>?
|
||||
- (void)testNoneBlockingMethodShouldNotBlock {
|
||||
HttpdnsRequestManager *requestManager = self.httpdns.requestManager;
|
||||
HttpdnsRequestManager *mockedScheduler = OCMPartialMock(requestManager);
|
||||
@@ -132,7 +132,7 @@
|
||||
OCMStub([mockResolver resolve:[OCMArg any] error:(NSError * __autoreleasing *)[OCMArg anyPointer]])
|
||||
.ignoringNonObjectArgs()
|
||||
.andDo(^(NSInvocation *invocation) {
|
||||
// 第一次调用,阻塞1.5秒
|
||||
// 第一次调用,阻塞1.5<EFBFBD><EFBFBD>?
|
||||
[NSThread sleepForTimeInterval:1.5];
|
||||
[invocation setReturnValue:&mockResolverHostObjects];
|
||||
});
|
||||
@@ -146,7 +146,7 @@
|
||||
[self.httpdns resolveHostSync:ipv4OnlyHost byIpType:HttpdnsQueryIPTypeIpv4];
|
||||
});
|
||||
|
||||
// 确保第一个请求已经开始
|
||||
// 确保第一个请求已经开<EFBFBD><EFBFBD>?
|
||||
[NSThread sleepForTimeInterval:0.5];
|
||||
|
||||
NSTimeInterval startTime = [[NSDate date] timeIntervalSince1970];
|
||||
@@ -156,7 +156,7 @@
|
||||
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
||||
// 第二次请求,由于是同一个域名,所以它应该等待第一个请求的返回
|
||||
// 第一个请求返回后,第二个请求不应该再次请求,而是直接从缓存中读取到结果,返回
|
||||
// 所以它的等待时间接近1秒
|
||||
// 所以它的等待时间接<EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?
|
||||
HttpdnsResult *result = [self.httpdns resolveHostSync:ipv4OnlyHost byIpType:HttpdnsQueryIPTypeIpv4];
|
||||
XCTAssertNotNil(result);
|
||||
XCTAssertTrue([result.host isEqualToString:ipv4OnlyHost]);
|
||||
@@ -171,7 +171,7 @@
|
||||
XCTAssert(elapsedTime >= 1, @"elapsedTime should be more than 1s, but is %f", elapsedTime);
|
||||
XCTAssert(elapsedTime <= 1.5, @"elapsedTime should not be more than 1.5s, but is %f", elapsedTime);
|
||||
|
||||
// TODO 这里暂时无法跑过,因为现在锁的机制,会导致第二个请求也要去请求
|
||||
// TODO 这里暂时无法跑过,因为现在锁的机制,会导致第二个请求也要去请<EFBFBD><EFBFBD>?
|
||||
// XCTAssert(elapsedTime < 4.1, @"elapsedTime should be less than 4.1s, but is %f", elapsedTime);
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@
|
||||
// 第一次调用,返回异常
|
||||
@throw [NSException exceptionWithName:@"TestException" reason:@"TestException" userInfo:nil];
|
||||
} else {
|
||||
// 第二次调用
|
||||
// 第二次调<EFBFBD><EFBFBD>?
|
||||
[NSThread sleepForTimeInterval:0.4];
|
||||
[invocation setReturnValue:&mockResolverHostObjects];
|
||||
}
|
||||
@@ -206,7 +206,7 @@
|
||||
[self.httpdns resolveHostSync:ipv4OnlyHost byIpType:HttpdnsQueryIPTypeIpv4];
|
||||
});
|
||||
|
||||
// 确保第一个请求已经开始
|
||||
// 确保第一个请求已经开<EFBFBD><EFBFBD>?
|
||||
[NSThread sleepForTimeInterval:0.2];
|
||||
|
||||
NSTimeInterval startTime = [[NSDate date] timeIntervalSince1970];
|
||||
@@ -215,8 +215,8 @@
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
||||
// 第二次请求,由于是同一个域名,所以它应该等待第一个请求的返回
|
||||
// 第一个请求失败后,第二个请求从缓存拿不到结果,应该再次请求
|
||||
// 所以它等待的时间将是约5秒
|
||||
// 第一个请求失败后,第二个请求从缓存拿不到结果,应该再次请<EFBFBD><EFBFBD>?
|
||||
// 所以它等待的时间将是约5<EFBFBD><EFBFBD>?
|
||||
HttpdnsResult *result = [self.httpdns resolveHostSync:ipv4OnlyHost byIpType:HttpdnsQueryIPTypeIpv4];
|
||||
XCTAssertNotNil(result);
|
||||
XCTAssertTrue([result.host isEqualToString:ipv4OnlyHost]);
|
||||
@@ -232,7 +232,7 @@
|
||||
XCTAssert(elapsedTime < 0.8, @"elapsedTime should be less than 0.8s, but is %f", elapsedTime);
|
||||
}
|
||||
|
||||
// 同步接口设置最大等待时间
|
||||
// 同步接口设置最大等待时<EFBFBD><EFBFBD>?
|
||||
- (void)testSyncMethodSetBlockTimeout {
|
||||
HttpdnsRequestManager *requestManager = self.httpdns.requestManager;
|
||||
[self.httpdns cleanAllHostCache];
|
||||
@@ -266,7 +266,7 @@
|
||||
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
||||
}
|
||||
|
||||
// 限制设置的等待时间在一个合理范围,目前是0.5 - 5秒
|
||||
// 限制设置的等待时间在一个合理范围,目前<EFBFBD><EFBFBD>?.5 - 5<EFBFBD><EFBFBD>?
|
||||
- (void)testLimitResolveTimeoutRange {
|
||||
HttpdnsRequest *request = [HttpdnsRequest new];
|
||||
request.host = ipv4OnlyHost;
|
||||
@@ -285,7 +285,7 @@
|
||||
XCTAssertEqual(request.resolveTimeoutInSecond, 3.5);
|
||||
}
|
||||
|
||||
// 设置异步回调接口的最大回调等待时间
|
||||
// 设置异步回调接口的最大回调等待时<EFBFBD><EFBFBD>?
|
||||
- (void)testAsyncMethodSetBlockTimeout {
|
||||
HttpdnsRequestManager *requestManager = self.httpdns.requestManager;
|
||||
[self.httpdns cleanAllHostCache];
|
||||
@@ -318,7 +318,7 @@
|
||||
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
||||
}
|
||||
|
||||
// 多线程状态下每个线程的等待时间
|
||||
// 多线程状态下每个线程的等待时<EFBFBD><EFBFBD>?
|
||||
- (void)testMultiThreadSyncMethodMaxBlockingTime {
|
||||
HttpdnsRequestManager *requestManager = self.httpdns.requestManager;
|
||||
[self.httpdns cleanAllHostCache];
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// PresetCacheAndRetrieveTest.m
|
||||
// AlicloudHttpDNSTests
|
||||
// TrustHttpDNSTests
|
||||
//
|
||||
// Created by xuyecan on 2024/5/26.
|
||||
// Copyright © 2024 alibaba-inc.com. All rights reserved.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
/**
|
||||
* 由于使用OCMock在连续的测试用例中重复Mock对象(即使每次都已经stopMocking)会有内存错乱的问题,
|
||||
* 目前还解决不了,所以这个类中的测试case,需要手动单独执行
|
||||
* 目前还解决不了,所以这个类中的测试case,需要手动单独执<EFBFBD><EFBFBD>?
|
||||
*/
|
||||
@interface PresetCacheAndRetrieveTest : TestBase
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
XCTAssertTrue([result.ipv6s[0] isEqualToString:ipv61]);
|
||||
|
||||
// 请求类型为auto,注意,我们认为ipv6only只存在理论上,比如实验室环境
|
||||
// 因此,ipv4的地址是一定会去解析的,auto的作用在于,如果发现网络还支持ipv6,那就多获取ipv6的结果
|
||||
// 因此,ipv4的地址是一定会去解析的,auto的作用在于,如果发现网络还支持ipv6,那就多获取ipv6的结<EFBFBD><EFBFBD>?
|
||||
// 因此,这里得到的也是ipv4+ipv6
|
||||
result = [self.httpdns resolveHostSyncNonBlocking:ipv4AndIpv6Host byIpType:HttpdnsQueryIPTypeAuto];
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
XCTAssertTrue([result.ipv6s[0] isEqualToString:ipv61]);
|
||||
}
|
||||
|
||||
// ttl、lastLookupTime,ipv4和ipv6是分开处理的
|
||||
// ttl、lastLookupTime,ipv4和ipv6是分开处理<EFBFBD><EFBFBD>?
|
||||
- (void)testTTLAndLastLookUpTime {
|
||||
[self presetNetworkEnvAsIpv4AndIpv6];
|
||||
[self.httpdns cleanAllHostCache];
|
||||
@@ -195,7 +195,7 @@
|
||||
hostObject1.lastIPv4LookupTime = currentTimestamp - 1;
|
||||
hostObject1.lastIPv6LookupTime = currentTimestamp - 2;
|
||||
|
||||
// 第一次设置缓存
|
||||
// 第一次设置缓<EFBFBD><EFBFBD>?
|
||||
[self.httpdns.requestManager mergeLookupResultToManager:hostObject1 host:ipv4AndIpv6Host cacheKey:ipv4AndIpv6Host underQueryIpType:HttpdnsQueryIPTypeBoth];
|
||||
|
||||
// auto在当前环境下即请求ipv4和ipv6
|
||||
@@ -210,10 +210,10 @@
|
||||
hostObject2.v4ttl = 600;
|
||||
hostObject2.lastIPv4LookupTime = currentTimestamp - 10;
|
||||
|
||||
// 单独在缓存更新ipv4地址的相关信息
|
||||
// 单独在缓存更新ipv4地址的相关信<EFBFBD><EFBFBD>?
|
||||
[self.httpdns.requestManager mergeLookupResultToManager:hostObject2 host:ipv4AndIpv6Host cacheKey:ipv4AndIpv6Host underQueryIpType:HttpdnsQueryIPTypeIpv4];
|
||||
|
||||
// v4的信息发生变化,v6的信息保持不变
|
||||
// v4的信息发生变化,v6的信息保持不<EFBFBD><EFBFBD>?
|
||||
result = [self.httpdns resolveHostSyncNonBlocking:ipv4AndIpv6Host byIpType:HttpdnsQueryIPTypeAuto];
|
||||
XCTAssertEqual(result.ttl, hostObject2.v4ttl);
|
||||
XCTAssertEqual(result.lastUpdatedTimeInterval, hostObject2.lastIPv4LookupTime);
|
||||
@@ -222,7 +222,7 @@
|
||||
}
|
||||
|
||||
// 只缓存ipv4单栈的地址,按请求双栈类型存入,此时会标记该域名没有ipv6地址
|
||||
// 按预期,会判断该域名没有ipv6地址,因此不会返回ipv6地址,也不会发请求
|
||||
// 按预期,会判断该域名没有ipv6地址,因此不会返回ipv6地址,也不会发请<EFBFBD><EFBFBD>?
|
||||
- (void)testMergeNoIpv6ResultAndGetBoth {
|
||||
[self presetNetworkEnvAsIpv4AndIpv6];
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// ResolvingEffectiveHostTest.m
|
||||
// AlicloudHttpDNSTests
|
||||
// TrustHttpDNSTests
|
||||
//
|
||||
// Created by xuyecan on 2024/5/28.
|
||||
// Copyright © 2024 alibaba-inc.com. All rights reserved.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@@ -42,8 +42,8 @@
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (int64_t)httpdnsHost:(NSString *)host ipType:(AlicloudHttpDNS_IPType)ipType ttl:(int64_t)ttl {
|
||||
// 为了在并发测试中域名快速过期,将ttl设置为随机1-4秒
|
||||
- (int64_t)httpdnsHost:(NSString *)host ipType:(TrustHttpDNS_IPType)ipType ttl:(int64_t)ttl {
|
||||
// 为了在并发测试中域名快速过期,将ttl设置为随<EFBFBD><EFBFBD>?-4<EFBFBD><EFBFBD>?
|
||||
return arc4random_uniform(4) + 1;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
long long executeStartTimeInMs = [[NSDate date] timeIntervalSince1970] * 1000;
|
||||
HttpdnsResult *result = [self.httpdns resolveHostSyncNonBlocking:host byIpType:HttpdnsQueryIPTypeIpv4];
|
||||
long long executeEndTimeInMs = [[NSDate date] timeIntervalSince1970] * 1000;
|
||||
// 非阻塞接口任何情况下不应该阻塞超过30ms
|
||||
// 非阻塞接口任何情况下不应该阻塞超<EFBFBD><EFBFBD>?0ms
|
||||
if (executeEndTimeInMs - executeStartTimeInMs >= 30) {
|
||||
printf("XCTAssertWillFailed, host: %s, executeTime: %lldms\n", [host UTF8String], executeEndTimeInMs - executeStartTimeInMs);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// ScheduleCenterV4Test.m
|
||||
// AlicloudHttpDNSTests
|
||||
// TrustHttpDNSTests
|
||||
//
|
||||
// Created by xuyecan on 2024/6/16.
|
||||
// Copyright © 2024 alibaba-inc.com. All rights reserved.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
/**
|
||||
* 由于使用OCMock在连续的测试用例中重复Mock对象(即使每次都已经stopMocking)会有内存错乱的问题,
|
||||
* 目前还解决不了,所以这个类中的测试case,需要手动单独执行
|
||||
* 目前还解决不了,所以这个类中的测试case,需要手动单独执<EFBFBD><EFBFBD>?
|
||||
*/
|
||||
@interface ScheduleCenterV4Test : TestBase
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// ScheduleCenterV6Test.m
|
||||
// AlicloudHttpDNSTests
|
||||
// TrustHttpDNSTests
|
||||
//
|
||||
// Created by xuyecan on 2024/6/17.
|
||||
// Copyright © 2024 alibaba-inc.com. All rights reserved.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <OCMock/OCMock.h>
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
/**
|
||||
* 由于使用OCMock在连续的测试用例中重复Mock对象(即使每次都已经stopMocking)会有内存错乱的问题,
|
||||
* 目前还解决不了,所以这个类中的测试case,需要手动单独执行
|
||||
* 目前还解决不了,所以这个类中的测试case,需要手动单独执<EFBFBD><EFBFBD>?
|
||||
*/
|
||||
@interface ScheduleCenterV6Test : TestBase
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// SdnsScenarioTest.m
|
||||
// AlicloudHttpDNSTests
|
||||
// TrustHttpDNSTests
|
||||
//
|
||||
// Created by xuyecan on 2024/5/29.
|
||||
// Copyright © 2024 alibaba-inc.com. All rights reserved.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@@ -41,8 +41,8 @@ static NSString *sdnsHost = @"sdns1.onlyforhttpdnstest.run.place";
|
||||
self.currentTimeStamp = [[NSDate date] timeIntervalSince1970];
|
||||
}
|
||||
|
||||
- (int64_t)httpdnsHost:(NSString *)host ipType:(AlicloudHttpDNS_IPType)ipType ttl:(int64_t)ttl {
|
||||
// 在测试中域名快速过期
|
||||
- (int64_t)httpdnsHost:(NSString *)host ipType:(TrustHttpDNS_IPType)ipType ttl:(int64_t)ttl {
|
||||
// 在测试中域名快速过<EFBFBD><EFBFBD>?
|
||||
return ttlForTest;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user