Documentation
¶
Overview ¶
Package storetest is the contract suite of the artifacts module's stores: one set of expectations that every implementation of the repository, item, trash, package, build, remote cache, Git LFS lock, Bower registration and archived-item stores and of the blob and replica indexes must meet.
Role ¶
artifacts module, adapter layer, test support. The module's in-memory and SQL adapters run Run over their own stores, and the metadata store's contract runs it with a Factory over its stores, so its in-memory, SQLite and PostgreSQL stores pass the same cases. The package imports the standard library, the kernel, the platform and the module's core and api only.
Inputs ¶
- Run: a Factory, which returns a fresh, empty port.Store and registers its cleanup with t.
Outputs ¶
- Factory and Run.
- RunDockerPages, the Docker page reader's contract (port.DockerPageStore): DockerPages, with ManifestFolders and ImageManifests.
- RunRepoPages, the contract of RepoStore.Page: the window, its More and Total, and the class, project, package type and visibility filters, in key order whatever the insertion order (#1408), and the window after a key that a walk of the whole list reads (#1409). It is a subtest of its own, RepoPages, run beside Run.
- RunVersionNames, the contract of PackageVersionNames: a package's version names in exactly Versions' order, following later writes and deletes, and a package's own (#1404). It is a subtest of its own, VersionNames, run beside Run rather than from it.
- RunPackagePages, the contract of port.PackagePages and of PackageVersionNames' CountVersions and VersionNamesAt: Puppet's, Chef's and Ansible's versions read back newest first in their lists' order whatever the write order, and a repository's packages with a version, and their versions, counted, paged, tallied and listed by release, NuGet's by the versions their filters show (#1425, #1426). Its subtests, ListOrderKeys, PackagePages, NuGetShown and TallyAndReleases, run beside Run.
- The subtests, one per concern, each on a store of its own: Blobs, ColdBlobs, BlobDeletion, ColdBlobDeletion, BlobTiersSeparate, Replicas, ReplicaTiersSeparate, Repos, Items, ItemCreate, ColonPaths, ItemProperties, RepositoryRoot, ItemStats, ItemSearch, ItemsByFullPath (a folder's descendants in full path byte order, the storage file list's, #1409), LongPropertyValues, LongPropertyKeys, Trash, TrashByPath (the trash can's tree in path byte order, #1409), Packages, GitLFSLocks, BowerRegistrations, UploadDigests, RemoteCache, RemoteCacheFences, RemoteCacheAtomic, RemoteCacheEvict, RemoteCacheConcurrent, RemoteCacheUsage, RemoteSmartState, ArchivedItems, Builds, BuildRuns, BuildDeletes, BuildRename, BuildPromotions, BuildFiles (with DependencyPage, a checksum's dependencies a keyset page at a time in FindDependencies' order, #1409), BuildRetention and BuildReports.
- LongText, the random text the long property cases store, which the server's long-property test shares.
Invariants ¶
- The subtests keep the names they had in the metadata store's contract, which calls Run where it ran Blobs, so its runs list the same subtests.
- The subtests use only the artifacts accessors. RemoteLayoutFences is not one of them: a layout document lives in the platform's config store, so the metadata store's contract registers it beside Run.
References ¶
- Decision 0004: docs/research/decisions/0004-storage-sql-metadata-and-blobs.md.
- Decision 0007: docs/research/decisions/0007-remote-repositories.md (the remote cache and its fences).
- Decision 0010: docs/research/decisions/0010-retention-trash-and-gc.md.
- Decision 0012: docs/research/decisions/0012-search-and-aql.md.
- Decision 0014: docs/research/decisions/0014-build-info.md.
- Decision 0015: docs/research/decisions/0015-testing-and-acceptance.md (one contract suite per store port).
- Decision 0018: docs/research/decisions/0018-package-index.md.
- Decision 0024: docs/research/decisions/0024-cold-storage-tier.md.
- Decision 0028: docs/research/decisions/0028-blob-mirroring.md.
- Decision 0044: docs/research/decisions/0044-modular-monolith-migration.md ("Persistence": contract suites; "Names the migration introduces", which lists Factory and Run).
- Target layout: docs/research/architecture-options/5-modular-monolith.md, lines 612 and 613 (the artifacts storetest adapter), line 847 (store contract suites per module, run by its adapters) and line 1057 (the metadata store's contract split per owner).
- Plan: docs/implementation/plan.md#p2-stores and #p9d-modular-monolith-migration, epic STO (https://github.com/weaveplatform/artifactweave/issues/939).
- https://github.com/weaveplatform/artifactweave/issues/1061
- https://github.com/weaveplatform/artifactweave/issues/1062
Status ¶
Implemented P2: the content, blob and archived-item cases, in the metadata store's contract (pull request 3). Later phases added the replica cases (pull request 30), the build cases (pull request 193), the property key cases (pull request 348), the remote cache cases (pull request 646), the Git LFS lock cases (pull request 849) and the Bower registration cases (pull request 912). Moved here in P9d, which added Factory and Run. RunDockerPages came with the Docker page reader (#1402), and RunRepoPages with the repository window (#1408).
Testing ¶
The package is the suite. The module's adapters run Run in adapters/inmem's TestUnitContract and in adapters/sql's TestAccContract (SQLite in memory and in a file), and the metadata store's TestUnitContract, TestAccContractFile, TestAccContractMemory and TestAccContract (PostgreSQL) run it under the same subtest names. The adapters run RunDockerPages in adapters/inmem's TestUnitDockerPagesContract and adapters/sql's TestAccDockerPagesContract, RunVersionNames in adapters/inmem's TestUnitVersionNamesContract and adapters/sql's TestAccVersionNamesContract, and RunPackagePages in adapters/inmem's TestUnitPackagePagesContract and adapters/sql's TestAccPackagePagesContract (each SQLite in memory and in a file, and PostgreSQL).
Index ¶
- func LongText(n int) string
- func Run(t *testing.T, newStore Factory)
- func RunDockerPages(t *testing.T, newStore Factory)
- func RunNpmSearch(t *testing.T, newStore Factory)
- func RunNuGetSearch(t *testing.T, newStore Factory)
- func RunPackagePages(t *testing.T, newStore Factory)
- func RunRepoPages(t *testing.T, newStore Factory)
- func RunVersionNames(t *testing.T, newStore Factory)
- type Factory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LongText ¶
LongText returns n characters of random text, the same on every call. Half the characters are two or three bytes of UTF-8 and each is one UTF-16 code unit; all sort above "!" and none is an AQL wildcard.
func Run ¶
Run runs the artifacts contract on stores from newStore, one subtest per concern, each on a store of its own: Blobs, ColdBlobs, BlobDeletion, ColdBlobDeletion, BlobTiersSeparate, Replicas, ReplicaTiersSeparate, Repos, Items, ItemCreate, ColonPaths, ItemProperties, RepositoryRoot, ItemStats, ItemSearch, ItemsByFullPath, LongPropertyValues, LongPropertyKeys, Trash, TrashByPath, Packages, GitLFSLocks, BowerRegistrations, UploadDigests, RemoteCache, RemoteCacheFences, RemoteCacheAtomic, RemoteCacheEvict, RemoteCacheConcurrent, RemoteCacheUsage, RemoteSmartState, ArchivedItems, Builds, BuildRuns, BuildDeletes, BuildRename, BuildPromotions, BuildFiles, BuildRetention and BuildReports.
func RunDockerPages ¶
RunDockerPages runs the image layout page reader's contract (port.DockerPageStore). Each adapter's tests call it next to Run; the SQL adapter's on PostgreSQL too, since each engine folds and orders in its own way.
func RunNpmSearch ¶
RunNpmSearch runs the contract of PackageStore.SearchNpm on stores from newStore: which packages a search's terms make candidates (port/npm_search.go), in name order, a page at a time, each with all its versions. Each adapter's tests call it beside Run.
func RunNuGetSearch ¶
RunNuGetSearch runs the contract of PackageStore.SearchNuGet on stores from newStore: the candidates npm's search returns (RunNpmSearch), only those whose names start with a prefix when the search gives one. Each adapter's tests call it beside Run.
func RunPackagePages ¶
RunPackagePages runs the contracts of the store's list paging (port.PackagePages, and PackageVersionNames' CountVersions and VersionNamesAt) on stores from newStore: Puppet's, Chef's and Ansible's versions, written in random order, read back newest first in their lists' order, and a repository's packages and versions are counted, paged, tallied and listed by release as those lists, npm's and NuGet's searches and NuGet's V2 feeds count them. The adapters' tests call it beside Run.
func RunRepoPages ¶
RunRepoPages runs the contract of RepoStore.Page, the window Get Repositories answers (#1408). Each adapter's tests call it next to Run; the SQL adapter's on PostgreSQL too, since each engine plans the filter, the order and the window in its own way.
func RunVersionNames ¶
RunVersionNames runs the contract of PackageVersionNames on a store from newStore: a package's version names come in exactly the order Versions returns its versions, whatever order they were written in, follow a version written or deleted later, and are a package's own. The adapters' tests call it beside Run.