Skip to content

This corrects a problem of resource cleanup (file deletion) in unit tests. - #172

Open
vvdb-architecture wants to merge 1 commit into
zhongkaifu:mainfrom
vvdb-architecture:TestCleanupOpenFilesBug
Open

This corrects a problem of resource cleanup (file deletion) in unit tests.#172
vvdb-architecture wants to merge 1 commit into
zhongkaifu:mainfrom
vvdb-architecture:TestCleanupOpenFilesBug

Conversation

@vvdb-architecture

Copy link
Copy Markdown
Contributor

This corrects a problem in 6 unit tests:

  • MissingFile_IsRejectedWithCurrentModelStillLoaded
  • SuccessfulReload_SwapsAndDisposesPreviousModel
  • TruncatedGguf_IsRejectedWithCurrentModelStillLoaded
  • TruncatedMmProj_IsRejectedWithCurrentModelStillLoaded
  • FailedLoad_RestoresPreviousModel
  • NonGgufFile_IsRejectedWithCurrentModelStillLoaded

... which fail while executing Directory.Delete(_dir, recursive: true) with the error:

"System.IO.IOException: The process cannot access the file '...' because it is being used by another process"

The reason is that for all tests except NonGgufFile_IsRejectedWithCurrentModelStillLoaded, files are kept open by the ModelLifecycleService which is not disposed in the tests. For NonGgufFile_IsRejectedWithCurrentModelStillLoaded, the GgufReader constructor might throw an exception during parsing, which causes Dispose() never to be called and therefore the file never to be closed.

- MissingFile_IsRejectedWithCurrentModelStillLoaded
- SuccessfulReload_SwapsAndDisposesPreviousModel
- TruncatedGguf_IsRejectedWithCurrentModelStillLoaded
- TruncatedMmProj_IsRejectedWithCurrentModelStillLoaded
- FailedLoad_RestoresPreviousModel
- NonGgufFile_IsRejectedWithCurrentModelStillLoaded

... which fail while executing Directory.Delete(_dir, recursive: true) with the error:

"System.IO.IOException: The process cannot access the file '...' because it is being used by another process"

The reason is that for all tests except `NonGgufFile_IsRejectedWithCurrentModelStillLoaded`, files are kept open by the `ModelLifecycleService', which is not disposed in the tests.
For `NonGgufFile_IsRejectedWithCurrentModelStillLoaded`, the `GgufReader` constructor might throw an exception during parsing, which causes Dispose() never to be called and therefore the file never to be closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant