如何在 M1 Mac 上运行 querydsl 项目测试?

Posted

技术标签:

【中文标题】如何在 M1 Mac 上运行 querydsl 项目测试?【英文标题】:how do I run querydsl project tests on an M1 Mac? 【发布时间】:2021-12-22 16:53:20 【问题描述】:

我正在尝试在 Github (https://github.com/querydsl/querydsl) 上运行 querydsl 项目的测试套件。按照说明进行构建(我使用“所有”配置文件构建)后,我安装了 Docker 和 docker-compose,但是当我根据说明运行 docker-compose up -d 时收到错误消息。

This is the output from running the command, with errors

我用谷歌搜索了关于 linux/arm64/v8 的错误消息,但还没有解决这个错误。

为了让测试套件在 Mac 上运行,我应该遵循什么其他具体步骤吗?

docker-compose.yml:

version: "2.4"
services:
  # Provides an easy way to ensure slow-starting databases are ready when the tests run
  block-until-healthy:
    image: alpine:latest
    depends_on:
      cubrid:
        condition: service_healthy
      db2:
        condition: service_healthy
      sqlserver:
        condition: service_healthy

  mysql:
    image: mysql:5.6.38
    ports:
      - "3306:3306"
    volumes:
      - ./db/mysql.sh:/docker-entrypoint-initdb.d/mysql.sh
    environment:
      - MYSQL_ROOT_PASSWORD=querydsl
      - MYSQL_USER=querydsl
      - MYSQL_PASSWORD=querydsl

  postgresql:
    image: mdillon/postgis:9.3-alpine
    ports:
      - "5433:5432"
    volumes:
      - ./db/postgresql.sql:/docker-entrypoint-initdb.d/postgresql.sql
    environment:
      - POSTGRES_USER=querydsl
      - POSTGRES_PASSWORD=querydsl
      - POSTGRES_DB=querydsl

  oracle:
    image: wnameless/oracle-xe-11g-r2:latest
    ports:
      - "1521:1521"
    volumes:
    - "./devops/sql-snippets/oracle.sql:/docker-entrypoint-initdb.d/oracle.sql"

  cubrid:
    image: lighthopper/cubrid:9.2.26.0004
    command: "./create-start-demodb.sh"
    ports:
      - "33000:33000"
      - "30000:30000"
      - "8001:8001"
      - "8002:8002"
      - "1523:1523"
    healthcheck:
      test: csql demodb -c "SELECT 1"
      interval: 5s
      timeout: 60s
      start_period: 60s

  mongo:
    image: mongo:3.6.1
    ports:
      - "27017:27017"

  db2:
    image: ibmcom/db2:11.5.0.0
    privileged: true
    ports:
      - "50000:50000"
    environment:
      - DB2INST1_PASSWORD=a3sd!fDj
      - DB2INSTANCE=db2inst1
      - DBNAME=sample
      - LICENSE=accept
      - ARCHIVE_LOGS=false
      - AUTOCONFIG=false
    healthcheck:
      test: /opt/ibm/db2/V11.5/bin/db2 CONNECT TO $$DBNAME
      interval: 5s
      timeout: 240s
      start_period: 240s

  sqlserver:
    image: mcr.microsoft.com/mssql/server:2017-latest-ubuntu
    environment:
      - ACCEPT_EULA=Y
      - SA_PASSWORD=Password1!
      - MSSQL_PID=Express
    ports:
      - "1433:1433"
    healthcheck:
      test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$$SA_PASSWORD" -Q "SELECT 1" || exit 1
      interval: 5s
      timeout: 60s
      start_period: 60s

  firebird:
    image: jacobalberty/firebird:2.5.9-ss
    ports:
      - "3050:3050"
    environment:
      - ISC_PASSWORD=masterkey
      - FIREBIRD_DATABASE=querydsl.fdb
      - FIREBIRD_USER=querydsl
      - FIREBIRD_PASSWORD=querydsl

【问题讨论】:

发布你的 docker compose @bananas 已发布,谢谢 【参考方案1】:

我可以通过在每个部分下的 docker-compose.yml 文件中添加 platform: "linux/x86_64" 来实现此功能。

我的完整文件现在如下所示:

version: "2.4"
services:
  # Provides an easy way to ensure slow-starting databases are ready when the tests run
  block-until-healthy:
    image: alpine:latest
    depends_on:
      cubrid:
        condition: service_healthy
      db2:
        condition: service_healthy
      sqlserver:
        condition: service_healthy

  mysql:
    image: mysql:5.6.38
    ports:
      - "3306:3306"
    volumes:
      - ./db/mysql.sh:/docker-entrypoint-initdb.d/mysql.sh
    environment:
      - MYSQL_ROOT_PASSWORD=querydsl
      - MYSQL_USER=querydsl
      - MYSQL_PASSWORD=querydsl
    platform: "linux/x86_64"

  postgresql:
    image: mdillon/postgis:9.3-alpine
    ports:
      - "5433:5432"
    volumes:
      - ./db/postgresql.sql:/docker-entrypoint-initdb.d/postgresql.sql
    environment:
      - POSTGRES_USER=querydsl
      - POSTGRES_PASSWORD=querydsl
      - POSTGRES_DB=querydsl
    platform: "linux/x86_64"

  oracle:
    image: wnameless/oracle-xe-11g-r2:latest
    ports:
      - "1521:1521"
    volumes:
    - "./devops/sql-snippets/oracle.sql:/docker-entrypoint-initdb.d/oracle.sql"
    platform: "linux/x86_64"

  cubrid:
    image: lighthopper/cubrid:9.2.26.0004
    command: "./create-start-demodb.sh"
    ports:
      - "33000:33000"
      - "30000:30000"
      - "8001:8001"
      - "8002:8002"
      - "1523:1523"
    healthcheck:
      test: csql demodb -c "SELECT 1"
      interval: 5s
      timeout: 60s
      start_period: 60s
    platform: "linux/x86_64"

  mongo:
    image: mongo:3.6.1
    ports:
      - "27017:27017"
    platform: "linux/x86_64"

  db2:
    image: ibmcom/db2:11.5.0.0
    privileged: true
    ports:
      - "50000:50000"
    environment:
      - DB2INST1_PASSWORD=a3sd!fDj
      - DB2INSTANCE=db2inst1
      - DBNAME=sample
      - LICENSE=accept
      - ARCHIVE_LOGS=false
      - AUTOCONFIG=false
    healthcheck:
      test: /opt/ibm/db2/V11.5/bin/db2 CONNECT TO $$DBNAME
      interval: 5s
      timeout: 240s
      start_period: 240s
    platform: "linux/x86_64"

  sqlserver:
    image: mcr.microsoft.com/mssql/server:2017-latest-ubuntu
    environment:
      - ACCEPT_EULA=Y
      - SA_PASSWORD=Password1!
      - MSSQL_PID=Express
    ports:
      - "1433:1433"
    healthcheck:
      test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$$SA_PASSWORD" -Q "SELECT 1" || exit 1
      interval: 5s
      timeout: 60s
      start_period: 60s
    platform: "linux/x86_64"

  firebird:
    image: jacobalberty/firebird:2.5.9-ss
    ports:
      - "3050:3050"
    environment:
      - ISC_PASSWORD=masterkey
      - FIREBIRD_DATABASE=querydsl.fdb
      - FIREBIRD_USER=querydsl
      - FIREBIRD_PASSWORD=querydsl
    platform: "linux/x86_64"

【讨论】:

以上是关于如何在 M1 Mac 上运行 querydsl 项目测试?的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 M1 芯片在我的 Mac 上运行 pyqt5

跳过 R 中 M1mac 的测试

在 M1 Mac 上运行 Flutter Doctor 时出错 - 无法找到捆绑的 Java 版本

如何在 mac M1(Apple 芯片)上使用 google_sign_in api 进行开发

Firebase 在 M1 Mac 上损坏

Cocoapods 无法在新的 m1 mac Big Sur Xcode 上运行