Skip to content

Commit

Permalink
chore: change default ceramic-one ports (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
dav1do authored Jul 3, 2024
1 parent b3c33e3 commit 810b491
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 24 deletions.
2 changes: 1 addition & 1 deletion port-forward.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ then
fi

composedb=7007
ceramic=5001
ceramic=5101
offset=1
step=1

Expand Down
2 changes: 1 addition & 1 deletion suite/env/.env.dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ANCHOR_INTERVAL_MIN=780
COMPOSEDB_URLS=http://keramik-ceramic-v4-dev-tailscale-0-0:7007,http://keramik-ceramic-v4-dev-tailscale-0-1:7007
CERAMIC_URLS=http://keramik-ceramic-v4-dev-tailscale-0-0:5001,http://keramik-ceramic-v4-dev-tailscale-0-1:5001
CERAMIC_URLS=http://keramik-ceramic-v4-dev-tailscale-0-0:5101,http://keramik-ceramic-v4-dev-tailscale-0-1:5101
NETWORK=dev-unstable
STAGE=dev
2 changes: 1 addition & 1 deletion suite/env/.env.prod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ANCHOR_INTERVAL_MIN=1440
COMPOSEDB_URLS=http://keramik-ceramic-v4-prod-tailscale-0-0:7007,http://keramik-ceramic-v4-prod-tailscale-0-1:7007
CERAMIC_URLS=http://keramik-ceramic-v4-prod-tailscale-0-0:5001,http://keramik-ceramic-v4-prod-tailscale-0-1:5001
CERAMIC_URLS=http://keramik-ceramic-v4-prod-tailscale-0-0:5101,http://keramik-ceramic-v4-prod-tailscale-0-1:5101
NETWORK=mainnet
STAGE=prod
2 changes: 1 addition & 1 deletion suite/env/.env.qa
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ANCHOR_INTERVAL_MIN=780
COMPOSEDB_URLS=http://keramik-ceramic-v4-qa-tailscale-0-0:7007,http://keramik-ceramic-v4-qa-tailscale-0-1:7007
CERAMIC_URLS=http://keramik-ceramic-v4-qa-tailscale-0-0:5001,http://keramik-ceramic-v4-qa-tailscale-0-1:5001
CERAMIC_URLS=http://keramik-ceramic-v4-qa-tailscale-0-0:5101,http://keramik-ceramic-v4-qa-tailscale-0-1:5101
NETWORK=dev-unstable
STAGE=qa
2 changes: 1 addition & 1 deletion suite/env/.env.tnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ANCHOR_INTERVAL_MIN=1440
COMPOSEDB_URLS=http://keramik-ceramic-v4-tnet-tailscale-0-0:7007,http://keramik-ceramic-v4-tnet-tailscale-0-1:7007
CERAMIC_URLS=http://keramik-ceramic-v4-tnet-tailscale-0-0:5001,http://keramik-ceramic-v4-tnet-tailscale-0-1:5001
CERAMIC_URLS=http://keramik-ceramic-v4-tnet-tailscale-0-0:5101,http://keramik-ceramic-v4-tnet-tailscale-0-1:5101
NETWORK=testnet-clay
STAGE=tnet
45 changes: 26 additions & 19 deletions suite/src/__tests__/correctness/fast/sync-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@ async function getEventData(url: string, eventId: string): Promise<ReconEvent> {

async function readEvents(
url: string,
resumeToken: String,
numExpectedEvents: number,
resumeToken: string,
eventCids: string[],
timeoutMs = READ_EVENTS_TIMEOUT_MS,
) {
const events = []
console.log(
`readEvents: ${url} starting at ${resumeToken}, waiting for ${numExpectedEvents} events`,
`readEvents: ${url} starting at ${resumeToken}, waiting for ${eventCids} events`,
)
var startTime = Date.now()
while (events.length < numExpectedEvents) {
while (events.length < eventCids.length) {
if (Date.now() - startTime > timeoutMs) {
// if it took more than a minute, quit
console.warn(
`readEvents: timeout after ${timeoutMs} millis waiting for ${numExpectedEvents} but only ${events.length} events found`,
`readEvents: timeout after ${timeoutMs} millis waiting for ${eventCids} but only ${events.length} events found`,
)
break
}
Expand All @@ -89,7 +89,9 @@ async function readEvents(

for (const event of data.events) {
const eventWithData = await getEventData(url, event.id)
events.push(eventWithData)
if (eventCids.includes(eventWithData.id)) {
events.push(eventWithData)
}
}

await delayMs(100)
Expand All @@ -110,15 +112,15 @@ function sortModelEvents(events: ReconEvent[]): ReconEvent[] {
}

// Wait up till retries seconds for all urls to have at least count events
async function waitForEventCount(urls: string[], count: number, resumeTokens: string[]) {
async function waitForEventCount(urls: string[], eventCids: string[], resumeTokens: string[]) {
if (urls.length !== resumeTokens.length) {
throw new Error('The lengths of urls and resumeTokens arrays must be equal')
}
let all_good = true
for (let i = 0; i < urls.length; i++) {
let url = urls[i]
let events = await readEvents(url, resumeTokens[i], count)
if (events.length < count) {
let events = await readEvents(url, resumeTokens[i], eventCids)
if (events.length < eventCids.length) {
all_good = false
break
}
Expand Down Expand Up @@ -155,13 +157,14 @@ describe('sync events', () => {
await registerInterest(url, modelID)
}
const sortedModelEvents = sortModelEvents(modelEvents)
await waitForEventCount(CeramicUrls, modelEvents.length, resumeTokens)
const eventCids = modelEvents.map((e) => e.id)
await waitForEventCount(CeramicUrls, eventCids, resumeTokens)

// Use a sorted expected value for stable tests
// Validate each node got the events, including the first node
for (let i = 0; i < CeramicUrls.length; i++) {
const url = CeramicUrls[i]
const events = await readEvents(url, resumeTokens[i], modelEvents.length)
const events = await readEvents(url, resumeTokens[i], eventCids)

expect(events).toEqual(sortedModelEvents)
}
Expand All @@ -178,15 +181,16 @@ describe('sync events', () => {
await registerInterest(url, modelID)
}
await writeEvents(firstNodeUrl, modelEvents)
const eventCids = modelEvents.map((e) => e.id)

await waitForEventCount(CeramicUrls, modelEvents.length, resumeTokens)
await waitForEventCount(CeramicUrls, eventCids, resumeTokens)

// Use a sorted expected value for stable tests
const sortedModelEvents = sortModelEvents(modelEvents)
// Validate each node got the events, including the first node
for (let idx in CeramicUrls) {
let url = CeramicUrls[idx]
let events = await readEvents(url, resumeTokens[idx], modelEvents.length)
let events = await readEvents(url, resumeTokens[idx], eventCids)

expect(events).toEqual(sortedModelEvents)
}
Expand All @@ -210,15 +214,16 @@ describe('sync events', () => {
}
// Write the second half of the data
await writeEvents(firstNodeUrl, secondHalf)
const eventCids = modelEvents.map((e) => e.id)

await waitForEventCount(CeramicUrls, modelEvents.length, resumeTokens)
await waitForEventCount(CeramicUrls,eventCids, resumeTokens)

// Use a sorted expected value for stable tests
const sortedModelEvents = sortModelEvents(modelEvents)
// Validate each node got the events, including the first node
for (let idx in CeramicUrls) {
let url = CeramicUrls[idx]
let events = await readEvents(url, resumeTokens[idx], modelEvents.length)
let events = await readEvents(url, resumeTokens[idx], eventCids)

expect(events).toEqual(sortedModelEvents)
}
Expand All @@ -243,15 +248,16 @@ describe('sync events', () => {
writeEvents(firstNodeUrl, firstHalf),
writeEvents(secondNodeUrl, secondHalf),
])
const eventCids = modelEvents.map((e) => e.id)

await waitForEventCount(CeramicUrls, modelEvents.length, resumeTokens)
await waitForEventCount(CeramicUrls, eventCids, resumeTokens)

// Use a sorted expected value for stable tests
const sortedModelEvents = sortModelEvents(modelEvents)
// Validate each node got the events, including the first node
for (let idx in CeramicUrls) {
let url = CeramicUrls[idx]
let events = await readEvents(url, resumeTokens[idx], modelEvents.length)
let events = await readEvents(url, resumeTokens[idx], eventCids)

expect(events).toEqual(sortedModelEvents)
}
Expand Down Expand Up @@ -295,15 +301,16 @@ describe('sync events', () => {
}
}
await Promise.all(writes)
const eventCids = allEvents.map((e) => e.id)

await waitForEventCount(CeramicUrls, allEvents.length, resumeTokens)
await waitForEventCount(CeramicUrls, eventCids, resumeTokens)

// Use a sorted expected value for stable tests
const sortedModelEvents = sortModelEvents(allEvents)
// Validate each node got the events, including the first node
for (let idx in CeramicUrls) {
let url = CeramicUrls[idx]
const foundEvents = await readEvents(url, resumeTokens[idx], allEvents.length)
const foundEvents = await readEvents(url, resumeTokens[idx], eventCids)

expect(foundEvents).toEqual(sortedModelEvents)
}
Expand Down

0 comments on commit 810b491

Please sign in to comment.