docker GitHub操作-使用Neo4j服务依赖运行DotNetCore测试

cnh2zyt3  于 2024-01-06  发布在  Docker
关注(0)|答案(1)|浏览(116)

我需要一些关于在GitHub上运行集成测试的步骤的帮助。我的项目需要Neo4j,所以我将neo4j声明为服务。然而,在运行我的测试项目时,我看到以下错误

Connection with the server breaks due to ExtendedSocketException: 
Resource temporarily unavailable Please ensure that your database is listening on the correct 
host and port and that you have compatible encryption settings both on Neo4j server and driver. 
Note that the default encryption setting has changed in Neo4j 4.0.

字符串
我不确定这个问题是否与我如何指定操作或与Neo4j有关。
这是我的GitHub CI文件:dotnetcore.yml

name: .NET Core

on:
  push:
    branches: [ master, GithubActions ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest

    env:
      NEO4J_HOST: neo4j

    # Service containers to run with `container-job`
    services:
      # Label used to access the service container
      neo4j:
        # Docker Hub image
        image: neo4j:4.0.1
        ports:                    
        - 7474:7474 # used for http
        - 7687:7687 # used for bolt
        env:       
          NEO4J_AUTH: neo4j/password  
          NEO4J_dbms_connector_http_advertised__address: "NEO4J_HOST:7687"
          NEO4J_dbms_connector_bolt_advertised__address: "NEO4J_HOST:7687"

    steps:
    - uses: actions/checkout@v2

    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 3.1.101

    - name: Install dependencies
      run: dotnet restore  ./src/BbcCorp.Neo4j.NeoGraphManager.sln

    - name: Build
      run: dotnet build --configuration Release --no-restore ./src/BbcCorp.Neo4j.NeoGraphManager.sln

    - name: Run Integration Tests 
      env:
        NEO4J_SERVER: NEO4J_HOST
      run: |
        cd ./src/BbcCorp.Neo4j.Tests
        docker ps
        dotnet test --no-restore --verbosity normal BbcCorp.Neo4j.Tests.csproj


我试图连接到:bolt://NEO4J_HOST:7687,但它只是不连接。
错误详细信息:

Using Neo4j Server NEO4J_HOST:7687 as neo4j/password
Error executing query. Connection with the server breaks due to ExtendedSocketException: Resource temporarily unavailable Please ensure that your database is listening on the correct host and port and that you have compatible encryption settings both on Neo4j server and driver. Note that the default encryption setting has changed in Neo4j 4.0.
[xUnit.net 00:00:00.83]     NeoGraphManagerIntegrationTests.SimpleNodeTests [FAIL]
[xUnit.net 00:00:00.83]       Neo4j.Driver.ServiceUnavailableException : Connection with the server breaks due to ExtendedSocketException: Resource temporarily unavailable Please ensure that your database is listening on the correct host and port and that you have compatible encryption settings both on Neo4j server and driver. Note that the default encryption setting has changed in Neo4j 4.0.
[xUnit.net 00:00:00.83]       ---- System.Net.Internals.SocketExceptionFactory+ExtendedSocketException : Resource temporarily unavailable


C#测试项目的设置文件如下所示

{
    "NEO4J_SERVER": "localhost",
    "NEO4J_PORT": 7687,
    "NEO4J_DB_USER": "neo4j",
    "NEO4J_DB_PWD": "password"
}


测试在我的本地机器上运行良好,但在GitHub上执行时失败。

watbbzwu

watbbzwu1#

今天我在为我的开源项目设置github action,在到处搜索之后,我找到了一个适合我的解决方案。
对我来说,这是与此代码在创建服务时,我配置它做测试,这就是我需要它。我希望它可以帮助你。

name: SonarCloud
on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened]

env:  
  NEO4J_USER: neo4j
  NEO4J_PASSWORD: neo4jSocial
  JAVA_VERSION: 21
    
jobs:
  build:
    name: Build and analyze
    runs-on: ubuntu-latest
    services:
      neo4j:
        image: neo4j:5.15.0-enterprise
        env:
          NEO4J_dbms_security_procedures_unrestricted: apoc.*
          NEO4J_dbms_connector_bolt_enabled: "true"
          NEO4J_apoc_import_file_enabled: "true"
          NEO4J_apoc_export_file_enabled: "true"
          NEO4J_apoc_import_file_use__neo4j__config: "true"
          NEO4J_ACCEPT_LICENSE_AGREEMENT: "yes"
          NEO4J_dbms_security_auth__enabled: "false"
          NEO4J_dbms_connector_bolt_advertised__address: localhost:7687
          NEO4JLABS_PLUGINS: '["apoc"]'
          NEO4J_AUTH: ${{ env.NEO4J_USER }}/${{ env.NEO4J_PASSWORD }}
        options: >-
          --health-cmd "cypher-shell 'match (n) return count(n)'"
          --health-timeout 10s
          --health-retries 20
          --health-interval 10s
          --health-start-period 30s
        ports:
          - 7687:7687
                
    steps:

字符串
如果您仍然有问题,我邀请您查看此出版物,这是另一种方法,但使用auraDB https://neo4j.com/developer-blog/neo4j-integration-tests-github-actions-aura-cli/

相关问题