小编rai*_*rey的帖子

Jenkins Kubernetes 插件:声明式管道和 pod 模板继承

Jenkins Kubernetes 插件的文档指出:

与脚本化 k8s 模板不同,声明性模板不会继承自父模板。如有必要,您需要显式声明继承。 插件自述文件

不幸的是,没有示例说明如何显式声明来自构建主模板的继承。我尝试使用标签,但继承似乎被忽略了。

def parentLabel = "my-project-${UUID.randomUUID().toString()}"

pipeline {
    agent {
        kubernetes {
            label parentLabel
            yamlFile "jenkins-agent.yml"
            // a global template in the cloud configuration
            inheritFrom "docker"
        }
    }
    stages {
        // .. stages using the above agent
        stage( 'Test Container' ) {
            agent {
                kubernetes {
                    label "xcel-spring-stage-${UUID.randomUUID().toString()}"
                    inheritFrom parentLabel
                    yaml """
                    apiVersion: v1
                    kind: Pod
                    metadata:
                      namespace: build
                      labels:
                        project: x-celerate-spring-application
                    spec:
                      containers:
                        - name: spring-application
                          # defined in previous stages, skipped for …
Run Code Online (Sandbox Code Playgroud)

jenkins kubernetes

8
推荐指数
1
解决办法
3605
查看次数

Grails 3:用于集成测试的自定义应用程序类

我想自定义用于集成测试的应用程序类。根据用户指南,这应该是可能的:

Integration 注释支持可选的 applicationClass 属性,该属性可用于指定用于功能测试的应用程序类。该类必须扩展 GrailsAutoConfiguration。

(来自http://grails.github.io/grails-doc/3.0.x/guide/testing.html#integrationTesting

所以我的集成测试注释为

@Integration(applicationClass = TestApplication)
class DataServiceSpec extends Specification {
Run Code Online (Sandbox Code Playgroud)

测试应用程序类(尚未定制)如下所示:

class TestApplication extends GrailsAutoConfiguration {
}
Run Code Online (Sandbox Code Playgroud)

运行集成测试(使用 grails test-app 或 gradle integrationTest 会导致 ApplicationContextException ,其根本原因是缺少 EmbeddedServletContainerFactory 。这是一个错误,还是我错误地使用了 applicationClass 属性?这样的自定义应用程序类应该驻留在哪里?我当我将它放在集成测试源和 grails-app/init 中时,出现了同样的错误。或者是否有另一种方法可以将另一个 @Configuration 类添加到集成测试上下文中?

这是完整的堆栈跟踪:

java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:94)
    at org.springframework.test.context.DefaultTestContext.getApplicationContext(DefaultTestContext.java:72)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:212)
    at org.spockframework.spring.SpringTestContextManager.prepareTestInstance(SpringTestContextManager.java:49)
    at org.spockframework.spring.SpringInterceptor.interceptSetupMethod(SpringInterceptor.java:42)
    at org.spockframework.runtime.extension.AbstractMethodInterceptor.intercept(AbstractMethodInterceptor.java:28)
    at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:64)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:50)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) …
Run Code Online (Sandbox Code Playgroud)

grails grails-3.0

5
推荐指数
1
解决办法
1379
查看次数

Spring web socket消息传递 - 订阅和发送初始消息

使用用于 Web 套接字消息传递的 Stomp 代理中继,我可以订阅目的地/topic/mydest。这将创建一个代理订阅并接收系统中的某些内容为此代理目标触发的所有消息,当系统中发生某些事件时会发生这种情况。

我可以订阅一个 destination /app/mydest,并且@SubscribeMapping("mydest")会调用一个控制器方法,并且返回值仅作为消息在此套接字上发回。据我所知,这是此订阅将发送的唯一消息。

有没有办法将其组合在单个订阅中,即为某个/topic目的地创建一个代理订阅,触发一些直接将消息发送回订阅者的代码?

用例:当系统中发生错误时,将带有当前错误计数的消息发送到/topic/mydest。当新客户订阅时,我只想向他发送最后已知的错误计数。其他人此刻不感兴趣,因为计数没有改变。

我当前的解决方案是订阅两者/app/mydest/topic/mydest在客户端使用相同的消息处理程序。但它确实是一种逻辑订阅,并且它有点容易出错,因为客户端需要记住同时订阅两者。

我在这种情况下的问题:是否会有进一步的/app/订阅消息?有什么可以调用来触发的吗?我还能如何向订阅者发送主题的初始信息,而不向现有订阅者发送冗余消息?

根据要求,这是我的 Websocket 配置类。

@Configuration
@EnableWebSocketMessageBroker
public class WebsocketConfiguration extends AbstractWebSocketMessageBrokerConfigurer {
    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/ws").setAllowedOrigins("*").withSockJS();
    }

    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {
        registry.enableStompBrokerRelay("/queue/", "/topic/", "/exchange/");
        registry.setApplicationDestinationPrefixes("/app");
    }
}
Run Code Online (Sandbox Code Playgroud)

spring stomp spring-messaging spring-websocket

5
推荐指数
1
解决办法
3574
查看次数