feat: initial commit of Ghaymah internal DNS, TCP and security testing suite and report
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
// Wait for apps to be ready and run all tests
|
||||
const PROJECT_ID = '3f55ceef-78ae-40c8-a41b-0505db8c59ee';
|
||||
const APP_A_ID = 'af1b9e91-9bec-4d6a-b76c-92d7273b82ce';
|
||||
const APP_B_ID = 'fcbd895c-2370-46db-bd6a-057f6d887b0f';
|
||||
const fs = require('fs');
|
||||
|
||||
let logBuffer = [];
|
||||
function log(phase, msg) {
|
||||
const ts = new Date().toISOString();
|
||||
const line = `[${ts}] [${phase}] ${msg}`;
|
||||
console.log(line);
|
||||
logBuffer.push(line);
|
||||
}
|
||||
|
||||
async function auth() {
|
||||
const res = await fetch('https://auth.ghaymah.systems/signin/email-password', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email: 'ziadalex2003@gmail.com', password: '2062003Mz*' })
|
||||
});
|
||||
const data = await res.json();
|
||||
return { token: data.session.accessToken, userId: data.session.user.id };
|
||||
}
|
||||
|
||||
async function gql(token, query, variables = {}) {
|
||||
const res = await fetch('https://graphql.ghaymah.systems/v1/graphql', {
|
||||
method: 'POST',
|
||||
headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ query, variables })
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const { token, userId } = await auth();
|
||||
log('AUTH', `Authenticated as ${userId}`);
|
||||
|
||||
// Poll for resources to become synced
|
||||
log('WAIT', 'Waiting for apps to deploy (polling every 15s, max 3min)...');
|
||||
let attempts = 0;
|
||||
let appAReady = false, appBReady = false;
|
||||
let appAUrl = null, appBUrl = null;
|
||||
|
||||
while (attempts < 12 && (!appAReady || !appBReady)) {
|
||||
attempts++;
|
||||
const res = await gql(token, `query GetResources($userId: uuid) {
|
||||
ghaymah_cloud_resources(where: { user_id: { _eq: $userId }, deleted: { _eq: false } }) {
|
||||
id chart_name status values message
|
||||
}
|
||||
}`, { userId });
|
||||
|
||||
const resources = res.data?.ghaymah_cloud_resources || [];
|
||||
const appA = resources.find(r => r.id === APP_A_ID);
|
||||
const appB = resources.find(r => r.id === APP_B_ID);
|
||||
|
||||
log('WAIT', `Attempt ${attempts}: AppA=${appA?.status || 'not found'} | AppB=${appB?.status || 'not found'}`);
|
||||
if (appA?.message) log('WAIT', ` AppA message: ${appA.message}`);
|
||||
if (appB?.message) log('WAIT', ` AppB message: ${appB.message}`);
|
||||
|
||||
if (appA?.status === 'synced') appAReady = true;
|
||||
if (appB?.status === 'synced') appBReady = true;
|
||||
if (appA?.status === 'backoff' || appB?.status === 'backoff') {
|
||||
log('WARN', 'One of the apps is in backoff state - may need investigation');
|
||||
}
|
||||
|
||||
if (!appAReady || !appBReady) {
|
||||
await new Promise(r => setTimeout(r, 15000));
|
||||
}
|
||||
}
|
||||
|
||||
// Get app URLs via ListApps
|
||||
log('WAIT', 'Getting app URLs...');
|
||||
const apps = await gql(token, `mutation ListApps {
|
||||
listApps {
|
||||
id name image status alias url
|
||||
ports { name number hostname }
|
||||
tags { key value }
|
||||
}
|
||||
}`);
|
||||
const appList = apps.data?.listApps || [];
|
||||
log('WAIT', `Total apps now: ${appList.length}`);
|
||||
appList.forEach(a => {
|
||||
log('WAIT', ` ${a.name} | status: ${a.status} | ports: ${JSON.stringify(a.ports)}`);
|
||||
if (a.name.includes('tcp-echo') || a.name.includes('tcp-test') || a.name.includes('echo') || a.name.includes('client')) {
|
||||
log('WAIT', ` >>> TEST APP FOUND: ${a.name} at ${a.ports?.[0]?.hostname}`);
|
||||
}
|
||||
});
|
||||
|
||||
// Also check resource statuses
|
||||
const finalRes = await gql(token, `query GetResources($userId: uuid) {
|
||||
ghaymah_cloud_resources(where: { user_id: { _eq: $userId }, deleted: { _eq: false } }) {
|
||||
id chart_name status values message
|
||||
}
|
||||
}`, { userId });
|
||||
const resources = finalRes.data?.ghaymah_cloud_resources || [];
|
||||
log('STATUS', 'All resources:');
|
||||
resources.forEach(r => {
|
||||
log('STATUS', ` ${r.chart_name} | ${r.values?.name || r.id} | ${r.status} | ${r.message || ''}`);
|
||||
});
|
||||
|
||||
// Save log
|
||||
fs.writeFileSync('D:/cumin/ghaymah_dns_net_sec_tests/logs/04_deploy_status.log', logBuffer.join('\n'));
|
||||
}
|
||||
|
||||
main().catch(e => { console.error('FATAL:', e); process.exit(1); });
|
||||
Reference in New Issue
Block a user