{"id":207365,"date":"2025-07-08T12:13:15","date_gmt":"2025-07-08T04:13:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/207365\/"},"modified":"2025-07-08T12:13:15","modified_gmt":"2025-07-08T04:13:15","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-github-actions-%e4%b8%8a%e5%b0%86-aerospike-%e4%b8%8e-testcontainers-%e4%b8%80%e8%b5%b7%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/207365\/","title":{"rendered":"\u5982\u4f55\u5728 github actions \u4e0a\u5c06 aerospike \u4e0e testcontainers \u4e00\u8d77\u4f7f\u7528"},"content":{"rendered":"<p><b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>\u5982\u4f55\u5728 github actions \u4e0a\u5c06 aerospike \u4e0e testcontainers \u4e00\u8d77\u4f7f\u7528<\/span><\/p>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-04-21 23:00:36<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u77e5\u8bc6\u70b9\u638c\u63e1\u4e86\uff0c\u8fd8\u9700\u8981\u4e0d\u65ad\u7ec3\u4e60\u624d\u80fd\u719f\u7ec3\u8fd0\u7528\u3002\u4e0b\u9762\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u4e2aGolang\u5f00\u53d1\u5b9e\u6218\uff0c\u624b\u628a\u624b\u6559\u5927\u5bb6\u5b66\u4e60\u300a\u5982\u4f55\u5728 github actions \u4e0a\u5c06 aerospike \u4e0e testcontainers \u4e00\u8d77\u4f7f\u7528\u300b\uff0c\u5728\u5b9e\u73b0\u529f\u80fd\u7684\u8fc7\u7a0b\u4e2d\u4e5f\u5e26\u5927\u5bb6\u91cd\u65b0\u6e29\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u6e29\u6545\u800c\u77e5\u65b0\uff0c\u56de\u5934\u770b\u770b\u8bf4\u4e0d\u5b9a\u53c8\u6709\u4e0d\u4e00\u6837\u7684\u611f\u609f\uff01<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u6211\u6b63\u5728\u5c1d\u8bd5\u4f7f\u7528 github \u64cd\u4f5c\u5728 testcontainers \u4e0a\u8fd0\u884c aerospike\uff0c<\/p>\n<p>\u5f53\u6211\u5728 github \u64cd\u4f5c\u4e0a\u8fd0\u884c\u6b64\u64cd\u4f5c\u65f6\uff0c\u6211\u6709\u65f6\u4f1a\u6536\u5230\u9519\u8bef\uff0c\u6709\u65f6\u5219\u4e0d\u4f1a\uff0c\u6211\u6536\u5230\u7684\u9519\u8bef\u5982\u4e0b\uff0c<\/p>\n<pre>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: &lt;nil&gt;: failed to connect to hosts: [127.0.0.1:32772]<\/pre>\n<p>\u6211\u7684 aerospike \u914d\u7f6e\u5982\u4e0b\uff0c<\/p>\n<pre>service {\n    user root\n    group root\n    # number of nodes where the replica count is automatically reduced to 1.\n    # paxos-single-replica-limit 1\n    # pidfile \/var\/run\/aerospike\/asd.pid\n    proto-fd-max 15000\n    query-threads-limit 100\n}\n\nlogging {\n    # log file must be an absolute path.\n    file ${logfile} {\n        context any critical\n    }\n\n    # send log messages to stdout\n    console {\n        context any info\n    }\n}\n\nnetwork {\n    service {\n        address any\n        port 3000\n\n        # uncomment the following to set the `access-address` parameter to the\n        # ip address of the docker host. this will the allow the server to correctly\n        # publish the address which applications and other nodes in the cluster to\n        # use when addressing this node.\n        # access-address &lt;ipaddr&gt;\n    }\n\n    heartbeat {\n        address any\n        # mesh is used for environments that do not support multicast\n        mode mesh\n        port 3002\n\n        # use asinfo -v 'tip:host=&lt;addr&gt;;port=3002' to inform cluster of\n        # other mesh nodes\n\n        interval 150\n        timeout 10\n    }\n\n    fabric {\n        address any\n        port 3001 \n    }\n}\n\nnamespace persistent00 {\n  replication-factor 1\n  memory-size 20m\n  storage-engine memory\n  nsup-period 86400\n}<\/pre>\n<p>\u8fd9\u5c31\u662f\u6211\u901a\u8fc7\u4f7f\u7528\u6d4b\u8bd5\u5bb9\u5668\u8fdb\u884c\u8fde\u63a5\u7684\u65b9\u5f0f\uff0c<\/p>\n<pre>func startContainer(ctx context.Context) (*aerospikeContainer, error) {\n    req := testcontainers.ContainerRequest{\n        Image:        \"aerospike\/aerospike-server:6.2.0.12\",\n        ExposedPorts: []string{\"3000\/tcp\", \"3001\/tcp\", \"3002\/tcp\"},\n        Files: []testcontainers.ContainerFile{\n            {\n                HostFilePath:      \"aerospike.conf\",\n                ContainerFilePath: \"aerospike.conf\",\n            },\n        },\n        Cmd: []string{\"--config-file\", \"aerospike.conf\"},\n        WaitingFor: wait.ForAll(\n            wait.ForListeningPort(\"3000\/tcp\"),\n            wait.ForLog(\"{persistent00} migrations: complete\").WithOccurrence(2),\n        ),\n    }\n\n    container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{\n        ContainerRequest: req,\n        Started:          true,\n    })\n    if err != nil {\n        return nil, err\n    }\n\n    return &amp;aerospikeContainer{Container: container}, nil\n}<\/pre>\n<p>\u6211\u5e94\u8be5\u600e\u4e48\u505a\u624d\u80fd\u8ba9\u5b83\u53d1\u6325\u4f5c\u7528\uff1f<\/p>\n<p>\u6211\u5c1d\u8bd5\u4f7f\u7528\u5fc3\u8df3\u5e76\u589e\u52a0\u4e86 <code>withoccurence<\/code> \u4f46\u5b83\u4f3c\u4e4e\u4ecd\u7136\u4e0d\u8d77\u4f5c\u7528<\/p>\n<p> <\/p>\n<h2>\u6b63\u786e\u7b54\u6848<\/h2>\n<p> <\/p>\n<p>\u6b64\u5e16\u5b50\u5efa\u8bae\u5728\u9047\u5230 <code>INVALID_NODE_ERROR<\/code>: \u65f6\u5c06\u5ba2\u6237\u7aef\uff08\u5728\u60a8\u7684\u60c5\u51b5\u4e0b\u4e3a Go \u5ba2\u6237\u7aef\uff09\u5347\u7ea7\u5230\u6700\u65b0\u7248\u672c<\/p>\n<p>JDogMcSteezy \u7684\u8bc4\u8bba\u662f\u6709\u9053\u7406\u7684\uff0c\u5982\u679c\u5b83\u6709\u65f6\u53d1\u751f\u800c\u4e0d\u662f\u603b\u662f\u53d1\u751f\uff08\u5ba2\u6237\u7aef\u5728 Aerospike \u53ef\u8fbe\u4e4b\u524d\u5c1d\u8bd5\u8fde\u63a5\u5230 Aerospike\uff09\uff0c<code>waitingFor<\/code> \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5e94\u8be5\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u6211\u5bf9 Go \u4e0d\u719f\u6089\uff0c\u4f46\u60a8\u53ef\u4ee5\u5728\u6b64\u5904\u770b\u5230\u4e00\u4e2a\u5c06 Aerospike \u4e0e testcontainers \u7ed3\u5408\u4f7f\u7528\u7684\u7a33\u5b9a Java \u793a\u4f8b\uff0c\u8be5\u793a\u4f8b\u5229\u7528 Playtika \u7684\u516c\u5171\u5e93\u5c06 testcontainers \u4e0e Aerospike \u7ed3\u5408\u4f7f\u7528\uff1a<\/p>\n<p>Playtika \u7684 testcontainers \u4f9d\u8d56\u9879\uff1a<\/p>\n<p>\u8fd9\u662f\u6d4b\u8bd5\u5bb9\u5668\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u9ed8\u8ba4\u53ea\u5305\u542bAerospike\u7684\u7248\u672c\uff1a<\/p>\n<p>\u8fd9\u662f\u6d4b\u8bd5\u4e2d\u7684\u914d\u7f6e\u7c7b\uff1a<\/p>\n<p>\u6587\u4e2d\u5173\u4e8e\u7684\u77e5\u8bc6\u4ecb\u7ecd\uff0c\u5e0c\u671b\u5bf9\u4f60\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff01\u82e5\u662f\u53d7\u76ca\u532a\u6d45\uff0c\u90a3\u5c31\u52a8\u52a8\u9f20\u6807\u6536\u85cf\u8fd9\u7bc7\u300a\u5982\u4f55\u5728 github actions \u4e0a\u5c06 aerospike \u4e0e testcontainers \u4e00\u8d77\u4f7f\u7528\u300b\u6587\u7ae0\u5427\uff0c\u4e5f\u53ef\u5173\u6ce8\u516c\u4f17\u53f7\u4e86\u89e3\u76f8\u5173\u6280\u672f\u6587\u7ae0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u4f4d\u7f6e\uff1a &gt; &gt; &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-207365","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=207365"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207365\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=207365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=207365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=207365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}