带阿里标识的版本

This commit is contained in:
robin
2026-02-28 18:55:33 +08:00
parent 150799f41d
commit 5d0b7c7e91
477 changed files with 10813 additions and 4044 deletions

View File

@@ -1,12 +1,12 @@
//
// HttpdnsNWHTTPClient_ConcurrencyTests.m
// AlicloudHttpDNSTests
// TrustHttpDNSTests
//
// @author Created by Claude Code on 2025-11-01
// Copyright © 2025 alibaba-inc.com. All rights reserved.
// Copyright © 2025 trustapp.com. All rights reserved.
//
// - (H) (I) (N)
// 13 H:5 + I:5 + N:3
// - (H)<EFBFBD><EFBFBD>?(I) (N) <EFBFBD><EFBFBD>?
// <EFBFBD><EFBFBD>?3 H:5 + I:5 + N:3<EFBFBD><EFBFBD>?
//
#import "HttpdnsNWHTTPClientTestBase.h"
@@ -137,7 +137,7 @@
[self waitForExpectations:expectations timeout:40.0];
}
// H.4
// H.4 <EFBFBD><EFBFBD>?
- (void)testConcurrency_HighLoad50Concurrent_NoDeadlock {
NSInteger concurrentCount = 50;
NSMutableArray<XCTestExpectation *> *expectations = [NSMutableArray array];
@@ -169,7 +169,7 @@
[self waitForExpectations:expectations timeout:60.0];
//
// <EFBFBD><EFBFBD>?
XCTAssertGreaterThan(successCount, concurrentCount * 0.8, @"At least 80%% should succeed");
}
@@ -230,14 +230,14 @@
[self waitForExpectations:@[serialExpectation, parallel1, parallel2, parallel3] timeout:60.0];
}
#pragma mark - I.
#pragma mark - I. <EFBFBD><EFBFBD>?
// I.1
// I.1 <EFBFBD><EFBFBD>?
- (void)testRaceCondition_ExceedPoolCapacity_MaxFourConnections {
XCTestExpectation *expectation = [self expectationWithDescription:@"Pool capacity test"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// 10
// <EFBFBD><EFBFBD>?10 <EFBFBD><EFBFBD>?
for (NSInteger i = 0; i < 10; i++) {
NSError *error = nil;
HttpdnsNWHTTPClientResponse *response = [self.client performRequestWithURLString:@"http://127.0.0.1:11080/get"
@@ -251,7 +251,7 @@
[NSThread sleepForTimeInterval:1.0];
//
// 4
// <EFBFBD><EFBFBD>?4 <EFBFBD><EFBFBD>?
[expectation fulfill];
});
@@ -276,7 +276,7 @@
timeout:15.0
error:&error];
XCTAssertTrue(response != nil || error != nil);
//
// <EFBFBD><EFBFBD>?
[expectation fulfill];
});
@@ -284,15 +284,15 @@
[self waitForExpectations:expectations timeout:30.0];
//
// <EFBFBD><EFBFBD>?
}
// I.3 --
// I.3 --<EFBFBD><EFBFBD>?
- (void)testRaceCondition_AcquireReturnReacquire_CorrectState {
XCTestExpectation *expectation = [self expectationWithDescription:@"Acquire-Return-Reacquire"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//
// <EFBFBD><EFBFBD>?
NSError *error1 = nil;
HttpdnsNWHTTPClientResponse *response1 = [self.client performRequestWithURLString:@"http://127.0.0.1:11080/get"
userAgent:@"First"
@@ -300,7 +300,7 @@
error:&error1];
XCTAssertTrue(response1 != nil || error1 != nil);
//
// <EFBFBD><EFBFBD>?
[NSThread sleepForTimeInterval:0.1];
//
@@ -317,7 +317,7 @@
[self waitForExpectations:@[expectation] timeout:35.0];
}
// I.4 31
// I.4 <EFBFBD><EFBFBD>?1<EFBFBD><EFBFBD>?
- (void)testRaceCondition_ExpiredConnectionPruning_CreatesNewConnection {
// SKIP_SLOW_TESTS
if (getenv("SKIP_SLOW_TESTS")) {
@@ -335,7 +335,7 @@
error:&error1];
XCTAssertTrue(response1 != nil || error1 != nil);
// 30
// 30<EFBFBD><EFBFBD>?
[NSThread sleepForTimeInterval:31.0];
//
@@ -352,19 +352,19 @@
[self waitForExpectations:@[expectation] timeout:70.0];
}
// I.5
// I.5 <EFBFBD><EFBFBD>?
- (void)testRaceCondition_ErrorRecovery_PoolRemainsHealthy {
NSMutableArray<XCTestExpectation *> *expectations = [NSMutableArray array];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
//
// <EFBFBD><EFBFBD>?
for (NSInteger i = 0; i < 3; i++) {
XCTestExpectation *expectation = [self expectationWithDescription:[NSString stringWithFormat:@"Error %ld", (long)i]];
[expectations addObject:expectation];
dispatch_async(queue, ^{
NSError *error = nil;
// 使
// 使<EFBFBD><EFBFBD>?
HttpdnsNWHTTPClientResponse *response = [self.client performRequestWithURLString:@"http://127.0.0.1:11080/delay/5"
userAgent:@"ErrorTest"
timeout:1.0
@@ -391,9 +391,9 @@
[self waitForExpectations:@[recoveryExpectation] timeout:20.0];
}
#pragma mark - N.
#pragma mark - N. <EFBFBD><EFBFBD>?
// N.1
// N.1 <EFBFBD><EFBFBD>?
- (void)testConcurrentMultiPort_ParallelKeepAlive_IndependentConnections {
if (getenv("SKIP_SLOW_TESTS")) {
return;
@@ -402,7 +402,7 @@
XCTestExpectation *expectation11443 = [self expectationWithDescription:@"Port 11443 keep-alive"];
XCTestExpectation *expectation11444 = [self expectationWithDescription:@"Port 11444 keep-alive"];
// 线 1 11443 10 1
// 线 1 11443 10 1 <EFBFBD><EFBFBD>?
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
for (NSInteger i = 0; i < 10; i++) {
if (i > 0) {
@@ -417,7 +417,7 @@
[expectation11443 fulfill];
});
// 线 2 11444 10 1
// 线 2 11444 10 1 <EFBFBD><EFBFBD>?
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
for (NSInteger i = 0; i < 10; i++) {
if (i > 0) {
@@ -449,7 +449,7 @@
portRequestCounts[port] = @0;
}
// 4 100
// 4 <EFBFBD><EFBFBD>?100 <EFBFBD><EFBFBD>?
for (NSInteger i = 0; i < totalRequests; i++) {
NSNumber *port = ports[i % ports.count];
NSString *urlString = [NSString stringWithFormat:@"https://127.0.0.1:%@/get", port];
@@ -466,7 +466,7 @@
}
}
// 25
// 25 <EFBFBD><EFBFBD>?
for (NSNumber *port in ports) {
NSInteger count = [portRequestCounts[port] integerValue];
XCTAssertEqual(count, 25, @"Port %@ should receive 25 requests", port);
@@ -478,12 +478,12 @@
[self waitForExpectations:@[expectation] timeout:180.0];
}
// N.3
// N.3 <EFBFBD><EFBFBD>?
- (void)testConcurrentMultiPort_MixedLoadPattern_RobustHandling {
NSMutableArray<XCTestExpectation *> *expectations = [NSMutableArray array];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
// 1144320
// 11443<EFBFBD><EFBFBD>?0
for (NSInteger i = 0; i < 20; i++) {
XCTestExpectation *expectation = [self expectationWithDescription:[NSString stringWithFormat:@"Heavy11443 %ld", (long)i]];
[expectations addObject:expectation];
@@ -498,7 +498,7 @@
});
}
// 1144410
// 11444<EFBFBD><EFBFBD>?0
for (NSInteger i = 0; i < 10; i++) {
XCTestExpectation *expectation = [self expectationWithDescription:[NSString stringWithFormat:@"Medium11444 %ld", (long)i]];
[expectations addObject:expectation];
@@ -513,7 +513,7 @@
});
}
// 114455
// 11445<EFBFBD><EFBFBD>?
for (NSInteger i = 0; i < 5; i++) {
XCTestExpectation *expectation = [self expectationWithDescription:[NSString stringWithFormat:@"Light11445 %ld", (long)i]];
[expectations addObject:expectation];