Skip to content

Commit

Permalink
Merge branch 'master' into resolver-priority
Browse files Browse the repository at this point in the history
  • Loading branch information
olivergrabinski authored Mar 28, 2024
2 parents 2b0d888 + 6534494 commit bd08d5f
Show file tree
Hide file tree
Showing 26 changed files with 480 additions and 309 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci-delta-ship.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
- name: Clean, build Delta & Storage images
run: |
sbt -Dsbt.color=always -Dsbt.supershell=false \
clean \
app/Docker/publishLocal
- name: Start services
run: docker-compose -f tests/docker/docker-compose.yml up -d
Expand All @@ -46,4 +45,8 @@ jobs:
- name: Unit tests
run: |
sbt -Dsbt.color=always -Dsbt.supershell=false \
ship-unit-tests
"ship/testOnly *Suite"
- name: Integration tests
run: |
sbt -Dsbt.color=always -Dsbt.supershell=false \
"ship/testOnly *Spec"
22 changes: 12 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ val byteBuddyAgentVersion = "1.10.17"
val betterMonadicForVersion = "0.3.1"
val caffeineVersion = "3.1.8"
val catsEffectVersion = "3.5.4"
val catsRetryVersion = "3.1.0"
val catsRetryVersion = "3.1.3"
val catsVersion = "2.10.0"
val circeVersion = "0.14.6"
val circeOpticsVersion = "0.15.0"
val circeExtrasVersions = "0.14.3"
val classgraphVersion = "4.8.168"
val declineVersion = "2.4.1"
val distageVersion = "1.2.6"
val distageVersion = "1.2.7"
val doobieVersion = "1.0.0-RC5"
val fs2Version = "3.9.4"
val fs2Version = "3.10.1"
val googleAuthClientVersion = "1.35.0"
val handleBarsVersion = "4.4.0"
val hikariVersion = "5.1.0"
Expand All @@ -52,7 +52,7 @@ val mockitoVersion = "1.17.30"
val munitVersion = "1.0.0-M11"
val munitCatsEffectVersion = "2.0.0-M4"
val nimbusJoseJwtVersion = "9.37.3"
val postgresJdbcVersion = "42.7.2"
val postgresJdbcVersion = "42.7.3"
val pureconfigVersion = "0.17.6"
val scalaTestVersion = "3.2.18"
val scalaXmlVersion = "2.2.0"
Expand Down Expand Up @@ -729,16 +729,18 @@ lazy val delta = project
lazy val ship = project
.in(file("ship"))
.settings(
name := "nexus-ship",
moduleName := "nexus-ship"
name := "nexus-ship",
moduleName := "nexus-ship",
Test / parallelExecution := false
)
.enablePlugins(UniversalPlugin, JavaAppPackaging, JavaAgent, DockerPlugin, BuildInfoPlugin)
.settings(shared, compilation, servicePackaging, assertJavaVersion, kamonSettings, coverage, release)
.dependsOn(
sdk % "compile->compile;test->test",
blazegraphPlugin % "compile->compile",
elasticsearchPlugin % "compile->compile",
tests % "test->compile;test->test"
sdk % "compile->compile;test->test",
blazegraphPlugin % "compile->compile",
compositeViewsPlugin % "compile->compile",
elasticsearchPlugin % "compile->compile",
tests % "test->compile;test->test"
)
.settings(
libraryDependencies ++= Seq(declineEffect),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ch.epfl.bluebrain.nexus.delta.routes
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.{Directive1, Route}
import cats.effect.IO
import cats.effect.unsafe.implicits._
import cats.implicits._
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.encoder.JsonLdEncoder
Expand All @@ -12,8 +11,8 @@ import ch.epfl.bluebrain.nexus.delta.routes.OrganizationsRoutes.OrganizationInpu
import ch.epfl.bluebrain.nexus.delta.sdk.OrganizationResource
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck
import ch.epfl.bluebrain.nexus.delta.sdk.circe.CirceUnmarshalling
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._
import ch.epfl.bluebrain.nexus.delta.sdk.directives.AuthDirectives
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._
import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
import ch.epfl.bluebrain.nexus.delta.sdk.implicits._
Expand Down Expand Up @@ -59,17 +58,15 @@ final class OrganizationsRoutes(
import baseUri.prefixSegment

private def orgsSearchParams(implicit caller: Caller): Directive1[OrganizationSearchParams] =
onSuccess(aclCheck.fetchAll.unsafeToFuture()).flatMap { allAcls =>
(searchParams & parameter("label".?)).tmap { case (deprecated, rev, createdBy, updatedBy, label) =>
OrganizationSearchParams(
deprecated,
rev,
createdBy,
updatedBy,
label,
org => aclCheck.authorizeFor(org.label, orgs.read, allAcls)
)
}
(searchParams & parameter("label".?)).tmap { case (deprecated, rev, createdBy, updatedBy, label) =>
OrganizationSearchParams(
deprecated,
rev,
createdBy,
updatedBy,
label,
org => aclCheck.authorizeFor(org.label, orgs.read)
)
}

private def emitMetadata(value: IO[OrganizationResource]) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,16 @@ final class ProjectsRoutes(
implicit val paginationConfig: PaginationConfig = config.pagination

private def projectsSearchParams(implicit caller: Caller): Directive1[ProjectSearchParams] = {
onSuccess(aclCheck.fetchAll.unsafeToFuture()).flatMap { allAcls =>
(searchParams & parameter("label".?)).tmap { case (deprecated, rev, createdBy, updatedBy, label) =>
ProjectSearchParams(
None,
deprecated,
rev,
createdBy,
updatedBy,
label,
proj => aclCheck.authorizeFor(proj.ref, ReadProjects, allAcls)
)
}
(searchParams & parameter("label".?)).tmap { case (deprecated, rev, createdBy, updatedBy, label) =>
ProjectSearchParams(
None,
deprecated,
rev,
createdBy,
updatedBy,
label,
proj => aclCheck.authorizeFor(proj.ref, ReadProjects)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ch.epfl.bluebrain.nexus.delta.kernel.kamon.KamonMetricComponent
import ch.epfl.bluebrain.nexus.delta.kernel.search.Pagination.FromPagination
import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF
import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.CompositeViews._
import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.config.CompositeViewsConfig
import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.indexing.CompositeViewDef
import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.indexing.CompositeViewDef.{ActiveViewDef, DeprecatedViewDef}
import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.model.CompositeViewCommand._
Expand All @@ -27,13 +26,16 @@ import ch.epfl.bluebrain.nexus.delta.sdk.projects.{FetchContext, Projects}
import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.ResolverContextResolution
import ch.epfl.bluebrain.nexus.delta.sdk.views.IndexingRev
import ch.epfl.bluebrain.nexus.delta.sourcing._
import ch.epfl.bluebrain.nexus.delta.sourcing.config.EventLogConfig
import ch.epfl.bluebrain.nexus.delta.sourcing.model.EntityDependency.DependsOn
import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.Subject
import ch.epfl.bluebrain.nexus.delta.sourcing.model._
import ch.epfl.bluebrain.nexus.delta.sourcing.offset.Offset
import ch.epfl.bluebrain.nexus.delta.sourcing.stream.Elem
import io.circe.Json

import scala.concurrent.duration.FiniteDuration

/**
* Composite views resource lifecycle operations.
*/
Expand Down Expand Up @@ -467,7 +469,8 @@ object CompositeViews {
fetchContext: FetchContext,
contextResolution: ResolverContextResolution,
validate: ValidateCompositeView,
config: CompositeViewsConfig,
minIntervalRebuild: FiniteDuration,
eventLogConfig: EventLogConfig,
xas: Transactors,
clock: Clock[IO]
)(implicit
Expand All @@ -476,13 +479,13 @@ object CompositeViews {
): IO[CompositeViews] =
IO
.delay(
CompositeViewFieldsJsonLdSourceDecoder(uuidF, contextResolution, config.minIntervalRebuild)
CompositeViewFieldsJsonLdSourceDecoder(uuidF, contextResolution, minIntervalRebuild)
)
.map { sourceDecoder =>
new CompositeViews(
ScopedEventLog(
definition(validate, clock),
config.eventLog,
eventLogConfig,
xas
),
fetchContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class CompositeViewsPluginModule(priority: Int) extends ModuleDef {
fetchContext,
contextResolution,
validate,
config,
config.minIntervalRebuild,
config.eventLog,
xas,
clock
)(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import cats.data.NonEmptyList
import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.model.CompositeView.RebuildStrategy
import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.JsonLdContext.keywords
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.decoder.JsonLdDecoder
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.decoder.{Configuration, JsonLdDecoder}
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.decoder.JsonLdDecoderError.ParsingFailure
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.decoder.configuration.semiauto.deriveConfigJsonLdDecoder
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.decoder.semiauto.deriveDefaultJsonLdDecoder
import ch.epfl.bluebrain.nexus.delta.rdf.syntax.iriStringContextSyntax
import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri
import io.circe.syntax.EncoderOps
import io.circe.{Encoder, Json}
Expand Down Expand Up @@ -73,6 +75,12 @@ object CompositeViewFields {
}
deriveDefaultJsonLdDecoder[RebuildStrategy]
}
deriveDefaultJsonLdDecoder[CompositeViewFields]

val ctx = Configuration.default.context
.addAliasIdType("description", iri"http://schema.org/description")
.addAliasIdType("name", iri"http://schema.org/name")
implicit val config = Configuration.default.copy(context = ctx)

deriveConfigJsonLdDecoder[CompositeViewFields]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class CompositeViewsSpec
fetchContext,
ResolverContextResolution(rcr),
alwaysValidate,
config,
config.minIntervalRebuild,
config.eventLog,
xas,
clock
).accepted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class CompositeViewsRoutesSpec extends CompositeViewsRoutesFixtures {
fetchContext,
ResolverContextResolution(rcr),
alwaysValidate,
config,
config.minIntervalRebuild,
config.eventLog,
xas,
clock
).accepted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import akka.actor.ActorSystem
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.Uri.Query
import akka.testkit.TestKit
import cats.effect.IO
import cats.implicits._
import ch.epfl.bluebrain.nexus.delta.kernel.search.Pagination.FromPagination
import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.ScalaTestElasticSearchClientSetup
Expand All @@ -23,7 +24,7 @@ import ch.epfl.bluebrain.nexus.testkit.CirceLiteral
import ch.epfl.bluebrain.nexus.testkit.elasticsearch.ElasticSearchDocker
import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsEffectSpec
import io.circe.{Json, JsonObject}
import org.scalatest.DoNotDiscover
import org.scalatest.{Assertion, DoNotDiscover}
import org.scalatest.concurrent.Eventually

import scala.concurrent.duration._
Expand Down Expand Up @@ -260,23 +261,25 @@ class ElasticSearchClientSpec(override val docker: ElasticSearchDocker)
ElasticSearchAction.Update(index, "1", json"""{ "doc" : {"field2" : "value2"} }""")
)

def theCountShouldBe(count: Long): IO[Assertion] =
esClient.count(index.value).map(_ shouldEqual count)

{
for {
// Indexing and checking count
_ <- esClient.bulk(operations)
_ <- esClient.refresh(index)
original <- esClient.count(index.value)
_ = original shouldEqual 2L
_ <- esClient.bulk(operations)
_ <- esClient.refresh(index)
_ <- eventually { theCountShouldBe(2L) }
// Deleting document matching the given query
query = jobj"""{"query": {"bool": {"must": {"term": {"field1": 3} } } } }"""
_ <- esClient.deleteByQuery(query, index)
query = jobj"""{"query": {"bool": {"must": {"term": {"field1": 3} } } } }"""
_ <- esClient.deleteByQuery(query, index)
// Checking docs again
newCount <- esClient.count(index.value)
_ = newCount shouldEqual 1L
doc1 <- esClient.getSource[Json](index, "1").attemptNarrow[HttpClientError]
_ = doc1.rightValue
doc2 <- esClient.getSource[Json](index, "2").attemptNarrow[HttpClientError]
_ = doc2.leftValue.errorCode.value shouldEqual StatusCodes.NotFound
_ <- esClient.refresh(index)
_ <- eventually { theCountShouldBe(1L) }
doc1 <- esClient.getSource[Json](index, "1").attemptNarrow[HttpClientError]
_ = doc1.rightValue
doc2 <- esClient.getSource[Json](index, "2").attemptNarrow[HttpClientError]
_ = doc2.leftValue.errorCode.value shouldEqual StatusCodes.NotFound
} yield ()
}.accepted
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class SearchScopeInitializationSpec
fetchContext,
ResolverContextResolution(rcr),
alwaysValidate,
config,
config.minIntervalRebuild,
config.eventLog,
xas,
clock
).accepted
Expand Down
Loading

0 comments on commit bd08d5f

Please sign in to comment.