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

fix: When changing the ontologies refresh the cache completely (DEV-4362) #3468

Merged
merged 24 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
73d03e7
inline OntologyTriplestoreHelpers trait
seakayone Jan 21, 2025
a881072
inline OntologyCacheHelpers trait
seakayone Jan 21, 2025
b98ca11
replace with ZIO.unit
seakayone Jan 21, 2025
f60c558
Replace cacheUpdatedOntology(SmartIri,ReadOntologyV2) with refreshing…
seakayone Jan 21, 2025
1b7f98e
replace OntologyCache.deleteOntology with refreshing from DB
seakayone Jan 21, 2025
0d786d0
replace OntologyCache.cacheUpdatedOntologyWithClass with refreshing f…
seakayone Jan 21, 2025
43598d7
replace OntologyCache.cacheUpdatedOntologyWithClass with refreshing f…
seakayone Jan 21, 2025
7fb2a43
cleanup
seakayone Jan 22, 2025
b0e6416
improve logging
seakayone Jan 22, 2025
68cc849
cleanup
seakayone Jan 22, 2025
09256f5
simplify
seakayone Jan 22, 2025
728c5cc
Merge branch 'main' into fix/ontology-cache
seakayone Jan 22, 2025
08e90f7
fixup! simplify
seakayone Jan 22, 2025
78050e1
fmt
seakayone Jan 22, 2025
4f0cee9
Merge branch 'main' into fix/ontology-cache
seakayone Jan 23, 2025
9dded3e
Merge branch 'main' into fix/ontology-cache
seakayone Jan 24, 2025
d3346a4
Merge branch 'main' into fix/ontology-cache
seakayone Jan 27, 2025
2d9e189
Merge branch 'main' into fix/ontology-cache
seakayone Jan 27, 2025
cdef837
Merge branch 'main' into fix/ontology-cache
seakayone Jan 27, 2025
43782b5
Merge branch 'main' into fix/ontology-cache
seakayone Jan 27, 2025
0d158bd
Merge branch 'main' into fix/ontology-cache
seakayone Jan 28, 2025
c4686c6
Merge branch 'main' into fix/ontology-cache
seakayone Jan 28, 2025
9600f67
Merge branch 'main' into fix/ontology-cache
seakayone Jan 28, 2025
5ea5f1a
fmt
seakayone Jan 28, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ import org.knora.webapi.responders.admin.*
import org.knora.webapi.responders.v2.*
import org.knora.webapi.responders.v2.ontology.CardinalityHandler
import org.knora.webapi.responders.v2.ontology.OntologyCacheHelpers
import org.knora.webapi.responders.v2.ontology.OntologyCacheHelpersLive
import org.knora.webapi.responders.v2.ontology.OntologyTriplestoreHelpers
import org.knora.webapi.responders.v2.ontology.OntologyTriplestoreHelpersLive
import org.knora.webapi.routing.*
import org.knora.webapi.slice.admin.AdminModule
import org.knora.webapi.slice.admin.api.*
Expand Down Expand Up @@ -199,10 +197,10 @@ object LayersTest {
MessageRelayLive.layer,
OntologyApiModule.layer,
OntologyCacheLive.layer,
OntologyCacheHelpersLive.layer,
OntologyCacheHelpers.layer,
OntologyRepoLive.layer,
OntologyServiceLive.layer,
OntologyTriplestoreHelpersLive.layer,
OntologyTriplestoreHelpers.layer,
PermissionUtilADMLive.layer,
PermissionsResponder.layer,
PredicateObjectMapper.layer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ trait TestStartupUtils extends LazyLogging {
tss <- ZIO.service[TriplestoreService]
_ <- tss.resetTripleStoreContent(rdfDataObjects).timeout(480.seconds)
_ <- ZIO.logInfo("... loading test data done.")
_ <- ZIO.serviceWithZIO[OntologyCache](_.loadOntologies()).orDie
_ <- ZIO.serviceWithZIO[OntologyCache](_.refreshCache()).orDie
} yield ()

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import pekko.actor.Status
import pekko.testkit.ImplicitSender

/**
* Tests that the [[OntologyCache.loadOntologies]] method does not load invalid data into the cache.
* Tests that the [[OntologyCache.refreshCache]] method does not load invalid data into the cache.
*/
class LoadOntologiesSpec extends CoreSpec with ImplicitSender {
private val INVALID_ONTO_NAME = "http://www.knora.org/ontology/invalid"
Expand All @@ -41,7 +41,7 @@ class LoadOntologiesSpec extends CoreSpec with ImplicitSender {
)

UnsafeZioRun
.run(ZIO.serviceWithZIO[OntologyCache](_.loadOntologies()))
.run(ZIO.serviceWithZIO[OntologyCache](_.refreshCache()))
.toEither
.map(_ => SuccessResponseV2("OK"))
.left
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class OntologyResponderV2Spec extends CoreSpec with ImplicitSender {
assert(!cachedMetadataResponse.ontologies.exists(_.ontologyIri == fooIri.get.toSmartIri))

// Reload the ontologies from the triplestore and check again.
UnsafeZioRun.runOrThrow(ZIO.serviceWithZIO[OntologyCache](_.loadOntologies()))
UnsafeZioRun.runOrThrow(ZIO.serviceWithZIO[OntologyCache](_.refreshCache()))

appActor ! OntologyMetadataGetByProjectRequestV2()

Expand Down Expand Up @@ -793,7 +793,7 @@ class OntologyResponderV2Spec extends CoreSpec with ImplicitSender {

// Reload the ontology cache and see if we get the same result.
UnsafeZioRun.runOrThrow(
ZIO.serviceWithZIO[OntologyCache](_.loadOntologies()),
ZIO.serviceWithZIO[OntologyCache](_.refreshCache()),
)

appActor ! PropertiesGetRequestV2(
Expand Down Expand Up @@ -897,7 +897,7 @@ class OntologyResponderV2Spec extends CoreSpec with ImplicitSender {

// Reload the ontology cache and see if we get the same result.
UnsafeZioRun.runOrThrow(
ZIO.serviceWithZIO[OntologyCache](_.loadOntologies()),
ZIO.serviceWithZIO[OntologyCache](_.refreshCache()),
)

appActor ! PropertiesGetRequestV2(
Expand Down Expand Up @@ -1994,8 +1994,8 @@ class OntologyResponderV2Spec extends CoreSpec with ImplicitSender {

val newObjects = Seq(
StringLiteralV2.from("has name", Some("en")),
StringLiteralV2.from("a nom", Some("fr")),
StringLiteralV2.from("hat Namen", Some("de")),
StringLiteralV2.from("a nom", Some("fr")),
)

appActor ! ChangePropertyLabelsOrCommentsRequestV2(
Expand Down Expand Up @@ -2029,8 +2029,8 @@ class OntologyResponderV2Spec extends CoreSpec with ImplicitSender {

val newObjects = Seq(
StringLiteralV2.from("has name", Some("en")),
StringLiteralV2.from("a nom", Some("fr")),
StringLiteralV2.from("hat Namen", Some("de")),
StringLiteralV2.from("a nom", Some("fr")),
)

appActor ! ChangePropertyLabelsOrCommentsRequestV2(
Expand Down Expand Up @@ -2092,11 +2092,11 @@ class OntologyResponderV2Spec extends CoreSpec with ImplicitSender {

val newObjects = Seq(
StringLiteralV2.from("The name of a Thing", Some("en")),
StringLiteralV2.from("Der Name eines Dinges", Some("de")),
StringLiteralV2.from(
"Le nom d\\'une chose",
Some("fr"),
), // This is SPARQL-escaped as it would be if taken from a JSON-LD request.
StringLiteralV2.from("Der Name eines Dinges", Some("de")),
)

// Make an unescaped copy of the new comments, because this is how we will receive them in the API response.
Expand Down Expand Up @@ -2135,11 +2135,11 @@ class OntologyResponderV2Spec extends CoreSpec with ImplicitSender {

val newObjects = Seq(
StringLiteralV2.from("The name of a Thing", Some("en")),
StringLiteralV2.from("Der Name eines Dinges", Some("de")),
StringLiteralV2.from(
"Le nom d\\'une chose",
Some("fr"),
), // This is SPARQL-escaped as it would be if taken from a JSON-LD request.
StringLiteralV2.from("Der Name eines Dinges", Some("de")),
)

// Make an unescaped copy of the new comments, because this is how we will receive them in the API response.
Expand Down Expand Up @@ -3736,7 +3736,7 @@ class OntologyResponderV2Spec extends CoreSpec with ImplicitSender {

// Reload the ontology cache and see if we get the same result.
UnsafeZioRun.runOrThrow(
ZIO.serviceWithZIO[OntologyCache](_.loadOntologies()),
ZIO.serviceWithZIO[OntologyCache](_.refreshCache()),
)

appActor ! linkPropGetRequest
Expand Down
Loading
Loading