|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# |
| 4 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 5 | +# contributor license agreements. See the NOTICE file distributed with |
| 6 | +# this work for additional information regarding copyright ownership. |
| 7 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 8 | +# (the "License"); you may not use this file except in compliance with |
| 9 | +# the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +# See the License for the specific language governing permissions and |
| 17 | +# limitations under the License. |
| 18 | +# |
| 19 | + |
| 20 | +. ./t/cli/common.sh |
| 21 | + |
| 22 | +# stream is only fully supported on the customed apisix-nginx-module build |
| 23 | +exit_if_not_customed_nginx |
| 24 | + |
| 25 | +# Nacos discovery picks its shared dict by subsystem (discovery/nacos/init.lua): |
| 26 | +# local dict_name = is_http and "nacos" or "nacos-stream" |
| 27 | +# and init_worker() raises 'lua_shared_dict "nacos-stream" not configured' when |
| 28 | +# the dict is missing. The `nacos-stream` dict must therefore be declared in the |
| 29 | +# stream block, otherwise enabling nacos discovery with the stream subsystem on |
| 30 | +# aborts the stream worker at startup. |
| 31 | +echo ' |
| 32 | +apisix: |
| 33 | + proxy_mode: stream |
| 34 | + enable_admin: false |
| 35 | + stream_proxy: |
| 36 | + tcp: |
| 37 | + - addr: 9100 |
| 38 | +discovery: |
| 39 | + nacos: |
| 40 | + host: |
| 41 | + - "http://127.0.0.1:8848" |
| 42 | +' > conf/config.yaml |
| 43 | + |
| 44 | +make run |
| 45 | +# wait until the stream worker accepts connections, which only happens after |
| 46 | +# init_worker has run -- avoids a race where the log is grepped too early |
| 47 | +wait_for_tcp 127.0.0.1 9100 |
| 48 | +make stop |
| 49 | + |
| 50 | +# guard against a false pass if nginx never started for an unrelated reason |
| 51 | +if grep -q "\[emerg\]" logs/error.log; then |
| 52 | + echo "failed: nginx did not start" |
| 53 | + cat logs/error.log |
| 54 | + exit 1 |
| 55 | +fi |
| 56 | + |
| 57 | +if grep -q 'lua_shared_dict "nacos-stream" not configured' logs/error.log; then |
| 58 | + echo "failed: nacos-stream shared dict is not declared in the stream subsystem" |
| 59 | + exit 1 |
| 60 | +fi |
| 61 | + |
| 62 | +echo "passed: nacos discovery initializes in the stream subsystem" |
0 commit comments