diff --git a/.ci/apps_tests/docker-compose.yaml b/.ci/apps_tests/docker-compose.yaml deleted file mode 100644 index 2fd49a893..000000000 --- a/.ci/apps_tests/docker-compose.yaml +++ /dev/null @@ -1,119 +0,0 @@ -version: '3.9' - -services: - erlang: - container_name: erlang - image: emqx/build-env:erl23.2.7-ubuntu20.04 - depends_on: - - mysql_server - - redis_server - - mongo_server - - pgsql_server - - ldap_server - networks: - - emqx_bridge - env_file: - - conf.env - environment: - GITHUB_ACTIONS: ${GITHUB_ACTIONS} - GITHUB_TOKEN: ${GITHUB_TOKEN} - GITHUB_RUN_ID: ${GITHUB_RUN_ID} - GITHUB_SHA: ${GITHUB_SHA} - GITHUB_RUN_NUMBER: ${GITHUB_RUN_NUMBER} - GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME} - GITHUB_REF: ${GITHUB_REF} - volumes: - - ../../.:/emqx - working_dir: /emqx - tty: true - deploy: - resources: - reservations: - cpus: '0.5' - memory: 500M - - mysql_server: - container_name: mysql - image: mysql:${MYSQL_TAG} - restart: always - ports: - - 3306:3306 - environment: - MYSQL_ROOT_PASSWORD: public - MYSQL_DATABASE: mqtt - command: - --bind-address 0.0.0.0 - --character-set-server=utf8mb4 - --collation-server=utf8mb4_general_ci - --explicit_defaults_for_timestamp=true - --lower_case_table_names=1 - --max_allowed_packet=128M - --skip-symbolic-links - networks: - - emqx_bridge - - redis_server: - container_name: redis - image: redis:${REDIS_TAG} - ports: - - 6379:6379 - command: - - redis-server - - "--bind 0.0.0.0 ::" - restart: always - networks: - - emqx_bridge - - mongo_server: - container_name: mongo - image: mongo:${MONGO_TAG} - ports: - - 27017:27017 - restart: always - environment: - MONGO_INITDB_DATABASE: mqtt - command: - --ipv6 - --bind_ip_all - networks: - - emqx_bridge - - pgsql_server: - container_name: pgsql - image: postgres:${PGSQL_TAG} - ports: - - 5432:5432 - restart: always - environment: - POSTGRES_PASSWORD: public - POSTGRES_USER: root - POSTGRES_DB: mqtt - networks: - - emqx_bridge - - ldap_server: - container_name: openldap - build: - context: ../.. - dockerfile: .ci/apps_tests/openldap/Dockerfile - args: - LDAP_TAG: ${LDAP_TAG} - image: emqx-ldap:1.0 - ports: - - 389:389 - restart: always - networks: - - emqx_bridge - -networks: - emqx_bridge: - driver: bridge - name: emqx_bridge - enable_ipv6: true - ipam: - driver: default - config: - - subnet: 172.100.239.0/24 - gateway: 172.100.239.1 - - subnet: 2001:3200:3200::/64 - gateway: 2001:3200:3200::1 diff --git a/.ci/apps_tests/openldap/Dockerfile b/.ci/apps_tests/openldap/Dockerfile deleted file mode 100644 index f15a48e69..000000000 --- a/.ci/apps_tests/openldap/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM buildpack-deps:stretch - -ARG LDAP_TAG=2.4.50 - -RUN apt-get update && apt-get install -y groff groff-base -RUN wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-${LDAP_TAG}.tgz \ - && gunzip -c openldap-${LDAP_TAG}.tgz | tar xvfB - \ - && cd openldap-${LDAP_TAG} \ - && ./configure && make depend && make && make install \ - && cd .. && rm -rf openldap-${LDAP_TAG} - -COPY .ci/apps_tests/openldap/slapd.conf /usr/local/etc/openldap/slapd.conf -COPY apps/emqx_auth_ldap/emqx.io.ldif /usr/local/etc/openldap/schema/emqx.io.ldif -COPY apps/emqx_auth_ldap/emqx.schema /usr/local/etc/openldap/schema/emqx.schema -COPY apps/emqx_auth_ldap/test/certs/*.pem /usr/local/etc/openldap/ - -RUN mkdir -p /usr/local/etc/openldap/data \ - && slapadd -l /usr/local/etc/openldap/schema/emqx.io.ldif -f /usr/local/etc/openldap/slapd.conf - -WORKDIR /usr/local/etc/openldap - -EXPOSE 389 636 - -ENTRYPOINT ["/usr/local/libexec/slapd", "-h", "ldap:/// ldaps:///", "-d", "3", "-f", "/usr/local/etc/openldap/slapd.conf"] - -CMD [] diff --git a/.ci/compatibility_tests/.env b/.ci/compatibility_tests/.env deleted file mode 100644 index 2ac286e98..000000000 --- a/.ci/compatibility_tests/.env +++ /dev/null @@ -1,5 +0,0 @@ -MYSQL_TAG=5.7 -REDIS_TAG=6 -MONGO_TAG=4.1 -PGSQL_TAG=11 -LDAP_TAG=2.4.50 diff --git a/.ci/compatibility_tests/docker-compose-mongo-tls.yaml b/.ci/compatibility_tests/docker-compose-mongo-tls.yaml deleted file mode 100644 index 610056121..000000000 --- a/.ci/compatibility_tests/docker-compose-mongo-tls.yaml +++ /dev/null @@ -1,43 +0,0 @@ -version: '3' - -services: - erlang: - container_name: erlang - image: emqx/build-env:erl23.2.7-ubuntu20.04 - volumes: - - ../../:/emqx - working_dir: /emqx - networks: - - emqx_bridge - depends_on: - - mongo_server - tty: true - - mongo_server: - container_name: mongo - image: mongo:${MONGO_TAG} - restart: always - environment: - MONGO_INITDB_DATABASE: mqtt - volumes: - - ../../apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/mongodb.pem/:/etc/certs/mongodb.pem - networks: - - emqx_bridge - command: - --ipv6 - --bind_ip_all - --sslMode requireSSL - --sslPEMKeyFile /etc/certs/mongodb.pem - -networks: - emqx_bridge: - driver: bridge - name: emqx_bridge - enable_ipv6: true - ipam: - driver: default - config: - - subnet: 172.100.100.0/24 - gateway: 172.100.100.1 - - subnet: 2001:3200:3200::/64 - gateway: 2001:3200:3200::1 diff --git a/.ci/compatibility_tests/docker-compose-mongo.yaml b/.ci/compatibility_tests/docker-compose-mongo.yaml deleted file mode 100644 index c3e2a1d66..000000000 --- a/.ci/compatibility_tests/docker-compose-mongo.yaml +++ /dev/null @@ -1,39 +0,0 @@ -version: '3' - -services: - erlang: - container_name: erlang - image: emqx/build-env:erl23.2.7-ubuntu20.04 - volumes: - - ../..:/emqx - working_dir: /emqx - networks: - - emqx_bridge - depends_on: - - mongo_server - tty: true - - mongo_server: - container_name: mongo - image: mongo:${MONGO_TAG} - restart: always - environment: - MONGO_INITDB_DATABASE: mqtt - networks: - - emqx_bridge - command: - --ipv6 - --bind_ip_all - -networks: - emqx_bridge: - driver: bridge - name: emqx_bridge - enable_ipv6: true - ipam: - driver: default - config: - - subnet: 172.100.100.0/24 - gateway: 172.100.100.1 - - subnet: 2001:3200:3200::/64 - gateway: 2001:3200:3200::1 diff --git a/.ci/compatibility_tests/docker-compose-mysql.yaml b/.ci/compatibility_tests/docker-compose-mysql.yaml deleted file mode 100644 index adc3aa97f..000000000 --- a/.ci/compatibility_tests/docker-compose-mysql.yaml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3' - -services: - erlang: - container_name: erlang - image: emqx/build-env:erl23.2.7-ubuntu20.04 - volumes: - - ../../:/emqx - working_dir: /emqx - networks: - - emqx_bridge - depends_on: - - mysql_server - tty: true - - mysql_server: - container_name: mysql - image: mysql:${MYSQL_TAG} - restart: always - environment: - MYSQL_ROOT_PASSWORD: public - MYSQL_DATABASE: mqtt - networks: - - emqx_bridge - command: - --bind-address "::" - --character-set-server=utf8mb4 - --collation-server=utf8mb4_general_ci - --explicit_defaults_for_timestamp=true - --lower_case_table_names=1 - --max_allowed_packet=128M - --skip-symbolic-links - -networks: - emqx_bridge: - driver: bridge - name: emqx_bridge - enable_ipv6: true - ipam: - driver: default - config: - - subnet: 172.100.100.0/24 - gateway: 172.100.100.1 - - subnet: 2001:3200:3200::/64 - gateway: 2001:3200:3200::1 diff --git a/.ci/compatibility_tests/docker-compose-pgsql.yaml b/.ci/compatibility_tests/docker-compose-pgsql.yaml deleted file mode 100644 index 5204d85c9..000000000 --- a/.ci/compatibility_tests/docker-compose-pgsql.yaml +++ /dev/null @@ -1,38 +0,0 @@ -version: '3' - -services: - erlang: - container_name: erlang - image: emqx/build-env:erl23.2.7-ubuntu20.04 - volumes: - - ../../:/emqx - working_dir: /emqx - networks: - - emqx_bridge - depends_on: - - pgsql_server - tty: true - - pgsql_server: - container_name: pgsql - image: postgres:${PGSQL_TAG} - restart: always - environment: - POSTGRES_PASSWORD: public - POSTGRES_USER: root - POSTGRES_DB: mqtt - networks: - - emqx_bridge - -networks: - emqx_bridge: - driver: bridge - name: emqx_bridge - enable_ipv6: true - ipam: - driver: default - config: - - subnet: 172.100.100.0/24 - gateway: 172.100.100.1 - - subnet: 2001:3200:3200::/64 - gateway: 2001:3200:3200::1 diff --git a/.ci/compatibility_tests/docker-compose-redis-cluster-tls.yaml b/.ci/compatibility_tests/docker-compose-redis-cluster-tls.yaml deleted file mode 100644 index bc9e24931..000000000 --- a/.ci/compatibility_tests/docker-compose-redis-cluster-tls.yaml +++ /dev/null @@ -1,41 +0,0 @@ -version: '2.4' -# network configuration is limited in version 3 -# https://github.com/docker/compose/issues/4958 - -services: - erlang: - container_name: erlang - image: emqx/build-env:erl23.2.7-ubuntu20.04 - volumes: - - ../..:/emqx - networks: - - app_net - depends_on: - - redis_cluster - working_dir: /emqx - tty: true - - redis_cluster: - container_name: redis - image: redis:${REDIS_TAG} - volumes: - - ../../apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs:/tls - - ./redis/:/data/conf - command: bash -c "/bin/bash /data/conf/redis.sh --node cluster --tls-enabled && while true; do echo 1; sleep 1; done" - networks: - app_net: - # Assign a public address. Erlang container cannot find cluster nodes by network-scoped alias (redis_cluster). - ipv4_address: 172.16.239.10 - ipv6_address: 2001:3200:3200::20 - -networks: - app_net: - driver: bridge - enable_ipv6: true - ipam: - driver: default - config: - - subnet: 172.16.239.0/24 - gateway: 172.16.239.1 - - subnet: 2001:3200:3200::/64 - gateway: 2001:3200:3200::1 diff --git a/.ci/compatibility_tests/docker-compose-redis-cluster.yaml b/.ci/compatibility_tests/docker-compose-redis-cluster.yaml deleted file mode 100644 index bdbcf11af..000000000 --- a/.ci/compatibility_tests/docker-compose-redis-cluster.yaml +++ /dev/null @@ -1,40 +0,0 @@ -version: '2.4' -# network configuration is limited in version 3 -# https://github.com/docker/compose/issues/4958 - -services: - erlang: - container_name: erlang - image: emqx/build-env:erl23.2.7-ubuntu20.04 - volumes: - - ../..:/emqx - networks: - - app_net - depends_on: - - redis_cluster - working_dir: /emqx - tty: true - - redis_cluster: - image: redis:${REDIS_TAG} - container_name: redis - volumes: - - ./redis/:/data/conf - command: bash -c "/bin/bash /data/conf/redis.sh --node cluster && while true; do echo 1; sleep 1; done" - networks: - app_net: - # Assign a public address. Erlang container cannot find cluster nodes by network-scoped alias (redis_cluster). - ipv4_address: 172.16.239.10 - ipv6_address: 2001:3200:3200::20 - -networks: - app_net: - driver: bridge - enable_ipv6: true - ipam: - driver: default - config: - - subnet: 172.16.239.0/24 - gateway: 172.16.239.1 - - subnet: 2001:3200:3200::/64 - gateway: 2001:3200:3200::1 diff --git a/.ci/compatibility_tests/docker-compose-redis-sentinel.yaml b/.ci/compatibility_tests/docker-compose-redis-sentinel.yaml deleted file mode 100644 index 134724da7..000000000 --- a/.ci/compatibility_tests/docker-compose-redis-sentinel.yaml +++ /dev/null @@ -1,40 +0,0 @@ -version: '2.4' -# network configuration is limited in version 3 -# https://github.com/docker/compose/issues/4958 - -services: - erlang: - container_name: erlang - image: emqx/build-env:erl23.2.7-ubuntu20.04 - volumes: - - ../..:/emqx - networks: - - app_net - depends_on: - - redis_cluster - working_dir: /emqx - tty: true - - redis_cluster: - container_name: redis - image: redis:${REDIS_TAG} - volumes: - - ./redis/:/data/conf - command: bash -c "/bin/bash /data/conf/redis.sh --node sentinel && while true; do echo 1; sleep 1; done" - networks: - app_net: - # Assign a public address. Erlang container cannot find cluster nodes by network-scoped alias (redis_cluster). - ipv4_address: 172.16.239.10 - ipv6_address: 2001:3200:3200::20 - -networks: - app_net: - driver: bridge - enable_ipv6: true - ipam: - driver: default - config: - - subnet: 172.16.239.0/24 - gateway: 172.16.239.1 - - subnet: 2001:3200:3200::/64 - gateway: 2001:3200:3200::1 diff --git a/.ci/compatibility_tests/docker-compose-redis-single-tls.yaml b/.ci/compatibility_tests/docker-compose-redis-single-tls.yaml deleted file mode 100644 index 0e0a0dd25..000000000 --- a/.ci/compatibility_tests/docker-compose-redis-single-tls.yaml +++ /dev/null @@ -1,43 +0,0 @@ -version: '3' - -services: - erlang: - container_name: erlang - image: emqx/build-env:erl23.2.7-ubuntu20.04 - volumes: - - ../..:/emqx - networks: - - emqx_bridge - depends_on: - - redis_server - working_dir: /emqx - tty: true - - redis_server: - container_name: redis - image: redis:${REDIS_TAG} - volumes: - - ../../apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs:/tls - command: - - redis-server - - "--bind 0.0.0.0 ::" - - --tls-port 6380 - - --tls-cert-file /tls/redis.crt - - --tls-key-file /tls/redis.key - - --tls-ca-cert-file /tls/ca.crt - restart: always - networks: - - emqx_bridge - -networks: - emqx_bridge: - driver: bridge - name: emqx_bridge - enable_ipv6: true - ipam: - driver: default - config: - - subnet: 172.100.100.0/24 - gateway: 172.100.100.1 - - subnet: 2001:3200:3200::/64 - gateway: 2001:3200:3200::1 diff --git a/.ci/compatibility_tests/docker-compose-redis-single.yaml b/.ci/compatibility_tests/docker-compose-redis-single.yaml deleted file mode 100644 index b603758ab..000000000 --- a/.ci/compatibility_tests/docker-compose-redis-single.yaml +++ /dev/null @@ -1,37 +0,0 @@ -version: '3' - -services: - erlang: - container_name: erlang - image: emqx/build-env:erl23.2.7-ubuntu20.04 - volumes: - - ../..:/emqx - networks: - - emqx_bridge - depends_on: - - redis_server - working_dir: /emqx - tty: true - - redis_server: - container_name: redis - image: redis:${REDIS_TAG} - command: - - redis-server - - "--bind 0.0.0.0 ::" - restart: always - networks: - - emqx_bridge - -networks: - emqx_bridge: - driver: bridge - name: emqx_bridge - enable_ipv6: true - ipam: - driver: default - config: - - subnet: 172.100.100.0/24 - gateway: 172.100.100.1 - - subnet: 2001:3200:3200::/64 - gateway: 2001:3200:3200::1 diff --git a/.ci/compatibility_tests/openldap/slapd.conf b/.ci/compatibility_tests/openldap/slapd.conf deleted file mode 100644 index d6ba20caa..000000000 --- a/.ci/compatibility_tests/openldap/slapd.conf +++ /dev/null @@ -1,16 +0,0 @@ -include /usr/local/etc/openldap/schema/core.schema -include /usr/local/etc/openldap/schema/cosine.schema -include /usr/local/etc/openldap/schema/inetorgperson.schema -include /usr/local/etc/openldap/schema/ppolicy.schema -include /usr/local/etc/openldap/schema/emqx.schema - -TLSCACertificateFile /usr/local/etc/openldap/cacert.pem -TLSCertificateFile /usr/local/etc/openldap/cert.pem -TLSCertificateKeyFile /usr/local/etc/openldap/key.pem - -database bdb -suffix "dc=emqx,dc=io" -rootdn "cn=root,dc=emqx,dc=io" -rootpw {SSHA}eoF7NhNrejVYYyGHqnt+MdKNBh4r1w3W - -directory /usr/local/etc/openldap/data diff --git a/.ci/apps_tests/.env b/.ci/docker-compose-file/.env similarity index 100% rename from .ci/apps_tests/.env rename to .ci/docker-compose-file/.env diff --git a/.ci/apps_tests/conf.env b/.ci/docker-compose-file/conf.env similarity index 100% rename from .ci/apps_tests/conf.env rename to .ci/docker-compose-file/conf.env index eb5a98277..a9da57f94 100644 --- a/.ci/apps_tests/conf.env +++ b/.ci/docker-compose-file/conf.env @@ -1,6 +1,5 @@ EMQX_AUTH__LDAP__SERVERS=ldap_server EMQX_AUTH__MONGO__SERVER=mongo_server:27017 -EMQX_AUTH__REDIS__SERVER=redis_server:6379 EMQX_AUTH__MYSQL__SERVER=mysql_server:3306 EMQX_AUTH__MYSQL__USERNAME=root EMQX_AUTH__MYSQL__PASSWORD=public @@ -9,4 +8,5 @@ EMQX_AUTH__PGSQL__SERVER=pgsql_server:5432 EMQX_AUTH__PGSQL__USERNAME=root EMQX_AUTH__PGSQL__PASSWORD=public EMQX_AUTH__PGSQL__DATABASE=mqtt +EMQX_AUTH__REDIS__SERVER=redis_server:6379 CUTTLEFISH_ENV_OVERRIDE_PREFIX=EMQX_ diff --git a/.ci/docker-compose-file/docker-compose-ldap-tcp.yaml b/.ci/docker-compose-file/docker-compose-ldap-tcp.yaml new file mode 100644 index 000000000..6640f8b50 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-ldap-tcp.yaml @@ -0,0 +1,18 @@ +version: '3.9' + +services: + ldap_server: + container_name: ldap + build: + context: ../.. + dockerfile: .ci/docker-compose-file/openldap/Dockerfile + args: + LDAP_TAG: ${LDAP_TAG} + image: openldap + ports: + - 389:389 + restart: always + networks: + emqx_bridge: + ipv4_address: 172.100.239.10 + ipv6_address: 2001:3200:3200::10 diff --git a/.ci/docker-compose-file/docker-compose-mongo-tcp.yaml b/.ci/docker-compose-file/docker-compose-mongo-tcp.yaml new file mode 100644 index 000000000..52f21df82 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-mongo-tcp.yaml @@ -0,0 +1,16 @@ +version: '3.9' + +services: + mongo_server: + container_name: mongo + image: mongo:${MONGO_TAG} + restart: always + environment: + MONGO_INITDB_DATABASE: mqtt + networks: + emqx_bridge: + ipv4_address: 172.100.239.11 + ipv6_address: 2001:3200:3200::11 + command: + --ipv6 + --bind_ip_all diff --git a/.ci/docker-compose-file/docker-compose-mongo-tls.yaml b/.ci/docker-compose-file/docker-compose-mongo-tls.yaml new file mode 100644 index 000000000..0188c77e7 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-mongo-tls.yaml @@ -0,0 +1,20 @@ +version: '3.9' + +services: + mongo_server: + container_name: mongo + image: mongo:${MONGO_TAG} + restart: always + environment: + MONGO_INITDB_DATABASE: mqtt + volumes: + - ../../apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/mongodb.pem/:/etc/certs/mongodb.pem + networks: + emqx_bridge: + ipv4_address: 172.100.239.11 + ipv6_address: 2001:3200:3200::11 + command: + --ipv6 + --bind_ip_all + --sslMode requireSSL + --sslPEMKeyFile /etc/certs/mongodb.pem diff --git a/.ci/docker-compose-file/docker-compose-mysql-tcp.yaml b/.ci/docker-compose-file/docker-compose-mysql-tcp.yaml new file mode 100644 index 000000000..e23de2369 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-mysql-tcp.yaml @@ -0,0 +1,22 @@ +version: '3.9' + +services: + mysql_server: + container_name: mysql + image: mysql:${MYSQL_TAG} + restart: always + environment: + MYSQL_ROOT_PASSWORD: public + MYSQL_DATABASE: mqtt + networks: + emqx_bridge: + ipv4_address: 172.100.239.12 + ipv6_address: 2001:3200:3200::12 + command: + --bind-address "::" + --character-set-server=utf8mb4 + --collation-server=utf8mb4_general_ci + --explicit_defaults_for_timestamp=true + --lower_case_table_names=1 + --max_allowed_packet=128M + --skip-symbolic-links diff --git a/.ci/compatibility_tests/docker-compose-mysql-tls.yaml b/.ci/docker-compose-file/docker-compose-mysql-tls.yaml similarity index 62% rename from .ci/compatibility_tests/docker-compose-mysql-tls.yaml rename to .ci/docker-compose-file/docker-compose-mysql-tls.yaml index f3c9142ed..0761a59cd 100644 --- a/.ci/compatibility_tests/docker-compose-mysql-tls.yaml +++ b/.ci/docker-compose-file/docker-compose-mysql-tls.yaml @@ -1,18 +1,6 @@ -version: '3' +version: '3.9' services: - erlang: - container_name: erlang - image: emqx/build-env:erl23.2.7-ubuntu20.04 - volumes: - - ../../:/emqx - working_dir: /emqx - networks: - - emqx_bridge - depends_on: - - mysql_server - tty: true - mysql_server: container_name: mysql image: mysql:${MYSQL_TAG} @@ -25,7 +13,9 @@ services: - ../../apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/server-cert.pem:/etc/certs/server-cert.pem - ../../apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/server-key.pem:/etc/certs/server-key.pem networks: - - emqx_bridge + emqx_bridge: + ipv4_address: 172.100.239.12 + ipv6_address: 2001:3200:3200::12 command: --bind-address "::" --character-set-server=utf8mb4 @@ -37,16 +27,3 @@ services: --ssl-ca=/etc/certs/ca-cert.pem --ssl-cert=/etc/certs/server-cert.pem --ssl-key=/etc/certs/server-key.pem - -networks: - emqx_bridge: - driver: bridge - name: emqx_bridge - enable_ipv6: true - ipam: - driver: default - config: - - subnet: 172.100.100.0/24 - gateway: 172.100.100.1 - - subnet: 2001:3200:3200::/64 - gateway: 2001:3200:3200::1 diff --git a/.ci/docker-compose-file/docker-compose-pgsql-tcp.yaml b/.ci/docker-compose-file/docker-compose-pgsql-tcp.yaml new file mode 100644 index 000000000..7ad5b4390 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-pgsql-tcp.yaml @@ -0,0 +1,17 @@ +version: '3.9' + +services: + pgsql_server: + container_name: pgsql + image: postgres:${PGSQL_TAG} + restart: always + environment: + POSTGRES_PASSWORD: public + POSTGRES_USER: root + POSTGRES_DB: mqtt + ports: + - "5432:5432" + networks: + emqx_bridge: + ipv4_address: 172.100.239.13 + ipv6_address: 2001:3200:3200::13 diff --git a/.ci/compatibility_tests/docker-compose-pgsql-tls.yaml b/.ci/docker-compose-file/docker-compose-pgsql-tls.yaml similarity index 52% rename from .ci/compatibility_tests/docker-compose-pgsql-tls.yaml rename to .ci/docker-compose-file/docker-compose-pgsql-tls.yaml index fd9855c01..589feddb4 100644 --- a/.ci/compatibility_tests/docker-compose-pgsql-tls.yaml +++ b/.ci/docker-compose-file/docker-compose-pgsql-tls.yaml @@ -1,23 +1,11 @@ -version: '3' +version: '3.9' services: - erlang: - container_name: erlang - image: emqx/build-env:erl23.2.7-ubuntu20.04 - volumes: - - ../../:/emqx - working_dir: /emqx - networks: - - emqx_bridge - depends_on: - - pgsql_server - tty: true - pgsql_server: container_name: pgsql build: context: ../.. - dockerfile: .ci/compatibility_tests/pgsql/Dockerfile + dockerfile: .ci/docker-compose-file/pgsql/Dockerfile args: POSTGRES_USER: postgres BUILD_FROM: postgres:${PGSQL_TAG} @@ -41,17 +29,6 @@ services: - -c - hba_file=/var/lib/postgresql/pg_hba.conf networks: - - emqx_bridge - -networks: - emqx_bridge: - driver: bridge - name: emqx_bridge - enable_ipv6: true - ipam: - driver: default - config: - - subnet: 172.100.100.0/24 - gateway: 172.100.100.1 - - subnet: 2001:3200:3200::/64 - gateway: 2001:3200:3200::1 + emqx_bridge: + ipv4_address: 172.100.239.13 + ipv6_address: 2001:3200:3200::13 diff --git a/.ci/docker-compose-file/docker-compose-redis-cluster-tcp.yaml b/.ci/docker-compose-file/docker-compose-redis-cluster-tcp.yaml new file mode 100644 index 000000000..b8ea44971 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-redis-cluster-tcp.yaml @@ -0,0 +1,14 @@ +version: '3.9' + +services: + redis_cluster: + image: redis:${REDIS_TAG} + container_name: redis + volumes: + - ./redis/:/data/conf + command: bash -c "/bin/bash /data/conf/redis.sh --node cluster && while true; do echo 1; sleep 1; done" + networks: + emqx_bridge: + # Assign a public address. Erlang container cannot find cluster nodes by network-scoped alias (redis_cluster). + ipv4_address: 172.100.239.14 + ipv6_address: 2001:3200:3200::14 diff --git a/.ci/docker-compose-file/docker-compose-redis-cluster-tls.yaml b/.ci/docker-compose-file/docker-compose-redis-cluster-tls.yaml new file mode 100644 index 000000000..16654531e --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-redis-cluster-tls.yaml @@ -0,0 +1,15 @@ +version: '3.9' + +services: + redis_cluster: + container_name: redis + image: redis:${REDIS_TAG} + volumes: + - ../../apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs:/tls + - ./redis/:/data/conf + command: bash -c "/bin/bash /data/conf/redis.sh --node cluster --tls-enabled && while true; do echo 1; sleep 1; done" + networks: + emqx_bridge: + # Assign a public address. Erlang container cannot find cluster nodes by network-scoped alias (redis_cluster). + ipv4_address: 172.100.239.14 + ipv6_address: 2001:3200:3200::14 diff --git a/.ci/docker-compose-file/docker-compose-redis-sentinel-tcp.yaml b/.ci/docker-compose-file/docker-compose-redis-sentinel-tcp.yaml new file mode 100644 index 000000000..f2a79bda6 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-redis-sentinel-tcp.yaml @@ -0,0 +1,14 @@ +version: '3.9' + +services: + redis_cluster: + container_name: redis + image: redis:${REDIS_TAG} + volumes: + - ./redis/:/data/conf + command: bash -c "/bin/bash /data/conf/redis.sh --node sentinel && while true; do echo 1; sleep 1; done" + networks: + emqx_bridge: + # Assign a public address. Erlang container cannot find cluster nodes by network-scoped alias (redis_cluster). + ipv4_address: 172.100.239.14 + ipv6_address: 2001:3200:3200::14 diff --git a/.ci/docker-compose-file/docker-compose-redis-single-tcp.yaml b/.ci/docker-compose-file/docker-compose-redis-single-tcp.yaml new file mode 100644 index 000000000..12fd2abc1 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-redis-single-tcp.yaml @@ -0,0 +1,15 @@ +version: '3.9' + +services: + redis_server: + container_name: redis + image: redis:${REDIS_TAG} + command: + - redis-server + - "--bind 0.0.0.0 ::" + restart: always + networks: + emqx_bridge: + # Assign a public address. Erlang container cannot find cluster nodes by network-scoped alias (redis_cluster). + ipv4_address: 172.100.239.14 + ipv6_address: 2001:3200:3200::14 diff --git a/.ci/docker-compose-file/docker-compose-redis-single-tls.yaml b/.ci/docker-compose-file/docker-compose-redis-single-tls.yaml new file mode 100644 index 000000000..a1ae8b379 --- /dev/null +++ b/.ci/docker-compose-file/docker-compose-redis-single-tls.yaml @@ -0,0 +1,21 @@ +version: '3.9' + +services: + redis_server: + container_name: redis + image: redis:${REDIS_TAG} + volumes: + - ../../apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs:/tls + command: + - redis-server + - "--bind 0.0.0.0 ::" + - --tls-port 6380 + - --tls-cert-file /tls/redis.crt + - --tls-key-file /tls/redis.key + - --tls-ca-cert-file /tls/ca.crt + restart: always + networks: + emqx_bridge: + # Assign a public address. Erlang container cannot find cluster nodes by network-scoped alias (redis_cluster). + ipv4_address: 172.100.239.14 + ipv6_address: 2001:3200:3200::14 diff --git a/.ci/compatibility_tests/docker-compose-ldap.yaml b/.ci/docker-compose-file/docker-compose.yaml similarity index 56% rename from .ci/compatibility_tests/docker-compose-ldap.yaml rename to .ci/docker-compose-file/docker-compose.yaml index 1c47756d5..1f9345bb7 100644 --- a/.ci/compatibility_tests/docker-compose-ldap.yaml +++ b/.ci/docker-compose-file/docker-compose.yaml @@ -1,32 +1,26 @@ -version: '3' +version: '3.9' services: erlang: container_name: erlang image: emqx/build-env:erl23.2.7-ubuntu20.04 - depends_on: - - ldap_server + env_file: + - conf.env + environment: + GITHUB_ACTIONS: ${GITHUB_ACTIONS} + GITHUB_TOKEN: ${GITHUB_TOKEN} + GITHUB_RUN_ID: ${GITHUB_RUN_ID} + GITHUB_SHA: ${GITHUB_SHA} + GITHUB_RUN_NUMBER: ${GITHUB_RUN_NUMBER} + GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME} + GITHUB_REF: ${GITHUB_REF} networks: - emqx_bridge volumes: - - ../../.:/emqx + - ../..:/emqx working_dir: /emqx tty: true - ldap_server: - container_name: ldap - build: - context: ../.. - dockerfile: .ci/compatibility_tests/openldap/Dockerfile - args: - LDAP_TAG: ${LDAP_TAG} - image: openldap - ports: - - 389:389 - restart: always - networks: - - emqx_bridge - networks: emqx_bridge: driver: bridge diff --git a/.ci/compatibility_tests/openldap/Dockerfile b/.ci/docker-compose-file/openldap/Dockerfile similarity index 93% rename from .ci/compatibility_tests/openldap/Dockerfile rename to .ci/docker-compose-file/openldap/Dockerfile index fa15ab5eb..adbb80800 100644 --- a/.ci/compatibility_tests/openldap/Dockerfile +++ b/.ci/docker-compose-file/openldap/Dockerfile @@ -9,7 +9,7 @@ RUN wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-${LDAP_TA && ./configure && make depend && make && make install \ && cd .. && rm -rf openldap-${LDAP_TAG} -COPY .ci/compatibility_tests/openldap/slapd.conf /usr/local/etc/openldap/slapd.conf +COPY .ci/docker-compose-file/openldap/slapd.conf /usr/local/etc/openldap/slapd.conf COPY apps/emqx_auth_ldap/emqx.io.ldif /usr/local/etc/openldap/schema/emqx.io.ldif COPY apps/emqx_auth_ldap/emqx.schema /usr/local/etc/openldap/schema/emqx.schema COPY apps/emqx_auth_ldap/test/certs/*.pem /usr/local/etc/openldap/ diff --git a/.ci/apps_tests/openldap/slapd.conf b/.ci/docker-compose-file/openldap/slapd.conf similarity index 100% rename from .ci/apps_tests/openldap/slapd.conf rename to .ci/docker-compose-file/openldap/slapd.conf diff --git a/.ci/compatibility_tests/pgsql/Dockerfile b/.ci/docker-compose-file/pgsql/Dockerfile similarity index 91% rename from .ci/compatibility_tests/pgsql/Dockerfile rename to .ci/docker-compose-file/pgsql/Dockerfile index a3b6374fc..e4c973258 100644 --- a/.ci/compatibility_tests/pgsql/Dockerfile +++ b/.ci/docker-compose-file/pgsql/Dockerfile @@ -1,7 +1,7 @@ ARG BUILD_FROM=postgres:11 FROM ${BUILD_FROM} ARG POSTGRES_USER=postgres -COPY --chown=$POSTGRES_USER .ci/compatibility_tests/pgsql/pg_hba.conf /var/lib/postgresql/pg_hba.conf +COPY --chown=$POSTGRES_USER .ci/docker-compose-file/pgsql/pg_hba.conf /var/lib/postgresql/pg_hba.conf COPY --chown=$POSTGRES_USER apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE_data/server-key.pem /var/lib/postgresql/server.key COPY --chown=$POSTGRES_USER apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE_data/server-cert.pem /var/lib/postgresql/server.crt COPY --chown=$POSTGRES_USER apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE_data/ca.pem /var/lib/postgresql/root.crt diff --git a/.ci/compatibility_tests/pgsql/pg_hba.conf b/.ci/docker-compose-file/pgsql/pg_hba.conf similarity index 100% rename from .ci/compatibility_tests/pgsql/pg_hba.conf rename to .ci/docker-compose-file/pgsql/pg_hba.conf diff --git a/.ci/compatibility_tests/redis/redis-tls.conf b/.ci/docker-compose-file/redis/redis-tls.conf similarity index 100% rename from .ci/compatibility_tests/redis/redis-tls.conf rename to .ci/docker-compose-file/redis/redis-tls.conf diff --git a/.ci/compatibility_tests/redis/redis.conf b/.ci/docker-compose-file/redis/redis.conf similarity index 100% rename from .ci/compatibility_tests/redis/redis.conf rename to .ci/docker-compose-file/redis/redis.conf diff --git a/.ci/compatibility_tests/redis/redis.sh b/.ci/docker-compose-file/redis/redis.sh similarity index 100% rename from .ci/compatibility_tests/redis/redis.sh rename to .ci/docker-compose-file/redis/redis.sh diff --git a/.ci/compatibility_tests/redis/sentinel.conf b/.ci/docker-compose-file/redis/sentinel.conf similarity index 100% rename from .ci/compatibility_tests/redis/sentinel.conf rename to .ci/docker-compose-file/redis/sentinel.conf diff --git a/.github/workflows/run_cts_tests.yaml b/.github/workflows/run_cts_tests.yaml index c996dfb8c..66744917f 100644 --- a/.github/workflows/run_cts_tests.yaml +++ b/.github/workflows/run_cts_tests.yaml @@ -24,12 +24,14 @@ jobs: steps: - uses: actions/checkout@v1 - - name: setup + - name: docker compose up env: LDAP_TAG: ${{ matrix.ldap_tag }} run: | - docker-compose -f .ci/compatibility_tests/docker-compose-ldap.yaml build --no-cache - docker-compose -f .ci/compatibility_tests/docker-compose-ldap.yaml up -d + docker-compose \ + -f .ci/docker-compose-file/docker-compose-ldap-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose.yaml \ + up -d --build - name: setup if: matrix.network_type == 'ipv4' run: | @@ -74,12 +76,17 @@ jobs: steps: - uses: actions/checkout@v1 + - name: docker-compose up + run: | + docker-compose \ + -f .ci/docker-compose-file/docker-compose-mongo-${{ matrix.connect_type }}.yaml \ + -f .ci/docker-compose-file/docker-compose.yaml \ + up -d --build - name: setup env: MONGO_TAG: ${{ matrix.mongo_tag }} if: matrix.connect_type == 'tls' run: | - docker-compose -f .ci/compatibility_tests/docker-compose-mongo-tls.yaml up -d cat <<-EOF >> "$GITHUB_ENV" EMQX_AUTH__MONGO__SSL=on EMQX_AUTH__MONGO__SSL__CACERTFILE=/emqx/apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/ca.pem @@ -93,7 +100,6 @@ jobs: MONGO_TAG: ${{ matrix.mongo_tag }} if: matrix.connect_type == 'tcp' run: | - docker-compose -f .ci/compatibility_tests/docker-compose-mongo.yaml up -d echo EMQX_AUTH__MONGO__SSL=off >> "$GITHUB_ENV" - name: setup if: matrix.network_type == 'ipv4' @@ -139,12 +145,17 @@ jobs: steps: - uses: actions/checkout@v1 + - name: docker-compose up + run: | + docker-compose \ + -f .ci/docker-compose-file/docker-compose-mysql-${{ matrix.connect_type }}.yaml \ + -f .ci/docker-compose-file/docker-compose.yaml \ + up -d --build - name: setup env: MYSQL_TAG: ${{ matrix.mysql_tag }} if: matrix.connect_type == 'tls' run: | - docker-compose -f .ci/compatibility_tests/docker-compose-mysql-tls.yaml up -d cat <<-EOF >> "$GITHUB_ENV" EMQX_AUTH__MYSQL__SSL=on EMQX_AUTH__MYSQL__SSL__CACERTFILE=/emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/ca.pem @@ -158,7 +169,6 @@ jobs: MYSQL_TAG: ${{ matrix.mysql_tag }} if: matrix.connect_type == 'tcp' run: | - docker-compose -f .ci/compatibility_tests/docker-compose-mysql.yaml up -d echo EMQX_AUTH__MYSQL__SSL=off >> "$GITHUB_ENV" - name: setup if: matrix.network_type == 'ipv4' @@ -209,13 +219,17 @@ jobs: - tcp steps: - uses: actions/checkout@v1 + - name: docker-compose up + run: | + docker-compose \ + -f .ci/docker-compose-file/docker-compose-pgsql-${{ matrix.connect_type }}.yaml \ + -f .ci/docker-compose-file/docker-compose.yaml \ + up -d --build - name: setup env: PGSQL_TAG: ${{ matrix.pgsql_tag }} if: matrix.connect_type == 'tls' run: | - docker-compose -f .ci/compatibility_tests/docker-compose-pgsql-tls.yaml build --no-cache - docker-compose -f .ci/compatibility_tests/docker-compose-pgsql-tls.yaml up -d cat <<-EOF >> "$GITHUB_ENV" EMQX_AUTH__PGSQL__SSL=on EMQX_AUTH__PGSQL__SSL__CACERTFILE=/emqx/apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE_data/ca.pem @@ -229,7 +243,6 @@ jobs: PGSQL_TAG: ${{ matrix.pgsql_tag }} if: matrix.connect_type == 'tcp' run: | - docker-compose -f .ci/compatibility_tests/docker-compose-pgsql.yaml up -d echo EMQX_AUTH__PGSQL__SSL=off >> "$GITHUB_ENV" - name: setup if: matrix.network_type == 'ipv4' @@ -284,13 +297,17 @@ jobs: steps: - uses: actions/checkout@v1 + - name: docker-compose up + run: | + docker-compose \ + -f .ci/docker-compose-file/docker-compose-redis-${{ matrix.node_type }}-${{ matrix.connect_type }}.yaml \ + -f .ci/docker-compose-file/docker-compose.yaml \ + up -d --build - name: setup env: REDIS_TAG: ${{ matrix.redis_tag }} if: matrix.connect_type == 'tls' run: | - set -exu - docker-compose -f .ci/compatibility_tests/docker-compose-redis-${{ matrix.node_type }}-tls.yaml up -d cat <<-EOF >> "$GITHUB_ENV" EMQX_AUTH__REDIS__SSL=on EMQX_AUTH__REDIS__SSL__CACERTFILE=/emqx/apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs/ca.crt @@ -304,11 +321,9 @@ jobs: REDIS_TAG: ${{ matrix.redis_tag }} if: matrix.connect_type == 'tcp' run: | - docker-compose -f .ci/compatibility_tests/docker-compose-redis-${{ matrix.node_type }}.yaml up -d echo EMQX_AUTH__REDIS__SSL=off >> "$GITHUB_ENV" - name: get server address run: | - set -exu ipv4_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' redis) ipv6_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' redis) cat <<-EOF >> "$GITHUB_ENV" @@ -318,7 +333,6 @@ jobs: - name: setup if: matrix.node_type == 'single' && matrix.connect_type == 'tcp' run: | - set -exu cat <<-EOF >> "$GITHUB_ENV" EMQX_AUTH__REDIS__TYPE=single EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:6379 @@ -326,7 +340,6 @@ jobs: - name: setup if: matrix.node_type == 'single' && matrix.connect_type == 'tls' run: | - set -exu cat <<-EOF >> "$GITHUB_ENV" EMQX_AUTH__REDIS__TYPE=single EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:6380 @@ -334,7 +347,6 @@ jobs: - name: setup if: matrix.node_type == 'cluster' && matrix.connect_type == 'tcp' run: | - set -exu cat <<-EOF >> "$GITHUB_ENV" EMQX_AUTH__REDIS__TYPE=cluster EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:7000 @@ -342,7 +354,6 @@ jobs: - name: setup if: matrix.node_type == 'cluster' && matrix.connect_type == 'tls' run: | - set -exu cat <<-EOF >> "$GITHUB_ENV" EMQX_AUTH__REDIS__TYPE=cluster EMQX_AUTH__REDIS__SERVER=${redis_${{ matrix.network_type }}_address}:8000 @@ -353,7 +364,12 @@ jobs: docker exec -i erlang bash -c "echo \"https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com\" > /root/.git-credentials && git config --global credential.helper store" fi - name: run test cases + timeout-minutes: 10 run: | + while ! nc -zv ${EMQX_AUTH__REDIS__SERVER%:*} ${EMQX_AUTH__REDIS__SERVER##*:} > /dev/null 2>&1; do + echo "waiting redis server" + sleep 1 + done export CUTTLEFISH_ENV_OVERRIDE_PREFIX=EMQX_ printenv > .env docker exec -i erlang sh -c "make ensure-rebar3" diff --git a/.github/workflows/run_test_cases.yaml b/.github/workflows/run_test_cases.yaml index 601c885e3..5f1c9e102 100644 --- a/.github/workflows/run_test_cases.yaml +++ b/.github/workflows/run_test_cases.yaml @@ -50,8 +50,14 @@ jobs: LDAP_TAG: 2.4.50 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - docker-compose -f .ci/apps_tests/docker-compose.yaml build --no-cache - docker-compose -f .ci/apps_tests/docker-compose.yaml up -d + docker-compose \ + -f .ci/docker-compose-file/docker-compose.yaml \ + -f .ci/docker-compose-file/docker-compose-ldap-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-mongo-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-mysql-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-pgsql-tcp.yaml \ + -f .ci/docker-compose-file/docker-compose-redis-single-tcp.yaml \ + up -d --build - name: docker compose up if: env.EDITION == 'enterprise' env: