Skip to content

Commit 9284fa5

Browse files
Merge pull request #83 from Benzyl-titanium/master
Fix: change the health check to a POST request.
2 parents a2dcc2e + 70f5bac commit 9284fa5

2 files changed

Lines changed: 24 additions & 22 deletions

File tree

.github/scripts/test-webservices.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ function loadWebservicesConfig() {
3939
return {
4040
baseUrl: serverName,
4141
services: {
42-
clean2d: `${serverName}/rest-v1/util/convert/clean`,
4342
molconvert: `${serverName}/rest-v1/util/calculate/molExport`,
44-
stereoinfo: `${serverName}/rest-v1/util/calculate/cipStereoInfo`,
45-
aromatize: `${serverName}/rest-v1/util/calculate/molExport`
4643
}
4744
};
4845
} catch (error) {
@@ -53,29 +50,33 @@ function loadWebservicesConfig() {
5350

5451
async function testServiceEndpoint(url, timeout = 10000) {
5552
try {
56-
console.log(`Testing endpoint: ${url}`);
53+
console.log(`Testing endpoint (POST): ${url}`);
5754

5855
const headers = getSpoofedHeaders(url);
59-
delete headers['Content-Type'];
60-
61-
const response = await axios.get(url, {
56+
57+
const response = await axios.post(url, {
58+
structure: 'C',
59+
parameters: 'smiles'
60+
}, {
6261
timeout,
6362
headers: headers,
64-
validateStatus: function (status) {
65-
return status < 500;
66-
}
63+
validateStatus: (status) => status < 500
6764
});
6865

6966
await sleep(500);
7067

7168
console.log(`Endpoint ${url} responded with status: ${response.status}`);
69+
70+
const isSuccessful = response.status === 200;
71+
7272
return {
73-
success: response.status < 400 || response.status === 405,
73+
success: isSuccessful,
7474
status: response.status,
75-
url: url
75+
url: url,
76+
error: isSuccessful ? null : `Unexpected Status: ${response.status}`
7677
};
7778
} catch (error) {
78-
console.error(`Endpoint ${url} failed:`, error.message);
79+
console.error(`Endpoint ${error.config?.url || url} failed:`, error.message);
7980
return {
8081
success: false,
8182
error: error.message,
@@ -152,7 +153,7 @@ async function sendEmailNotification(failedServices, failedConversions) {
152153
}
153154

154155
try {
155-
const transporter = nodemailer.createTransporter({
156+
const transporter = nodemailer.createTransport({
156157
service: 'gmail',
157158
auth: { user: emailUser, pass: emailPass }
158159
});
@@ -164,7 +165,7 @@ async function sendEmailNotification(failedServices, failedConversions) {
164165
from: emailUser,
165166
to: notificationEmail,
166167
subject: '🚨 Webservice Health Check Failed',
167-
html: `<h3>Health Check Failed</h3><pre>${failedList}</pre>`
168+
html: `<h3>Health Check Failed</h3><p>The following services returned non-200 status or failed:</p><pre>${failedList}</pre>`
168169
});
169170
console.log('Email notification sent successfully');
170171
} catch (error) {
@@ -182,7 +183,7 @@ async function runHealthCheck() {
182183
try {
183184
const config = loadWebservicesConfig();
184185

185-
console.log('\n=== Testing Service Endpoints ===');
186+
console.log('\n=== Testing Service Endpoints (POST Validation) ===');
186187
for (const [name, url] of Object.entries(config.services)) {
187188
const result = await testServiceEndpoint(url);
188189
if (!result.success) {
@@ -191,10 +192,12 @@ async function runHealthCheck() {
191192
}
192193
}
193194

194-
console.log('\n=== Testing SMILES Conversions ===');
195+
console.log('\n=== Testing Full SMILES Conversions ===');
195196
const molconvertUrl = config.services.molconvert;
196197

197-
if (!hasFailures) {
198+
if (failedServices.find(s => s.url === molconvertUrl)) {
199+
console.log('Skipping conversion tests as molconvert endpoint is down.');
200+
} else {
198201
for (const smiles of TEST_SMILES) {
199202
const result = await testSmilesConversion(molconvertUrl, smiles);
200203
if (!result.overallSuccess) {
@@ -215,7 +218,7 @@ async function runHealthCheck() {
215218
}
216219

217220
} catch (error) {
218-
console.error('Error:', error.message);
221+
console.error('Fatal Error:', error.message);
219222
process.exit(1);
220223
}
221224
}

.github/workflows/webservice-health-check.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ jobs:
6464
6565
### Next Steps
6666
1. Check the webservice endpoints in \`public/marvin/js/webservices.js\`
67-
2. Verify the server status at: https://marvinjs.agungxenos.eu.org
68-
3. Test the conversion functionality manually
69-
4. Update the webservice URLs if necessary
67+
2. Test the conversion functionality manually
68+
3. Update the webservice URLs if necessary
7069
7170
### Logs
7271
Check the [workflow run](${context.payload.repository.html_url}/actions/runs/${context.runId}) for detailed logs.

0 commit comments

Comments
 (0)