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

[WIP] Add tests for the server stability #2530

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
75 changes: 74 additions & 1 deletion languageServer/src/test/definitions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
foreach_dvc_yaml,
params_dvc_yaml
} from './fixtures/examples/valid'
import { params } from './fixtures/params'
import { params, paramsJson } from './fixtures/params'
import { requestDefinitions } from './utils/requestDefinitions'
import { openTheseFilesAndNotifyServer } from './utils/openTheseFilesAndNotifyServer'
import {
Expand Down Expand Up @@ -122,4 +122,77 @@ describe('textDocument/definitions', () => {
uri: 'file:///moreParams/otherParams.json'
})
})

it('should send responses for a big number of the same file', async () => {
const multipleDocuments = [
{
languageId: 'yaml',
mockContents: file_path_dvc_yaml,
mockPath: 'dvc.yaml'
}
]

for (let i = 0; i < 100; i++) {
multipleDocuments.push({
languageId: 'yaml',
mockContents: file_path_dvc_yaml,
mockPath: 'dvc.yaml'
})
}

const [dvcYaml] = await openTheseFilesAndNotifyServer(multipleDocuments)

const response = await requestDefinitions(dvcYaml, 'params.json')

expect(response).toBeTruthy()
})

it('should send responses for a big number of different files', async () => {
const multipleDocuments = [
{
languageId: 'yaml',
mockContents: file_path_dvc_yaml,
mockPath: 'dvc.yaml'
}
]

for (let i = 0; i < 100; i++) {
multipleDocuments.push(
{
languageId: 'yaml',
mockContents: file_path_dvc_yaml.repeat(i),
mockPath: 'dvc.yaml'
},
{
languageId: 'json',
mockContents: paramsJson.repeat(i),
mockPath: 'params.json'
}
)
}

const [dvcYaml] = await openTheseFilesAndNotifyServer(multipleDocuments)

const response = await requestDefinitions(dvcYaml, 'params.json')

expect(response).toBeTruthy()
})

it('should send responses for a big number of requests to the same file', async () => {
const multipleDocuments = [
{
languageId: 'yaml',
mockContents: file_path_dvc_yaml,
mockPath: 'dvc.yaml'
}
]

for (let i = 0; i < 100; i++) {
const [dvcYaml] = await openTheseFilesAndNotifyServer(multipleDocuments)

const response = await requestDefinitions(dvcYaml, 'params.json')

expect(response).toBeTruthy()
}
})
})
7 changes: 7 additions & 0 deletions languageServer/src/test/fixtures/params/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ epochs: 15
auc: 0.9
loss: 0.2
`.trim()

export const paramsJson = `
{
"lr": 0.003,
"epochs": 15
}
`