Go语言 如何在github actions上使用aerospike和testcontainers

lsmepo6l  于 2023-09-28  发布在  Go
关注(0)|答案(1)|浏览(139)

我正在尝试用github操作在testcontainers上运行aerospike,
我有时会得到一个错误,有时不会,当我在github上运行这个动作时,我得到的错误如下:

  1. integration_test.go:124: error getting aerospike client: error creating cluster client: aero client failed to connect to [127.0.0.1]:32772 timeout:10s: ResultCode: INVALID_NODE_ERROR, Iteration: 0, InDoubt: false, Node: <nil>: Failed to connect to hosts: [127.0.0.1:32772]

下面是我的气刺式配置

  1. service {
  2. user root
  3. group root
  4. # Number of nodes where the replica count is automatically reduced to 1.
  5. # paxos-single-replica-limit 1
  6. # pidfile /var/run/aerospike/asd.pid
  7. proto-fd-max 15000
  8. query-threads-limit 100
  9. }
  10. logging {
  11. # Log file must be an absolute path.
  12. file ${LOGFILE} {
  13. context any critical
  14. }
  15. # Send log messages to stdout
  16. console {
  17. context any info
  18. }
  19. }
  20. network {
  21. service {
  22. address any
  23. port 3000
  24. # Uncomment the following to set the `access-address` parameter to the
  25. # IP address of the Docker host. This will the allow the server to correctly
  26. # publish the address which applications and other nodes in the cluster to
  27. # use when addressing this node.
  28. # access-address <IPADDR>
  29. }
  30. heartbeat {
  31. address any
  32. # mesh is used for environments that do not support multicast
  33. mode mesh
  34. port 3002
  35. # use asinfo -v 'tip:host=<ADDR>;port=3002' to inform cluster of
  36. # other mesh nodes
  37. interval 150
  38. timeout 10
  39. }
  40. fabric {
  41. address any
  42. port 3001
  43. }
  44. }
  45. namespace persistent00 {
  46. replication-factor 1
  47. memory-size 20M
  48. storage-engine memory
  49. nsup-period 86400
  50. }

这是我如何通过使用测试容器进行连接

  1. func startContainer(ctx context.Context) (*aerospikeContainer, error) {
  2. req := testcontainers.ContainerRequest{
  3. Image: "aerospike/aerospike-server:6.2.0.12",
  4. ExposedPorts: []string{"3000/tcp", "3001/tcp", "3002/tcp"},
  5. Files: []testcontainers.ContainerFile{
  6. {
  7. HostFilePath: "aerospike.conf",
  8. ContainerFilePath: "aerospike.conf",
  9. },
  10. },
  11. Cmd: []string{"--config-file", "aerospike.conf"},
  12. WaitingFor: wait.ForAll(
  13. wait.ForListeningPort("3000/tcp"),
  14. wait.ForLog("{persistent00} migrations: complete").WithOccurrence(2),
  15. ),
  16. }
  17. container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
  18. ContainerRequest: req,
  19. Started: true,
  20. })
  21. if err != nil {
  22. return nil, err
  23. }
  24. return &aerospikeContainer{Container: container}, nil
  25. }

我该怎么做才能让它工作?
我尝试使用心跳和增加withOccurence,但它似乎仍然不工作

egmofgnx

egmofgnx1#

此线程建议在遇到INVALID_NODE_ERROR时将客户端(在您的情况下是Go客户端)升级到最新版本:https://discuss.aerospike.com/t/invalid-node-error-code-3-after-some-writes/6037/9
JDogMcSteezy的评论是有意义的,如果它有时发生,而不是总是发生(客户端试图连接到Aerospike之前,Aerospike是可达的),waitingFor应该在这种情况下有所帮助。
我不熟悉Go语言,但你可以在这里看到一个使用Aerospike和testcontainers的稳定Java示例,它利用Playtika的公共库来使用Aerospike和testcontainers:https://github.com/aerospike/spring-data-aerospike
Playtika的testcontainers依赖:https://github.com/aerospike/spring-data-aerospike/blob/main/pom.xml#L256
这是testcontainers的配置文件,默认情况下只包含Aerospike的版本:https://github.com/aerospike/spring-data-aerospike/blob/main/src/test/resources/bootstrap.properties
这是测试中的配置类:https://github.com/aerospike/spring-data-aerospike/blob/main/src/test/java/org/springframework/data/aerospike/config/BlockingTestConfig.java#L30

相关问题