From 4deeca9ef2a7f32d1e5030c224832d63525dba56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Mon, 20 May 2024 12:19:36 +0200 Subject: [PATCH] fix --- .../apigateway/http/GatewayResourceTest.java | 2 + .../handlers/ProduceConsumeHandlerTest.java | 2 + .../langstream/api/runtime/DeployContext.java | 66 ++++++++++++------- .../impl/deploy/ApplicationDeployerTest.java | 7 +- .../KubernetesClusterRuntimeDockerTest.java | 2 +- .../k8s/KubernetesClusterRuntimeTest.java | 2 +- .../application/ApplicationSetupRunner.java | 2 + .../runtime/deployer/RuntimeDeployer.java | 1 + .../tester/LocalApplicationRunner.java | 6 +- .../application/ApplicationService.java | 7 +- 10 files changed, 59 insertions(+), 38 deletions(-) diff --git a/langstream-api-gateway/src/test/java/ai/langstream/apigateway/http/GatewayResourceTest.java b/langstream-api-gateway/src/test/java/ai/langstream/apigateway/http/GatewayResourceTest.java index 8e7db231b..9781a168e 100644 --- a/langstream-api-gateway/src/test/java/ai/langstream/apigateway/http/GatewayResourceTest.java +++ b/langstream-api-gateway/src/test/java/ai/langstream/apigateway/http/GatewayResourceTest.java @@ -30,6 +30,7 @@ import ai.langstream.api.runner.topics.TopicConsumer; import ai.langstream.api.runner.topics.TopicProducer; import ai.langstream.api.runtime.ClusterRuntimeRegistry; +import ai.langstream.api.runtime.DeployContext; import ai.langstream.api.runtime.PluginsRegistry; import ai.langstream.api.storage.ApplicationStore; import ai.langstream.apigateway.api.ConsumePushMessage; @@ -658,6 +659,7 @@ private void prepareTopicsForTest(String... topic) throws Exception { .pluginsRegistry(new PluginsRegistry()) .registry(new ClusterRuntimeRegistry()) .topicConnectionsRuntimeRegistry(topicConnectionsRuntimeRegistry) + .deployContext(DeployContext.NO_DEPLOY_CONTEXT) .build(); final StreamingCluster streamingCluster = getStreamingCluster(); topicConnectionsRuntimeRegistry diff --git a/langstream-api-gateway/src/test/java/ai/langstream/apigateway/websocket/handlers/ProduceConsumeHandlerTest.java b/langstream-api-gateway/src/test/java/ai/langstream/apigateway/websocket/handlers/ProduceConsumeHandlerTest.java index bcccad9da..1a8693ab7 100644 --- a/langstream-api-gateway/src/test/java/ai/langstream/apigateway/websocket/handlers/ProduceConsumeHandlerTest.java +++ b/langstream-api-gateway/src/test/java/ai/langstream/apigateway/websocket/handlers/ProduceConsumeHandlerTest.java @@ -35,6 +35,7 @@ import ai.langstream.api.model.StreamingCluster; import ai.langstream.api.runner.topics.TopicConnectionsRuntimeRegistry; import ai.langstream.api.runtime.ClusterRuntimeRegistry; +import ai.langstream.api.runtime.DeployContext; import ai.langstream.api.runtime.PluginsRegistry; import ai.langstream.api.storage.ApplicationStore; import ai.langstream.apigateway.api.ConsumePushMessage; @@ -267,6 +268,7 @@ private void prepareTopicsForTest(String... topic) throws Exception { .pluginsRegistry(new PluginsRegistry()) .registry(new ClusterRuntimeRegistry()) .topicConnectionsRuntimeRegistry(topicConnectionsRuntimeRegistry) + .deployContext(DeployContext.NO_DEPLOY_CONTEXT) .build(); final StreamingCluster streamingCluster = getStreamingCluster(); topicConnectionsRuntimeRegistry diff --git a/langstream-api/src/main/java/ai/langstream/api/runtime/DeployContext.java b/langstream-api/src/main/java/ai/langstream/api/runtime/DeployContext.java index 791e64f6c..81e57ba48 100644 --- a/langstream-api/src/main/java/ai/langstream/api/runtime/DeployContext.java +++ b/langstream-api/src/main/java/ai/langstream/api/runtime/DeployContext.java @@ -15,40 +15,62 @@ */ package ai.langstream.api.runtime; -import ai.langstream.api.runner.assets.AssetManagerRegistry; import ai.langstream.api.webservice.application.ApplicationCodeInfo; public interface DeployContext extends AutoCloseable { - default ApplicationCodeInfo getApplicationCodeInfo( - String tenant, String applicationId, String codeArchiveId) { - throw new UnsupportedOperationException(); - } + DeployContext NO_DEPLOY_CONTEXT = new NoOpDeployContext(); - default AssetManagerRegistry getAssetManagerRegistry() { - throw new UnsupportedOperationException(); - } + class NoOpDeployContext implements DeployContext { - default boolean isAutoUpgradeRuntimeImage() { - return false; - } + @Override + public ApplicationCodeInfo getApplicationCodeInfo( + String tenant, String applicationId, String codeArchiveId) { + return null; + } - default boolean isAutoUpgradeRuntimeImagePullPolicy() { - return false; - } + @Override + public boolean isAutoUpgradeRuntimeImage() { + return false; + } - default boolean isAutoUpgradeAgentResources() { - return false; - } + @Override + public boolean isAutoUpgradeRuntimeImagePullPolicy() { + return false; + } - default boolean isAutoUpgradeAgentPodTemplate() { - return false; - } + @Override + public boolean isAutoUpgradeAgentResources() { + return false; + } + + @Override + public boolean isAutoUpgradeAgentPodTemplate() { + return false; + } - default long getApplicationSeed() { - throw new UnsupportedOperationException(); + @Override + public long getApplicationSeed() { + return -1L; + } + + @Override + public void close() {} } + ApplicationCodeInfo getApplicationCodeInfo( + String tenant, String applicationId, String codeArchiveId); + + boolean isAutoUpgradeRuntimeImage(); + + boolean isAutoUpgradeRuntimeImagePullPolicy(); + + boolean isAutoUpgradeAgentResources(); + + boolean isAutoUpgradeAgentPodTemplate(); + + long getApplicationSeed(); + @Override default void close() {} } diff --git a/langstream-core/src/test/java/ai/langstream/impl/deploy/ApplicationDeployerTest.java b/langstream-core/src/test/java/ai/langstream/impl/deploy/ApplicationDeployerTest.java index 940fe7636..e90c9136e 100644 --- a/langstream-core/src/test/java/ai/langstream/impl/deploy/ApplicationDeployerTest.java +++ b/langstream-core/src/test/java/ai/langstream/impl/deploy/ApplicationDeployerTest.java @@ -25,11 +25,7 @@ import ai.langstream.api.runner.topics.TopicConnectionsRuntime; import ai.langstream.api.runner.topics.TopicConnectionsRuntimeAndLoader; import ai.langstream.api.runner.topics.TopicConnectionsRuntimeRegistry; -import ai.langstream.api.runtime.ClusterRuntimeRegistry; -import ai.langstream.api.runtime.ComputeClusterRuntime; -import ai.langstream.api.runtime.ExecutionPlan; -import ai.langstream.api.runtime.PluginsRegistry; -import ai.langstream.api.runtime.StreamingClusterRuntime; +import ai.langstream.api.runtime.*; import ai.langstream.impl.noop.NoOpComputeClusterRuntimeProvider; import ai.langstream.impl.parser.ModelBuilder; import java.util.Map; @@ -82,6 +78,7 @@ void testDeploy() throws Exception { ApplicationDeployer.builder() .pluginsRegistry(new PluginsRegistry()) .registry(registry) + .deployContext(DeployContext.NO_DEPLOY_CONTEXT) .topicConnectionsRuntimeRegistry( new TopicConnectionsRuntimeRegistry() { @Override diff --git a/langstream-k8s-runtime/langstream-k8s-runtime-core/src/test/java/ai/langstream/runtime/impl/k8s/KubernetesClusterRuntimeDockerTest.java b/langstream-k8s-runtime/langstream-k8s-runtime-core/src/test/java/ai/langstream/runtime/impl/k8s/KubernetesClusterRuntimeDockerTest.java index c15e683a6..a5ef89e92 100644 --- a/langstream-k8s-runtime/langstream-k8s-runtime-core/src/test/java/ai/langstream/runtime/impl/k8s/KubernetesClusterRuntimeDockerTest.java +++ b/langstream-k8s-runtime/langstream-k8s-runtime-core/src/test/java/ai/langstream/runtime/impl/k8s/KubernetesClusterRuntimeDockerTest.java @@ -309,7 +309,7 @@ public void testCodeArchiveId() throws Exception { ApplicationDeployer deployer = getDeployer( - new DeployContext() { + new DeployContext.NoOpDeployContext() { @Override public ApplicationCodeInfo getApplicationCodeInfo( String tenant, String applicationId, String codeArchiveId) { diff --git a/langstream-k8s-runtime/langstream-k8s-runtime-core/src/test/java/ai/langstream/runtime/impl/k8s/KubernetesClusterRuntimeTest.java b/langstream-k8s-runtime/langstream-k8s-runtime-core/src/test/java/ai/langstream/runtime/impl/k8s/KubernetesClusterRuntimeTest.java index 49bb6f58a..56625872e 100644 --- a/langstream-k8s-runtime/langstream-k8s-runtime-core/src/test/java/ai/langstream/runtime/impl/k8s/KubernetesClusterRuntimeTest.java +++ b/langstream-k8s-runtime/langstream-k8s-runtime-core/src/test/java/ai/langstream/runtime/impl/k8s/KubernetesClusterRuntimeTest.java @@ -116,7 +116,7 @@ private void assertCode( String oldCode, boolean expectKeep) { final DeployContext deployContext = - new DeployContext() { + new DeployContext.NoOpDeployContext() { @Override public ApplicationCodeInfo getApplicationCodeInfo( String tenant, String applicationId, String codeArchiveId) { diff --git a/langstream-runtime/langstream-runtime-impl/src/main/java/ai/langstream/runtime/application/ApplicationSetupRunner.java b/langstream-runtime/langstream-runtime-impl/src/main/java/ai/langstream/runtime/application/ApplicationSetupRunner.java index bfc55d9a4..88209f25d 100644 --- a/langstream-runtime/langstream-runtime-impl/src/main/java/ai/langstream/runtime/application/ApplicationSetupRunner.java +++ b/langstream-runtime/langstream-runtime-impl/src/main/java/ai/langstream/runtime/application/ApplicationSetupRunner.java @@ -22,6 +22,7 @@ import ai.langstream.api.runner.assets.AssetManagerRegistry; import ai.langstream.api.runner.topics.TopicConnectionsRuntimeRegistry; import ai.langstream.api.runtime.ClusterRuntimeRegistry; +import ai.langstream.api.runtime.DeployContext; import ai.langstream.api.runtime.ExecutionPlan; import ai.langstream.api.runtime.PluginsRegistry; import ai.langstream.impl.deploy.ApplicationDeployer; @@ -124,6 +125,7 @@ private ApplicationDeployer buildDeployer( .pluginsRegistry(new PluginsRegistry()) .topicConnectionsRuntimeRegistry(topicConnectionsRuntimeRegistry) .assetManagerRegistry(assetManagerRegistry) + .deployContext(DeployContext.NO_DEPLOY_CONTEXT) .build(); } diff --git a/langstream-runtime/langstream-runtime-impl/src/main/java/ai/langstream/runtime/deployer/RuntimeDeployer.java b/langstream-runtime/langstream-runtime-impl/src/main/java/ai/langstream/runtime/deployer/RuntimeDeployer.java index acce8b518..2aac052d7 100644 --- a/langstream-runtime/langstream-runtime-impl/src/main/java/ai/langstream/runtime/deployer/RuntimeDeployer.java +++ b/langstream-runtime/langstream-runtime-impl/src/main/java/ai/langstream/runtime/deployer/RuntimeDeployer.java @@ -110,6 +110,7 @@ public void delete( ApplicationDeployer.builder() .registry(new ClusterRuntimeRegistry(clusterRuntimeConfiguration)) .pluginsRegistry(new PluginsRegistry()) + .deployContext(DeployContext.NO_DEPLOY_CONTEXT) .build()) { log.info("Deleting application {}", applicationId); diff --git a/langstream-runtime/langstream-runtime-tester/src/main/java/ai/langstream/runtime/tester/LocalApplicationRunner.java b/langstream-runtime/langstream-runtime-tester/src/main/java/ai/langstream/runtime/tester/LocalApplicationRunner.java index 6e5ff0ec7..2b13230b9 100644 --- a/langstream-runtime/langstream-runtime-tester/src/main/java/ai/langstream/runtime/tester/LocalApplicationRunner.java +++ b/langstream-runtime/langstream-runtime-tester/src/main/java/ai/langstream/runtime/tester/LocalApplicationRunner.java @@ -19,10 +19,7 @@ import ai.langstream.api.runner.assets.AssetManagerRegistry; import ai.langstream.api.runner.code.MetricsReporter; import ai.langstream.api.runner.topics.TopicConnectionsRuntimeRegistry; -import ai.langstream.api.runtime.AgentNode; -import ai.langstream.api.runtime.ClusterRuntimeRegistry; -import ai.langstream.api.runtime.ExecutionPlan; -import ai.langstream.api.runtime.PluginsRegistry; +import ai.langstream.api.runtime.*; import ai.langstream.deployer.k8s.agents.AgentResourcesFactory; import ai.langstream.impl.deploy.ApplicationDeployer; import ai.langstream.impl.nar.NarFileHandler; @@ -101,6 +98,7 @@ public LocalApplicationRunner( .pluginsRegistry(new PluginsRegistry()) .topicConnectionsRuntimeRegistry(topicConnectionsRuntimeRegistry) .assetManagerRegistry(assetManagerRegistry) + .deployContext(DeployContext.NO_DEPLOY_CONTEXT) .build(); } diff --git a/langstream-webservice/src/main/java/ai/langstream/webservice/application/ApplicationService.java b/langstream-webservice/src/main/java/ai/langstream/webservice/application/ApplicationService.java index 17dfb98b1..71b9d89b0 100644 --- a/langstream-webservice/src/main/java/ai/langstream/webservice/application/ApplicationService.java +++ b/langstream-webservice/src/main/java/ai/langstream/webservice/application/ApplicationService.java @@ -23,11 +23,7 @@ import ai.langstream.api.model.StoredApplication; import ai.langstream.api.model.TopicDefinition; import ai.langstream.api.runner.topics.TopicConnectionsRuntimeRegistry; -import ai.langstream.api.runtime.AgentNode; -import ai.langstream.api.runtime.ClusterRuntimeRegistry; -import ai.langstream.api.runtime.ExecutionPlan; -import ai.langstream.api.runtime.PluginsRegistry; -import ai.langstream.api.runtime.Topic; +import ai.langstream.api.runtime.*; import ai.langstream.api.storage.ApplicationStore; import ai.langstream.api.webservice.tenant.TenantConfiguration; import ai.langstream.impl.common.DefaultAgentNode; @@ -57,6 +53,7 @@ public class ApplicationService { .registry(new ClusterRuntimeRegistry()) .pluginsRegistry(new PluginsRegistry()) .topicConnectionsRuntimeRegistry(new TopicConnectionsRuntimeRegistry()) + .deployContext(DeployContext.NO_DEPLOY_CONTEXT) .build(); private final GlobalMetadataService globalMetadataService;