|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +package org.apache.pekko.cluster |
| 19 | + |
| 20 | +import com.typesafe.config.{ Config, ConfigFactory } |
| 21 | + |
| 22 | +import org.apache.pekko.testkit.{ LongRunningTest, PekkoSpec } |
| 23 | + |
| 24 | +object MixedProtocolClusterSpec { |
| 25 | + |
| 26 | + val baseConfig: Config = |
| 27 | + ConfigFactory.parseString(""" |
| 28 | + pekko.actor.provider = "cluster" |
| 29 | + pekko.coordinated-shutdown.terminate-actor-system = on |
| 30 | +
|
| 31 | + pekko.remote.classic.netty.tcp.port = 0 |
| 32 | + pekko.remote.artery.canonical.port = 0 |
| 33 | + pekko.remote.artery.advanced.aeron.idle-cpu-level = 3 |
| 34 | + pekko.remote.accept-protocol-names = ["pekko", "akka"] |
| 35 | +
|
| 36 | + pekko.cluster.jmx.multi-mbeans-in-same-jvm = on |
| 37 | + pekko.cluster.configuration-compatibility-check.enforce-on-join = off |
| 38 | + """) |
| 39 | + |
| 40 | + val configWithPekko: Config = |
| 41 | + ConfigFactory.parseString(""" |
| 42 | + pekko.remote.protocol-name = "pekko" |
| 43 | + """).withFallback(baseConfig) |
| 44 | + |
| 45 | + val configWithAkka: Config = |
| 46 | + ConfigFactory.parseString(""" |
| 47 | + pekko.remote.protocol-name = "akka" |
| 48 | + """).withFallback(baseConfig) |
| 49 | +} |
| 50 | + |
| 51 | +class MixedProtocolClusterSpec extends PekkoSpec with ClusterTestKit { |
| 52 | + |
| 53 | + import MixedProtocolClusterSpec._ |
| 54 | + |
| 55 | + "A node using the akka protocol" must { |
| 56 | + |
| 57 | + "be allowed to join a cluster with a node using the pekko protocol" taggedAs LongRunningTest in { |
| 58 | + |
| 59 | + val clusterTestUtil = new ClusterTestUtil(system.name) |
| 60 | + // start the first node with the "pekko" protocol |
| 61 | + clusterTestUtil.newActorSystem(configWithPekko) |
| 62 | + |
| 63 | + // have a node using the "akka" protocol join |
| 64 | + val joiningNode = clusterTestUtil.newActorSystem(configWithAkka) |
| 65 | + clusterTestUtil.formCluster() |
| 66 | + |
| 67 | + try { |
| 68 | + awaitCond(clusterTestUtil.isMemberUp(joiningNode), message = "awaiting joining node to be 'Up'") |
| 69 | + } finally { |
| 70 | + clusterTestUtil.shutdownAll() |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + "allow a node using the pekko protocol to join the cluster" taggedAs LongRunningTest in { |
| 75 | + |
| 76 | + val clusterTestUtil = new ClusterTestUtil(system.name) |
| 77 | + |
| 78 | + // create the first node with the "akka" protocol |
| 79 | + clusterTestUtil.newActorSystem(configWithAkka) |
| 80 | + |
| 81 | + // have a node using the "pekko" protocol join |
| 82 | + val joiningNode = clusterTestUtil.newActorSystem(configWithPekko) |
| 83 | + clusterTestUtil.formCluster() |
| 84 | + |
| 85 | + try { |
| 86 | + awaitCond(clusterTestUtil.isMemberUp(joiningNode), message = "awaiting joining node to be 'Up'") |
| 87 | + } finally { |
| 88 | + clusterTestUtil.shutdownAll() |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | +} |
0 commit comments