Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Wait untill the root server is fully initialized #1623

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions tests/at_functional_test/test/check_docker_readiness.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ void main() {

test('checking for test environment readiness', () async {
_secureSocket = await secure_socket_connection(rootServer, atsignPort);
print('connection established');
socket_listener(_secureSocket);
String response = '';
while (response.isEmpty || response == 'data:null\n') {
while ((retryCount < maxRetryCount) &&
(response.isEmpty || response == 'data:null\n')) {
_secureSocket.write('lookup:signing_publickey$atsign\n');
response = await read();
print('waiting for signing public key response : $response');
await Future.delayed(Duration(milliseconds: 100));
if (response.startsWith('data:')) {
break;
}
}
await _secureSocket.close();
}, timeout: Timeout(Duration(minutes: 1)));
expect(response.startsWith('data:'), true);
});
}
14 changes: 9 additions & 5 deletions tests/at_functional_test/test/check_root_server_readiness.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ void main() {

late SecureSocket _secureSocket;

bool isRootServerStarted = false;

test('checking for root server readiness', () async {
while (retryCount < maxRetryCount) {
try {
Expand All @@ -25,16 +27,17 @@ void main() {
if (response == '@') {
print('Secure Socket is open for Root Server');
}
var isRootServerStarted =
await _lookupForSecondaryAddress(_secureSocket, atSign, rootServer);
isRootServerStarted =
await _lookupForSecondaryAddress(_secureSocket, atSign, rootServer);
if (isRootServerStarted) {
print('Closing socket connection');
print('Root server started successfully');
_secureSocket.close();
break;
} else {
print('Failed to start root server');
print('Root server is not completely initialized');
_secureSocket.close();
break;
retryCount = retryCount + 1;
await Future.delayed(Duration(seconds: 5));
}
} on SocketException {
print('Waiting for the root server to start: RetryCount: $retryCount');
Expand All @@ -46,6 +49,7 @@ void main() {
retryCount = retryCount + 1;
}
}
expect(isRootServerStarted, true, reason: 'Failed to start root server successfully');
}, timeout: Timeout(Duration(minutes: 1)));
}

Expand Down
14 changes: 12 additions & 2 deletions tests/at_functional_test/test/check_test_env.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,28 @@ void main() {
var rootServer = 'vip.ve.atsign.zone';
var atsign = '@sitaram🛠';
var atsignPort = 25017;
bool arePKAMKeysLoaded = false;
int maxRetryCount = 10;
int retryCount = 1;

test('checking for test environment readiness', () async {
_secureSocket = await secure_socket_connection(rootServer, atsignPort);
print('connection established');
socket_listener(_secureSocket);
String response = '';
while (response.isEmpty || response.startsWith('error:')) {
while ((retryCount < maxRetryCount) &&
(response.isEmpty || response.startsWith('error:'))) {
_secureSocket.write('lookup:pkaminstalled$atsign\n');
response = await read();
print('Waiting for PKAM keys to load : $response');
if (response.startsWith('data:')) {
arePKAMKeysLoaded = true;
break;
}
await Future.delayed(Duration(seconds: 1));
}
await _secureSocket.close();
}, timeout: Timeout(Duration(minutes: 1)));
expect(arePKAMKeysLoaded, true,
reason: 'PKAM Keys are not loaded successfully');
});
}