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

Add API retry-and-backoff + tests #1646

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 16 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
module.exports = {
extends: ["airbnb-base", "prettier"],
ignorePatterns: [
"tests/translations/**/*.js",
"uswds*.js"
],
ignorePatterns: ["tests/translations/**/*.js", "uswds*.js"],
rules: {
// For imports in the browser, file extensions are always required.
"import/extensions": ["error", "always"],
Expand Down Expand Up @@ -43,6 +40,21 @@ module.exports = {
"class-methods-use-this": 0,
},
},
{
files: ["api-interop-layer/**/*.test.js"],
extends: ["airbnb-base", "prettier"],
rules: {
// This rule disallows using require() on files in devDependencies. But
// for test code, we'll rely on that heavily so we can disable the rule
// in here.
"import/no-extraneous-dependencies": [0],

// For imports in Node, file extensions are optional and discouraged as
// a matter of practice.
"import/extensions": { js: "always", json: "always" },
},
env: { mocha: true },
},
{
files: [
"tests/**/*.js",
Expand Down
2 changes: 2 additions & 0 deletions api-interop-layer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.nyc_output
coverage
9 changes: 2 additions & 7 deletions api-interop-layer/data/db.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import mariadb from "mariadb";

import { sleep } from "../util/sleep.js";

export const openDatabase = async () => {
const connectionDetails = {
user: process.env.DB_USERNAME ?? "drupal",
Expand All @@ -13,13 +15,6 @@ export const openDatabase = async () => {
return mariadb.createConnection(connectionDetails);
};

const sleep = (ms) =>
new Promise((resolve) => {
setTimeout(() => {
resolve();
}, ms);
});

// Try to connect, wait, try again, wait, etc. If the database isn't ready after
// 4 attempts and 30 seconds, we'll just fail.
await openDatabase()
Expand Down
Loading
Loading