From 23e2ba6c14c1fa3720d851e9662b20389ca2b3cb Mon Sep 17 00:00:00 2001 From: Aiee <18348405+Aiee@users.noreply.github.com> Date: Thu, 6 Jan 2022 11:10:56 +0800 Subject: [PATCH 1/4] Add console retry in the action --- .github/workflows/test.yaml | 2 ++ nebula-docker-compose/docker-compose.yaml | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 20dfa43c..21419bd9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -36,10 +36,12 @@ jobs: - name: Test SSL connection with CA run: | make up-ssl + sleep 10 make ssl-test - name: Test SSL connection self-signed run: | make up-ssl + sleep 10 make ssl-test-self-signed - name: down if: always() diff --git a/nebula-docker-compose/docker-compose.yaml b/nebula-docker-compose/docker-compose.yaml index 8429d68d..790758d5 100644 --- a/nebula-docker-compose/docker-compose.yaml +++ b/nebula-docker-compose/docker-compose.yaml @@ -417,9 +417,14 @@ services: - sh - -c - | - sleep 3 && - nebula-console -addr graphd -port 3699 -u root -p nebula -e 'ADD HOSTS "storaged0":44500,"storaged1":44500,"storaged2":44500' && - sleep 36000 + for i in `seq 1 60`;do + var=`nebula-console -addr graphd -port 3699 -u root -p nebula -e 'ADD HOSTS "storaged0":44500,"storaged1":44500,"storaged2":44500'`; + if [[ $$? == 0 ]];then + break; + fi; + sleep 1; + echo "retry to add hosts."; + done && tail -f /dev/null; depends_on: - graphd networks: From 1dc2478be951746573f21d32b2b46caaa3a271e8 Mon Sep 17 00:00:00 2001 From: jievince <38901892+jievince@users.noreply.github.com> Date: Thu, 30 Dec 2021 16:40:14 +0800 Subject: [PATCH 2/4] change toString of duration --- client_test.go | 12 ++++++------ result_set_test.go | 2 +- value_wrapper.go | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/client_test.go b/client_test.go index be38745a..60146324 100644 --- a/client_test.go +++ b/client_test.go @@ -193,7 +193,7 @@ func TestAuthentication(t *testing.T) { defer conn.close() _, authErr := conn.authenticate(username, password) - assert.EqualError(t, authErr, "fail to authenticate, error: Bad username/password") + assert.EqualError(t, authErr, "fail to authenticate, error: User not exist") } func TestInvalidHostTimeout(t *testing.T) { @@ -369,7 +369,7 @@ func TestServiceDataIO(t *testing.T) { return } assert.Equal(t, - "(\"Bob\" :student{interval: P12M0DT0S, name: \"Bob\"} "+ + "(\"Bob\" :student{interval: P1MT100.000020000S, name: \"Bob\"} "+ ":person{age: 10, birthday: 2010-09-10T10:08:02.000000, book_num: 100, "+ "child_name: \"Hello Worl\", expend: 100.0, "+ "first_out_city: 1111, friends: 10, grade: 3, "+ @@ -929,7 +929,7 @@ func TestExecuteJson(t *testing.T) { "person.property": float64(1000), "person.start_school": `2017-09-10`, "student.name": "Bob", - "student.interval": `P12M0DT0S`, + "student.interval": `P1MT100.000020000S`, }, } @@ -1066,7 +1066,7 @@ func TestExecuteWithParameter(t *testing.T) { } // Complex result { - resp, err := tryToExecuteWithParameter(session, "MATCH (v:person {name: $p4.b}) WHERE v.age>$p2-3 and $p1==true RETURN v ORDER BY $p3[0] LIMIT $p2", params) + resp, err := tryToExecuteWithParameter(session, "MATCH (v:person {name: $p4.b}) WHERE v.person.age>$p2-3 and $p1==true RETURN v ORDER BY $p3[0] LIMIT $p2", params) if err != nil { t.Fatalf(err.Error()) return @@ -1088,7 +1088,7 @@ func TestExecuteWithParameter(t *testing.T) { return } assert.Equal(t, - "(\"Bob\" :student{interval: P12M0DT0S, name: \"Bob\"} "+ + "(\"Bob\" :student{interval: P1MT100.000020000S, name: \"Bob\"} "+ ":person{age: 10, birthday: 2010-09-10T10:08:02.000000, book_num: 100, "+ "child_name: \"Hello Worl\", expend: 100.0, "+ "first_out_city: 1111, friends: 10, grade: 3, "+ @@ -1275,7 +1275,7 @@ func loadTestData(t *testing.T, session *Session) { query = "INSERT VERTEX student(name, interval) VALUES " + - "'Bob':('Bob', duration({years: 1, seconds: 0})), 'Lily':('Lily', duration({years: 1, seconds: 0})), " + + "'Bob':('Bob', duration({months:1, seconds:100, microseconds:20})), 'Lily':('Lily', duration({years: 1, seconds: 0})), " + "'Tom':('Tom', duration({years: 1, seconds: 0})), 'Jerry':('Jerry', duration({years: 1, seconds: 0})), 'John':('John', duration({years: 1, seconds: 0}))" resultSet, err = tryToExecute(session, query) if err != nil { diff --git a/result_set_test.go b/result_set_test.go index 25358ccb..5616e99b 100644 --- a/result_set_test.go +++ b/result_set_test.go @@ -423,7 +423,7 @@ func TestAsDuration(t *testing.T) { value := nebula.Value{DuVal: &nebula.Duration{86400, 3000, 12}} valWrap := ValueWrapper{&value, testTimezone} assert.Equal(t, true, valWrap.IsDuration()) - assert.Equal(t, "P12M1DT86400S", valWrap.String()) + assert.Equal(t, "P12MT86400.003000000S", valWrap.String()) } func TestNode(t *testing.T) { vertex := getVertex("Tom", 3, 5) diff --git a/value_wrapper.go b/value_wrapper.go index c128b23e..9759783b 100644 --- a/value_wrapper.go +++ b/value_wrapper.go @@ -404,8 +404,10 @@ func (valWrap ValueWrapper) String() string { return toWKT(ggval) } else if value.IsSetDuVal() { duval := value.GetDuVal() - days := duval.GetSeconds() / (24 * 60 * 60) - return fmt.Sprintf("P%vM%vDT%vS", duval.GetMonths(), days, duval.GetSeconds()) + totalSeconds := duval.GetSeconds() + int64(duval.GetMicroseconds()) / 1000000; + remainMicroSeconds := duval.GetMicroseconds() % 1000000 + s := fmt.Sprintf("P%vMT%v.%06d000S", duval.GetMonths(), totalSeconds, remainMicroSeconds) + return s } else { // is empty return "" } From 2c078fa4711f2d0c219d2e47f724a91c745f103c Mon Sep 17 00:00:00 2001 From: Aiee <18348405+Aiee@users.noreply.github.com> Date: Thu, 6 Jan 2022 16:20:31 +0800 Subject: [PATCH 3/4] Add ssl config to console --- nebula-docker-compose/docker-compose-ssl.yaml | 434 ++++++++++++++++++ nebula-docker-compose/docker-compose.yaml | 3 +- value_wrapper.go | 2 +- 3 files changed, 436 insertions(+), 3 deletions(-) create mode 100644 nebula-docker-compose/docker-compose-ssl.yaml diff --git a/nebula-docker-compose/docker-compose-ssl.yaml b/nebula-docker-compose/docker-compose-ssl.yaml new file mode 100644 index 00000000..82ff701a --- /dev/null +++ b/nebula-docker-compose/docker-compose-ssl.yaml @@ -0,0 +1,434 @@ +version: '3.4' +services: + metad0: + image: vesoft/nebula-metad:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:45500,metad1:45500,metad2:45500 + - --local_ip=metad0 + - --ws_ip=metad0 + - --port=45500 + - --ws_http_port=11000 + - --data_path=/data/meta + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + - --timezone_name=+08:00 + - --heartbeat_interval_secs=1 + # ssl + - --ca_path=${ca_path} + - --cert_path=${cert_path} + - --key_path=${key_path} + - --enable_ssl=${enable_ssl} + - --password_path=${password_path} + healthcheck: + test: ["CMD", "curl", "-sf", "http://metad0:11000/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 45500 + - 11000 + - 11002 + volumes: + - ./secrets:/secrets + - ./data/meta0:/data/meta + - ./logs/meta0:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + metad1: + image: vesoft/nebula-metad:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:45500,metad1:45500,metad2:45500 + - --local_ip=metad1 + - --ws_ip=metad1 + - --port=45500 + - --ws_http_port=11000 + - --data_path=/data/meta + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + - --timezone_name=+08:00 + - --heartbeat_interval_secs=1 + # ssl + - --ca_path=${ca_path} + - --cert_path=${cert_path} + - --key_path=${key_path} + - --enable_ssl=${enable_ssl} + - --password_path=${password_path} + healthcheck: + test: ["CMD", "curl", "-sf", "http://metad1:11000/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 45500 + - 11000 + - 11002 + volumes: + - ./secrets:/secrets + - ./data/meta1:/data/meta + - ./logs/meta1:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + metad2: + image: vesoft/nebula-metad:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:45500,metad1:45500,metad2:45500 + - --local_ip=metad2 + - --ws_ip=metad2 + - --port=45500 + - --ws_http_port=11000 + - --data_path=/data/meta + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + - --timezone_name=+08:00 + - --heartbeat_interval_secs=1 + # ssl + - --ca_path=${ca_path} + - --cert_path=${cert_path} + - --key_path=${key_path} + - --enable_ssl=${enable_ssl} + - --password_path=${password_path} + healthcheck: + test: ["CMD", "curl", "-sf", "http://metad2:11000/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 45500 + - 11000 + - 11002 + volumes: + - ./secrets:/secrets + - ./data/meta2:/data/meta + - ./logs/meta2:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + storaged0: + image: vesoft/nebula-storaged:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:45500,metad1:45500,metad2:45500 + - --local_ip=storaged0 + - --ws_ip=storaged0 + - --port=44500 + - --ws_http_port=12000 + - --data_path=/data/storage + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + - --timezone_name=+08:00 + - --heartbeat_interval_secs=1 + # ssl + - --ca_path=${ca_path} + - --cert_path=${cert_path} + - --key_path=${key_path} + - --enable_ssl=${enable_ssl} + - --password_path=${password_path} + depends_on: + - metad0 + - metad1 + - metad2 + healthcheck: + test: ["CMD", "curl", "-sf", "http://storaged0:12000/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 44500 + - 12000 + - 12002 + volumes: + - ./secrets:/secrets + - ./data/storage0:/data/storage + - ./logs/storage0:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + storaged1: + image: vesoft/nebula-storaged:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:45500,metad1:45500,metad2:45500 + - --local_ip=storaged1 + - --ws_ip=storaged1 + - --port=44500 + - --ws_http_port=12000 + - --data_path=/data/storage + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + - --timezone_name=+08:00 + - --heartbeat_interval_secs=1 + # ssl + - --ca_path=${ca_path} + - --cert_path=${cert_path} + - --key_path=${key_path} + - --enable_ssl=${enable_ssl} + - --password_path=${password_path} + depends_on: + - metad0 + - metad1 + - metad2 + healthcheck: + test: ["CMD", "curl", "-sf", "http://storaged1:12000/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 44500 + - 12000 + - 12002 + volumes: + - ./secrets:/secrets + - ./data/storage1:/data/storage + - ./logs/storage1:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + storaged2: + image: vesoft/nebula-storaged:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:45500,metad1:45500,metad2:45500 + - --local_ip=storaged2 + - --ws_ip=storaged2 + - --port=44500 + - --ws_http_port=12000 + - --data_path=/data/storage + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + - --timezone_name=+08:00 + - --heartbeat_interval_secs=1 + # ssl + - --ca_path=${ca_path} + - --cert_path=${cert_path} + - --key_path=${key_path} + - --enable_ssl=${enable_ssl} + - --password_path=${password_path} + depends_on: + - metad0 + - metad1 + - metad2 + healthcheck: + test: ["CMD", "curl", "-sf", "http://storaged2:12000/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 44500 + - 12000 + - 12002 + volumes: + - ./secrets:/secrets + - ./data/storage2:/data/storage + - ./logs/storage2:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + graphd: + image: vesoft/nebula-graphd:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:45500,metad1:45500,metad2:45500 + - --port=3699 + - --ws_ip=graphd + - --ws_http_port=13000 + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + - --enable_authorize=true + - --timezone_name=+08:00 + - --system_memory_high_watermark_ratio=0.99 + - --heartbeat_interval_secs=1 + # ssl + - --ca_path=${ca_path} + - --cert_path=${cert_path} + - --key_path=${key_path} + - --enable_ssl=${enable_ssl} + - --password_path=${password_path} + depends_on: + - metad0 + - metad1 + - metad2 + healthcheck: + test: ["CMD", "curl", "-sf", "http://graphd:13000/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - "3699:3699" + - 13000 + - 13002 + volumes: + - ./secrets:/secrets + - ./logs/graph:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + graphd1: + image: vesoft/nebula-graphd:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:45500,metad1:45500,metad2:45500 + - --port=3699 + - --ws_ip=graphd1 + - --ws_http_port=13000 + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + - --enable_authorize=true + - --timezone_name=+08:00 + - --system_memory_high_watermark_ratio=0.99 + - --heartbeat_interval_secs=1 + # ssl + - --ca_path=${ca_path} + - --cert_path=${cert_path} + - --key_path=${key_path} + - --enable_ssl=${enable_ssl} + - --password_path=${password_path} + depends_on: + - metad0 + - metad1 + - metad2 + healthcheck: + test: ["CMD", "curl", "-sf", "http://graphd1:13000/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - "3700:3699" + - 13000 + - 13002 + volumes: + - ./secrets:/secrets + - ./logs/graph1:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + graphd2: + image: vesoft/nebula-graphd:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:45500,metad1:45500,metad2:45500 + - --port=3699 + - --ws_ip=graphd2 + - --ws_http_port=13000 + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + - --enable_authorize=true + - --timezone_name=+08:00 + - --system_memory_high_watermark_ratio=0.99 + - --heartbeat_interval_secs=1 + # ssl + - --ca_path=${ca_path} + - --cert_path=${cert_path} + - --key_path=${key_path} + - --enable_ssl=${enable_ssl} + - --password_path=${password_path} + + + depends_on: + - metad0 + - metad1 + - metad2 + healthcheck: + test: ["CMD", "curl", "-sf", "http://graphd2:13000/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - "3701:3699" + - 13000 + - 13002 + volumes: + - ./secrets:/secrets + - ./logs/graph2:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + console: + image: vesoft/nebula-console:nightly + entrypoint: "" + command: + - sh + - -c + - | + for i in `seq 1 60`;do + var=`nebula-console -addr graphd -port 3699 -u root -p nebula -enable_ssl=true -ssl_root_ca_path /secrets/test.ca.pem -ssl_cert_path /secrets/test.client.crt -ssl_private_key_path /secrets/test.client.key --ssl_insecure_skip_verify=true -e 'ADD HOSTS "storaged0":44500,"storaged1":44500,"storaged2":44500'`; + if [[ $$? == 0 ]];then + break; + fi; + sleep 1; + echo "retry to add hosts."; + done && tail -f /dev/null; + depends_on: + - graphd + networks: + - nebula-net + +networks: + nebula-net: diff --git a/nebula-docker-compose/docker-compose.yaml b/nebula-docker-compose/docker-compose.yaml index 790758d5..f1a08bcb 100644 --- a/nebula-docker-compose/docker-compose.yaml +++ b/nebula-docker-compose/docker-compose.yaml @@ -418,8 +418,7 @@ services: - -c - | for i in `seq 1 60`;do - var=`nebula-console -addr graphd -port 3699 -u root -p nebula -e 'ADD HOSTS "storaged0":44500,"storaged1":44500,"storaged2":44500'`; - if [[ $$? == 0 ]];then + var=`nebula-console -addr graphd -port 3699 -u root -p nebula -e 'ADD HOSTS "storaged0":44500,"storaged1":44500,"storaged2":44500'`; if [[ $$? == 0 ]];then break; fi; sleep 1; diff --git a/value_wrapper.go b/value_wrapper.go index 9759783b..e63c2227 100644 --- a/value_wrapper.go +++ b/value_wrapper.go @@ -404,7 +404,7 @@ func (valWrap ValueWrapper) String() string { return toWKT(ggval) } else if value.IsSetDuVal() { duval := value.GetDuVal() - totalSeconds := duval.GetSeconds() + int64(duval.GetMicroseconds()) / 1000000; + totalSeconds := duval.GetSeconds() + int64(duval.GetMicroseconds())/1000000 remainMicroSeconds := duval.GetMicroseconds() % 1000000 s := fmt.Sprintf("P%vMT%v.%06d000S", duval.GetMonths(), totalSeconds, remainMicroSeconds) return s From e6abc3feb5ac5c5ab7d98f6727d4f39d57eecead Mon Sep 17 00:00:00 2001 From: Aiee <18348405+Aiee@users.noreply.github.com> Date: Mon, 10 Jan 2022 15:30:05 +0800 Subject: [PATCH 4/4] Add another yaml file --- Makefile | 5 +---- nebula-docker-compose/docker-compose-ssl.yaml | 4 ++++ nebula-docker-compose/docker-compose.yaml | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 98feae01..d1a8ffeb 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ up: cd ./nebula-docker-compose && docker-compose up -d up-ssl: - cd ./nebula-docker-compose && enable_ssl=true docker-compose up -d + cd ./nebula-docker-compose && enable_ssl=true docker-compose -f docker-compose-ssl.yaml up -d down: cd ./nebula-docker-compose && docker-compose down -v @@ -25,9 +25,6 @@ ssl-test: ssl_test=true go test -v -run TestSslConnection; ssl-test-self-signed: - cd ./nebula-docker-compose && enable_ssl=true docker-compose up -d && \ - sleep 10 && \ - cd .. && \ self_signed=true go test -v -run TestSslConnection; run-examples: diff --git a/nebula-docker-compose/docker-compose-ssl.yaml b/nebula-docker-compose/docker-compose-ssl.yaml index 82ff701a..1b5682ae 100644 --- a/nebula-docker-compose/docker-compose-ssl.yaml +++ b/nebula-docker-compose/docker-compose-ssl.yaml @@ -418,13 +418,17 @@ services: - -c - | for i in `seq 1 60`;do + echo "Adding hosts..." var=`nebula-console -addr graphd -port 3699 -u root -p nebula -enable_ssl=true -ssl_root_ca_path /secrets/test.ca.pem -ssl_cert_path /secrets/test.client.crt -ssl_private_key_path /secrets/test.client.key --ssl_insecure_skip_verify=true -e 'ADD HOSTS "storaged0":44500,"storaged1":44500,"storaged2":44500'`; if [[ $$? == 0 ]];then + echo "Hosts added successfully" break; fi; sleep 1; echo "retry to add hosts."; done && tail -f /dev/null; + volumes: + - ./secrets:/secrets depends_on: - graphd networks: diff --git a/nebula-docker-compose/docker-compose.yaml b/nebula-docker-compose/docker-compose.yaml index f1a08bcb..790758d5 100644 --- a/nebula-docker-compose/docker-compose.yaml +++ b/nebula-docker-compose/docker-compose.yaml @@ -418,7 +418,8 @@ services: - -c - | for i in `seq 1 60`;do - var=`nebula-console -addr graphd -port 3699 -u root -p nebula -e 'ADD HOSTS "storaged0":44500,"storaged1":44500,"storaged2":44500'`; if [[ $$? == 0 ]];then + var=`nebula-console -addr graphd -port 3699 -u root -p nebula -e 'ADD HOSTS "storaged0":44500,"storaged1":44500,"storaged2":44500'`; + if [[ $$? == 0 ]];then break; fi; sleep 1;