Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Reorganise and extend TCK #500

Merged
merged 7 commits into from
Dec 21, 2020
Merged
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
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ lazy val `java-support-docs` = (project in file("java-support/docs"))
)

lazy val `java-support-tck` = (project in file("java-support/tck"))
.dependsOn(`java-support`, `java-shopping-cart`, `java-eventsourced-shopping-cart`)
.dependsOn(`java-support`)
.enablePlugins(AkkaGrpcPlugin, AssemblyPlugin, JavaAppPackaging, DockerPlugin, AutomateHeaderPlugin, NoPublish)
.settings(
name := "cloudstate-java-tck",
Expand Down Expand Up @@ -782,7 +782,7 @@ lazy val `testkit` = (project in file("testkit"))
lazy val `tck` = (project in file("tck"))
.enablePlugins(AkkaGrpcPlugin, JavaAppPackaging, DockerPlugin, NoPublish)
.configs(IntegrationTest)
.dependsOn(`akka-client`, testkit)
.dependsOn(testkit)
.settings(
Defaults.itSettings,
common,
Expand All @@ -798,11 +798,11 @@ lazy val `tck` = (project in file("tck"))
),
PB.protoSources in Compile ++= {
val baseDir = (baseDirectory in ThisBuild).value / "protocols"
Seq(baseDir / "protocol", baseDir / "tck")
Seq(baseDir / "protocol", baseDir / "frontend", baseDir / "tck")
},
dockerSettings,
Compile / bashScriptDefines / mainClass := Some("org.scalatest.run"),
bashScriptExtraDefines += "addApp io.cloudstate.tck.ConfiguredCloudStateTCK",
bashScriptExtraDefines += "addApp io.cloudstate.tck.ConfiguredCloudstateTCK",
headerSettings(IntegrationTest),
automateHeaderSettings(IntegrationTest),
fork in IntegrationTest := true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@

package io.cloudstate.javasupport.tck;

import com.example.valueentity.shoppingcart.Shoppingcart;
import io.cloudstate.javasupport.CloudState;
import io.cloudstate.javasupport.PassivationStrategy;
import io.cloudstate.javasupport.crdt.CrdtEntityOptions;
import io.cloudstate.javasupport.entity.EntityOptions;
import io.cloudstate.javasupport.tck.model.passivation.PassivationTckModelEntity;
import io.cloudstate.javasupport.eventsourced.EventSourcedEntityOptions;
import io.cloudstate.javasupport.tck.model.crdt.CrdtConfiguredEntity;
import io.cloudstate.javasupport.tck.model.eventlogeventing.EventLogSubscriber;
import io.cloudstate.javasupport.tck.model.eventsourced.EventSourcedConfiguredEntity;
import io.cloudstate.javasupport.tck.model.valuebased.ValueEntityConfiguredEntity;
import io.cloudstate.javasupport.tck.model.valuebased.ValueEntityTckModelEntity;
import io.cloudstate.javasupport.tck.model.valuebased.ValueEntityTwoEntity;
import io.cloudstate.javasupport.tck.model.action.ActionTckModelBehavior;
Expand All @@ -30,12 +33,10 @@
import io.cloudstate.javasupport.tck.model.crdt.CrdtTwoEntity;
import io.cloudstate.javasupport.tck.model.eventsourced.EventSourcedTckModelEntity;
import io.cloudstate.javasupport.tck.model.eventsourced.EventSourcedTwoEntity;
import io.cloudstate.samples.shoppingcart.ShoppingCartEntity;
import io.cloudstate.tck.model.Action;
import io.cloudstate.tck.model.Crdt;
import io.cloudstate.tck.model.Eventlogeventing;
import io.cloudstate.tck.model.Eventsourced;
import io.cloudstate.tck.model.entitypassivation.Entitypassivation;
import io.cloudstate.tck.model.valueentity.Valueentity;

import java.time.Duration;
Expand All @@ -59,21 +60,32 @@ public static final void main(String[] args) throws Exception {
ValueEntityTwoEntity.class,
Valueentity.getDescriptor().findServiceByName("ValueEntityTwo"))
.registerEntity(
ShoppingCartEntity.class,
Shoppingcart.getDescriptor().findServiceByName("ShoppingCart"),
com.example.valueentity.shoppingcart.persistence.Domain.getDescriptor())
ValueEntityConfiguredEntity.class,
Valueentity.getDescriptor().findServiceByName("ValueEntityConfigured"),
EntityOptions.defaults() // required timeout of 100 millis for TCK tests
.withPassivationStrategy(PassivationStrategy.timeout(Duration.ofMillis(100))))
.registerCrdtEntity(
CrdtTckModelEntity.class,
Crdt.getDescriptor().findServiceByName("CrdtTckModel"),
Crdt.getDescriptor())
.registerCrdtEntity(CrdtTwoEntity.class, Crdt.getDescriptor().findServiceByName("CrdtTwo"))
.registerCrdtEntity(
CrdtConfiguredEntity.class,
Crdt.getDescriptor().findServiceByName("CrdtConfigured"),
CrdtEntityOptions.defaults() // required timeout of 100 millis for TCK tests
.withPassivationStrategy(PassivationStrategy.timeout(Duration.ofMillis(100))))
.registerEventSourcedEntity(
EventSourcedTckModelEntity.class,
Eventsourced.getDescriptor().findServiceByName("EventSourcedTckModel"),
Eventsourced.getDescriptor())
.registerEventSourcedEntity(
EventSourcedTwoEntity.class,
Eventsourced.getDescriptor().findServiceByName("EventSourcedTwo"))
.registerEventSourcedEntity(
EventSourcedConfiguredEntity.class,
Eventsourced.getDescriptor().findServiceByName("EventSourcedConfigured"),
EventSourcedEntityOptions.defaults() // required timeout of 100 millis for TCK tests
.withPassivationStrategy(PassivationStrategy.timeout(Duration.ofMillis(100))))
.registerAction(
new EventLogSubscriber(),
Eventlogeventing.getDescriptor().findServiceByName("EventLogSubscriberModel"))
Expand All @@ -85,18 +97,6 @@ public static final void main(String[] args) throws Exception {
io.cloudstate.javasupport.tck.model.eventlogeventing.EventSourcedEntityTwo.class,
Eventlogeventing.getDescriptor().findServiceByName("EventSourcedEntityTwo"),
Eventlogeventing.getDescriptor())
.registerEventSourcedEntity(
io.cloudstate.samples.eventsourced.shoppingcart.ShoppingCartEntity.class,
com.example.shoppingcart.Shoppingcart.getDescriptor().findServiceByName("ShoppingCart"),
com.example.shoppingcart.persistence.Domain.getDescriptor())
.registerEntity(
PassivationTckModelEntity.class,
Entitypassivation.getDescriptor().findServiceByName("PassivationTckModel"),
EntityOptions.defaults()
.withPassivationStrategy(
PassivationStrategy.timeout(
Duration.ofSeconds(2))), // 2 seconds for timeout passivation testing!
Entitypassivation.getDescriptor())
.start()
.toCompletableFuture()
.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public ActionTwoBehavior() {}

@CallHandler
public Response call(OtherRequest request) {
return Response.newBuilder().build();
return Response.getDefaultInstance();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2019 Lightbend Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.cloudstate.javasupport.tck.model.crdt;

import io.cloudstate.javasupport.crdt.*;
import io.cloudstate.tck.model.Crdt.*;

@CrdtEntity
public class CrdtConfiguredEntity {

@CommandHandler
public Response call(Request request) {
return Response.getDefaultInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@

@CrdtEntity
public class CrdtTwoEntity {
public CrdtTwoEntity() {}
// create a CRDT to be able to call delete
public CrdtTwoEntity(GCounter counter) {}

@CommandHandler
public Response call(Request request) {
return Response.newBuilder().build();
public Response call(Request request, CommandContext context) {
for (RequestAction action : request.getActionsList()) {
if (action.hasDelete()) context.delete();
}
return Response.getDefaultInstance();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2019 Lightbend Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.cloudstate.javasupport.tck.model.eventsourced;

import io.cloudstate.javasupport.eventsourced.*;
import io.cloudstate.tck.model.Eventsourced.*;

@EventSourcedEntity(persistenceId = "event-sourced-configured")
public class EventSourcedConfiguredEntity {

@CommandHandler
public Response call(Request request) {
return Response.getDefaultInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@

@EventSourcedEntity
public class EventSourcedTwoEntity {
public EventSourcedTwoEntity() {}

@CommandHandler
public Response call(Request request) {
return Response.newBuilder().build();
return Response.getDefaultInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@
* limitations under the License.
*/

package io.cloudstate.javasupport.tck.model.passivation;
package io.cloudstate.javasupport.tck.model.valuebased;

import io.cloudstate.javasupport.entity.CommandContext;
import io.cloudstate.javasupport.entity.CommandHandler;
import io.cloudstate.javasupport.entity.Entity;
import io.cloudstate.tck.model.entitypassivation.Entitypassivation.*;
import io.cloudstate.tck.model.valueentity.Valueentity.Request;
import io.cloudstate.tck.model.valueentity.Valueentity.Response;

import java.util.Optional;

@Entity(persistenceId = "entity-passivation-tck-model")
public class PassivationTckModelEntity {

private final String state = "state";
@Entity(persistenceId = "value-entity-configured")
public class ValueEntityConfiguredEntity {

@CommandHandler
public Optional<Response> activate(Request request, CommandContext<Persisted> context) {
return Optional.of(Response.newBuilder().setMessage(state).build());
public Response call(Request request) {
return Response.getDefaultInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@

@Entity(persistenceId = "value-entity-tck-model-two")
public class ValueEntityTwoEntity {
public ValueEntityTwoEntity() {}

@CommandHandler
public Response call(Request request) {
return Response.newBuilder().build();
return Response.getDefaultInstance();
}
}
11 changes: 9 additions & 2 deletions protocols/tck/cloudstate/tck/model/action.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ syntax = "proto3";

package cloudstate.tck.model.action;

import "google/api/annotations.proto";

option java_package = "io.cloudstate.tck.model";
option go_package = "github.com/cloudstateio/go-support/tck/action;action";

Expand All @@ -41,15 +43,20 @@ option go_package = "github.com/cloudstateio/go-support/tck/action;action";
// - Forwarding and side effects must always be made to the second service `ActionTwo`.
//
service ActionTckModel {
rpc ProcessUnary(Request) returns (Response);
rpc ProcessUnary(Request) returns (Response) {
option (google.api.http) = {
post: "/tck/model/action/unary",
body: "*"
};
}
rpc ProcessStreamedIn(stream Request) returns (Response);
rpc ProcessStreamedOut(Request) returns (stream Response);
rpc ProcessStreamed(stream Request) returns (stream Response);
}

//
// The `ActionTwo` service is only for verifying forwards and side effects.
// The `Call` method is not required to do anything, and may simply return an empty `Response` message.
// The `Call` method is not required to do anything, and must return an empty `Response` message.
//
service ActionTwo {
rpc Call(OtherRequest) returns (Response);
Expand Down
21 changes: 19 additions & 2 deletions protocols/tck/cloudstate/tck/model/crdt.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ syntax = "proto3";
package cloudstate.tck.model.crdt;

import "cloudstate/entity_key.proto";
import "google/api/annotations.proto";

option java_package = "io.cloudstate.tck.model";
option go_package = "github.com/cloudstateio/go-support/tck/crdt;crdt";
Expand All @@ -42,18 +43,34 @@ option go_package = "github.com/cloudstateio/go-support/tck/crdt;crdt";
// - The `ProcessStreamed` method must stream the current state in a `Response`, on any changes.
// - A `StreamedRequest` message may have an end state, an update to apply on stream cancellation, or side effects.
service CrdtTckModel {
rpc Process(Request) returns (Response);
rpc Process(Request) returns (Response) {
option (google.api.http) = {
post: "/tck/model/crdt/{id}",
body: "*"
};
}
rpc ProcessStreamed(StreamedRequest) returns (stream Response);
}

//
// The `CrdtTwo` service is only for verifying forwards and side effects.
// The `Call` method is not required to do anything, and may simply return an empty `Response` message.
// The only action the `Call` method is expected to handle is a delete action, and otherwise
// the `Call` method is not required to do anything, and must return an empty `Response` message.
//
service CrdtTwo {
rpc Call(Request) returns (Response);
}

//
// The `CrdtConfigured` service is for testing entity configuration from the language support:
//
// - The passivation strategy must be set with a timeout of 100 millis.
// - The `Call` method is not required to do anything, and must return an empty `Response` message.
//
service CrdtConfigured {
rpc Call(Request) returns (Response);
}

//
// A `Request` message contains any actions that the entity should process.
// Actions must be processed in order. Any actions after a `Fail` may be ignored.
Expand Down
62 changes: 0 additions & 62 deletions protocols/tck/cloudstate/tck/model/entitypassivation.proto

This file was deleted.

Loading