-
Notifications
You must be signed in to change notification settings - Fork 0
feat: [NET-1393] Collect RTTs #30
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
544857b
rename Topology#getPeers()
teogeb 0b66b22
Neighbor interface
teogeb b858f49
add rtt field to Neighbor entity and column to neighbors table
teogeb a2cb490
use real Topology class
teogeb abd00a4
add test
teogeb 23d4c0f
fix comment
teogeb d7c5a60
add test
teogeb 7cf2c35
logging
teogeb 812437a
improve type safety
teogeb 7e7f53d
stricter comparison
teogeb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import 'reflect-metadata' | ||
|
||
import { PeerDescriptor, randomDhtAddress, toDhtAddress, toDhtAddressRaw } from '@streamr/dht' | ||
import { StreamPartIDUtils } from '@streamr/utils' | ||
import { range } from 'lodash' | ||
import Container from 'typedi' | ||
import { CONFIG_TOKEN } from '../src/Config' | ||
import { Topology } from '../src/crawler/Topology' | ||
import { NodeRepository } from '../src/repository/NodeRepository' | ||
import { createDatabase } from '../src/utils' | ||
import { TEST_DATABASE_NAME, dropTestDatabaseIfExists } from './utils' | ||
|
||
const STREAM_PART_ID = StreamPartIDUtils.parse('stream#1') | ||
|
||
describe('NodeRepository', () => { | ||
|
||
beforeEach(async () => { | ||
const config = { | ||
database: { | ||
host: '10.200.10.1', | ||
name: TEST_DATABASE_NAME, | ||
user: 'root', | ||
password: 'password' | ||
} | ||
} | ||
await dropTestDatabaseIfExists(config.database) | ||
await createDatabase(config.database) | ||
Container.set(CONFIG_TOKEN, config) | ||
}) | ||
|
||
afterEach(() => { | ||
Container.reset() | ||
}) | ||
|
||
it('replace topology', async () => { | ||
const repository = Container.get(NodeRepository) | ||
|
||
const peerDescriptors: PeerDescriptor[] = range(2).map(() => ({ | ||
nodeId: toDhtAddressRaw(randomDhtAddress()) | ||
} as any)) | ||
const nodes = [{ | ||
peerDescriptor: peerDescriptors[0], | ||
streamPartitions: [{ | ||
id: STREAM_PART_ID, | ||
contentDeliveryLayerNeighbors: [{ peerDescriptor: peerDescriptors[1], rtt: 100 }], | ||
controlLayerNeighbors: undefined as any | ||
}] | ||
}, { | ||
peerDescriptor: peerDescriptors[1], | ||
streamPartitions: [{ | ||
id: STREAM_PART_ID, | ||
contentDeliveryLayerNeighbors: [{ peerDescriptor: peerDescriptors[0], rtt: 200 }], | ||
controlLayerNeighbors: undefined as any | ||
}] | ||
}] | ||
const topology = new Topology(nodes) | ||
await repository.replaceNetworkTopology(topology) | ||
|
||
const nodeIds = peerDescriptors.map((p) => toDhtAddress(p.nodeId)) | ||
const actualNodes = await repository.getNodes() | ||
expect(actualNodes.items.map((item) => item.id)).toIncludeSameMembers(nodeIds) | ||
const actualNeighbors = await repository.getNeighbors() | ||
expect(actualNeighbors.items).toHaveLength(1) | ||
expect(actualNeighbors.items[0].streamPartId).toBe(STREAM_PART_ID) | ||
expect(actualNeighbors.items[0].rtt).toBe(150) | ||
expect([actualNeighbors.items[0].nodeId1, actualNeighbors.items[0].nodeId2]).toIncludeSameMembers(nodeIds) | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.