diff --git a/gnes/composer/base.py b/gnes/composer/base.py index 0f491185..03d16a8e 100644 --- a/gnes/composer/base.py +++ b/gnes/composer/base.py @@ -175,8 +175,8 @@ def build_dockerswarm(all_layers: List['YamlGraph.Layer'], docker_img: str = 'gn host_in_name = '%s%d%d' % (_c['name'], _l_idx, _c_idx) break - args += ['--host_in %s' % host_in_name, - '--host_out %s' % host_out_name] + args += ['--host_in %s' % host_in_name] + # '--host_out %s' % host_out_name] cmd = '%s %s' % (YamlGraph.comp2file[c['name']], ' '.join(args)) swarm_lines['services'][c_name] = { @@ -266,7 +266,7 @@ def build_mermaid(all_layers: List['YamlGraph.Layer'], mermaid_leftright: bool = # if len(last_layer.components) > 1: # self.mermaid_graph.append('\tend') - style = ['classDef FrontendCLS fill:#FFFFCB,stroke:#277CE8,stroke-width:1px,stroke-dasharray:5;', + style = ['classDef FrontendCLS fill:#ffb347,stroke:#277CE8,stroke-width:1px,stroke-dasharray:5;', 'classDef EncoderCLS fill:#27E1E8,stroke:#277CE8,stroke-width:1px;', 'classDef IndexerCLS fill:#27E1E8,stroke:#277CE8,stroke-width:1px;', 'classDef RouterCLS fill:#2BFFCB,stroke:#277CE8,stroke-width:1px;', @@ -417,20 +417,29 @@ def rule8(): 'port_out': self._get_random_port()}) for c in last_layer.components: - c['socket_out'] = str(SocketType.PUSH_CONNECT) - r_c = CommentedMap({'name': 'Router', - 'yaml_path': None, - 'socket_in': str(SocketType.PULL_BIND), - 'socket_out': str(SocketType.PUSH_CONNECT), - 'port_in': self._get_random_port(), - 'port_out': r['port_in']}) - c['port_out'] = r_c['port_in'] - router_layer.append(r_c) + last_income = self.Layer.get_value(c, 'income') + if last_income == 'sub': + c['socket_out'] = str(SocketType.PUSH_CONNECT) + r_c = CommentedMap({'name': 'Router', + 'yaml_path': None, + 'socket_in': str(SocketType.PULL_BIND), + 'socket_out': str(SocketType.PUSH_CONNECT), + 'port_in': self._get_random_port(), + 'port_out': r['port_in']}) + c['port_out'] = r_c['port_in'] + router_layer.append(r_c) + elif last_income == 'pull': + c['socket_out'] = str(SocketType.PUSH_CONNECT) + c['port_out'] = r['port_in'] for c in layer.components: c['socket_in'] = str(SocketType.PULL_CONNECT) c['port_in'] = r['port_out'] - router_layers.append(router_layer) + + if router_layer.components: + router_layers.append(router_layer) + else: + self._num_layer -= 1 router_layer = YamlGraph.Layer(layer_id=self._num_layer) self._num_layer += 1 diff --git a/gnes/resources/static/gnes-board.html b/gnes/resources/static/gnes-board.html index ef704b79..81fc94e0 100644 --- a/gnes/resources/static/gnes-board.html +++ b/gnes/resources/static/gnes-board.html @@ -194,7 +194,7 @@
-
+
YAML config @@ -211,7 +211,7 @@
-
+
diff --git a/tests/test_compose.py b/tests/test_compose.py index 013f2fee..263dcc4c 100644 --- a/tests/test_compose.py +++ b/tests/test_compose.py @@ -11,8 +11,8 @@ def setUp(self): self.html_path = os.path.join(self.dirname, 'test.html') def test_all(self): - paths = [os.path.join(self.dirname, 'yaml', 'topology%d.yml' % j) for j in range(1, 7)] - b_a = [(3, 3), (4, 4), (4, 5), (4, 7), (4, 7), (4, 9)] + paths = [os.path.join(self.dirname, 'yaml', 'topology%d.yml' % j) for j in range(1, 8)] + b_a = [(3, 3), (4, 4), (4, 5), (4, 7), (4, 6), (4, 8), (4, 9)] for p, j in zip(paths, b_a): self._test_topology(p, *j) @@ -32,6 +32,6 @@ def _test_topology(self, yaml_path: str, num_layer_before: int, num_layer_after: os.path.exists(self.html_path) print(a.build_dockerswarm(r)) - def tearDown(self): - if os.path.exists(self.html_path): - os.remove(self.html_path) + # def tearDown(self): + # if os.path.exists(self.html_path): + # os.remove(self.html_path) diff --git a/tests/yaml/topology7.yml b/tests/yaml/topology7.yml new file mode 100644 index 00000000..a816d55b --- /dev/null +++ b/tests/yaml/topology7.yml @@ -0,0 +1,15 @@ +port: 5566 +services: +- name: Preprocessor + replicas: 2 +- name: Encoder + replicas: 3 +- + - name: Indexer + yaml_path: indexer-binary.yml + replicas: 4 + income: sub + - name: Indexer + yaml_path: indexer-fulltext.yml + replicas: 3 + income: sub \ No newline at end of file