Skip to content

Commit 20e7ef4

Browse files
committed
Revert "Temporarily turn on device sync and multiple client instances"
This reverts commit 76fcd9b.
1 parent 8f23c7b commit 20e7ef4

File tree

12 files changed

+729
-110
lines changed

12 files changed

+729
-110
lines changed

chaos/db.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import type { ChaosProvider } from "@chaos/provider";
22
import type { WorkerManager } from "@workers/manager";
33

44
export type DbChaosConfig = {
5-
minLockTime: number;
6-
maxLockTime: number;
7-
lockInterval: number;
5+
minLockTime: number; // Minimum duration in milliseconds to lock the database
6+
maxLockTime: number; // Maximum duration in milliseconds to lock the database
7+
lockInterval: number; // Interval in milliseconds between lock attempts
88
impactedWorkerPercentage: number; // number between 0 and 100 for what % of workers to lock on each run
99
};
1010

@@ -14,6 +14,7 @@ export class DbChaos implements ChaosProvider {
1414
interval?: NodeJS.Timeout;
1515

1616
constructor(config: DbChaosConfig) {
17+
validateConfig(config);
1718
this.config = config;
1819
}
1920

@@ -70,3 +71,26 @@ export class DbChaos implements ChaosProvider {
7071
await Promise.allSettled(Array.from(this.activeLocks.values()));
7172
}
7273
}
74+
75+
function validateConfig(config: DbChaosConfig): void {
76+
if (config.minLockTime > config.maxLockTime) {
77+
throw new Error(
78+
"Minimum lock time cannot be greater than maximum lock time",
79+
);
80+
}
81+
82+
if (
83+
config.impactedWorkerPercentage < 0 ||
84+
config.impactedWorkerPercentage > 100
85+
) {
86+
throw new Error("Impacted worker percentage must be between 0 and 100");
87+
}
88+
89+
if (!config.lockInterval) {
90+
throw new Error("Lock interval must be defined");
91+
}
92+
93+
if (config.impactedWorkerPercentage === undefined) {
94+
throw new Error("Impacted worker percentage must be defined");
95+
}
96+
}

chaos/network.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ export type NetworkChaosConfig = {
1111
interval: number; // How often to apply chaos in ms
1212
};
1313

14-
// import type { Worker } from "@workers/manager";
15-
1614
export class NetworkChaos implements ChaosProvider {
1715
config: NetworkChaosConfig;
1816
interval?: NodeJS.Timeout;

chaos/provider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { type WorkerManager } from "@workers/manager";
22

3+
// Generic interface for the Chaos Provider.
4+
// A Chaos Provider is started after the test has been setup, but before we start performing actions
5+
// It is stopped after the core of the test has been completed, and should remove all chaos so that final
6+
// validations can be performed cleanly.
37
export interface ChaosProvider {
48
start(workers: WorkerManager): Promise<void>;
59
stop(): Promise<void>;

chaos/streams.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { typeofStream, type WorkerClient } from "@workers/main";
33
import type { WorkerManager } from "@workers/manager";
44

55
export type StreamsConfig = {
6-
cloned: boolean;
6+
cloned: boolean; // Should the stream be run against the workers used in the tests, or a cloned client instance?
77
};
88

99
export class StreamsChaos implements ChaosProvider {

forks/cli.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
type RuntimeConfig,
1515
} from "./config";
1616

17+
// CLI options for fork testing
1718
interface ForkOptions {
1819
count: number; // Number of times to run the process (default: 100)
1920
cleanAll: boolean; // Clean all raw logs before starting
@@ -223,7 +224,7 @@ async function main() {
223224
type: "string",
224225
choices: ["local", "dev", "production"] as const,
225226
default:
226-
(process.env.XMTP_ENV as "local" | "dev" | "production") || "dev",
227+
(process.env.XMTP_ENV as "local" | "dev" | "production") || "local",
227228
describe: "XMTP environment",
228229
})
229230
.option("network-chaos-level", {

forks/config.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ export const workerNames = [
1212
"random3",
1313
"random4",
1414
"random5",
15-
"random1",
16-
"random2",
17-
"random3",
18-
"random4",
19-
"random5",
2015
] as string[];
2116

2217
// Operations configuration - enable/disable specific operations
@@ -28,10 +23,11 @@ export const epochRotationOperations = {
2823
export const otherOperations = {
2924
createInstallation: true, // creates a new installation for a random worker
3025
sendMessage: true, // sends a message to the group
31-
sync: false, // syncs the group
26+
sync: true, // syncs the group
3227
};
3328
export const randomInboxIdsCount = 50; // How many inboxIds to use randomly in the add/remove operations
3429
export const installationCount = 2; // How many installations to use randomly in the createInstallation operations
30+
export const maxConsecutiveFailures = 5; // Maximum number of times we throw an error verifying the results of a batch of operations
3531
export const testName = "forks";
3632

3733
// Network chaos configuration

forks/forks.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
epochRotationOperations,
1414
getConfigFromEnv,
1515
installationCount,
16+
maxConsecutiveFailures,
1617
multinodeContainers,
1718
NODE_VERSION,
1819
otherOperations,
@@ -149,7 +150,8 @@ describe(testName, () => {
149150
let currentEpoch = 0n;
150151
let numConsecutiveFailures = 0;
151152

152-
while (currentEpoch < targetEpoch && numConsecutiveFailures < 5) {
153+
// Run until we reach the target epoch or we hit 5 consecutive failures.
154+
while (currentEpoch < targetEpoch) {
153155
const parallelOperationsArray = Array.from(
154156
{ length: parallelOperations },
155157
() =>
@@ -198,6 +200,8 @@ describe(testName, () => {
198200
}
199201
})(),
200202
);
203+
204+
// We want to wait for all operations to complete, but ignore any errors which may be caused by the chaos
201205
const results = await Promise.allSettled(parallelOperationsArray);
202206
for (const result of results) {
203207
if (result.status === "rejected") {
@@ -221,6 +225,9 @@ describe(testName, () => {
221225
} catch (e) {
222226
console.error(`Group ${groupIndex + 1} operation failed:`, e);
223227
numConsecutiveFailures++;
228+
if (numConsecutiveFailures >= maxConsecutiveFailures) {
229+
throw e;
230+
}
224231
}
225232
}
226233

@@ -232,6 +239,7 @@ describe(testName, () => {
232239
} catch (e: any) {
233240
const msg = `Error during fork testing: ${e}`;
234241
console.error(msg);
242+
// This will fail the test if there were too many failures
235243
expect.fail(msg);
236244
} finally {
237245
clearInterval(verifyInterval);

helpers/versions.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,6 @@ export const AgentVersionList = [
105105

106106
// Node SDK version list
107107
export const VersionList = [
108-
{
109-
Client: Client440,
110-
Conversation: Conversation440,
111-
Dm: Dm440,
112-
Group: Group440,
113-
nodeSDK: "4.4.0",
114-
nodeBindings: "1.6.1",
115-
auto: true,
116-
},
117108
{
118109
Client: Client430Dev,
119110
Conversation: Conversation430Dev,
@@ -123,6 +114,15 @@ export const VersionList = [
123114
nodeBindings: "1.7.0",
124115
auto: true,
125116
},
117+
{
118+
Client: Client440,
119+
Conversation: Conversation440,
120+
Dm: Dm440,
121+
Group: Group440,
122+
nodeSDK: "4.4.0",
123+
nodeBindings: "1.6.1",
124+
auto: true,
125+
},
126126
{
127127
Client: Client430,
128128
Conversation: Conversation430,
@@ -275,8 +275,6 @@ export const regressionClient = async (
275275
loggingLevel,
276276
apiUrl,
277277
appVersion: APP_VERSION,
278-
historySyncUrl: "http://localhost:5558",
279-
disableDeviceSync: false,
280278
codecs: [new ReactionCodec(), new ReplyCodec()],
281279
});
282280
} catch (error) {

multinode/docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,16 @@ services:
113113
- mlsdb
114114
- validation
115115

116-
validation:
117-
image: ghcr.io/xmtp/mls-validation-service:main
118-
platform: linux/amd64
119-
120116
history-server:
121117
image: ghcr.io/xmtp/message-history-server:main
122118
platform: linux/amd64
123119
ports:
124120
- 5558:5558
125121

122+
validation:
123+
image: ghcr.io/xmtp/mls-validation-service:main
124+
platform: linux/amd64
125+
126126
db:
127127
image: postgres:13
128128
environment:

scripts/revokeInstallations.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { existsSync } from "node:fs";
22
import { readFile } from "node:fs/promises";
33
import { join } from "node:path";
44
import { createSigner } from "@helpers/client";
5-
import { type XmtpEnv } from "@helpers/versions";
6-
import { Client } from "@xmtp/node-sdk";
5+
import { Client, type XmtpEnv } from "@helpers/versions";
76

87
// Check Node.js version
98
const nodeVersion = process.versions.node;

0 commit comments

Comments
 (0)