CentaurusInfra / global-resource-service

Apache License 2.0
0 stars 4 forks source link

Merge PR167 and PR171 about Redis changes into simulator-list-watch branch #180

Closed q131172019 closed 2 years ago

q131172019 commented 2 years ago

This PR is same as PR179 which has been approved, only difference is the codes are pushed from personal branch q131172019/GRS:Carl_Merge_PR167_and_PR171_Into_simulator-list-watch.

This PR is to merge PR167 and PR171 into simulator-list-watch branch to be convenient for integration test

PR167 - Should not flushall redis DB when service API starts PR171 - Change Redis default port 6379 to new port flexibly

UT test:

ubuntu@ip-172-31-8-82:~/go/src/GRS/resource-management/pkg/store/redis$ go test -v
=== RUN   TestNewRedisClient
--- PASS: TestNewRedisClient (0.00s)
=== RUN   TestSetGettString
--- PASS: TestSetGettString (0.00s)
=== RUN   TestPersistNodes
--- PASS: TestPersistNodes (0.00s)
=== RUN   TestPersistNodeStoreStatus
--- PASS: TestPersistNodeStoreStatus (0.00s)
=== RUN   TestPersistVirtualNodesAssignments
--- PASS: TestPersistVirtualNodesAssignments (0.00s)
=== RUN   TestBatchLogicalNodeInquiry
    redis_test.go:219:
        First test is starting
    redis_test.go:263: Scan (2) logical nodes and actually get (2) logical nodes
    redis_test.go:266: Index #(0):
    redis_test.go:267: =================
    redis_test.go:268: Id:        (0002)
    redis_test.go:269: Region:    (1001)
    redis_test.go:270: RP:        (1001)
    redis_test.go:266: Index #(1):
    redis_test.go:267: =================
    redis_test.go:268: Id:        (0003)
    redis_test.go:269: Region:    (1002)
    redis_test.go:270: RP:        (1002)
    redis_test.go:272:
        First test is OK

    redis_test.go:275:
        Second test is starting
    redis_test.go:320: Scan (10) logical nodes and actually get (10) logical nodes
    redis_test.go:321:
        Second test is OK

    redis_test.go:324:
        Third test is starting
    redis_test.go:336: Scan (1000) logical nodes and actually get (1001) logical nodes
    redis_test.go:337:
        Third test is OK

    redis_test.go:340:
        Fourth test is starting
    redis_test.go:352: Scan (2000) logical nodes and actually get (2000) logical nodes
    redis_test.go:353:
        Fouth test is OK

    redis_test.go:356:
        The fifth test is starting
    redis_test.go:364: Scan (20000) logical nodes and actually get (10002) logical nodes
    redis_test.go:365:
        Fifth test is OK

--- PASS: TestBatchLogicalNodeInquiry (3.02s)
PASS
ok      global-resource-service/resource-management/pkg/store/redis     3.048s

The integration test have been done successfully in AWS environment (1 service-api and 1 region simulator)

-- service api

ubuntu@ip-172-31-8-82:~/go/src/GRS$ kill -9 `ps -ef |grep service-api |grep -v grep |awk '{print $2}'`;kill -9 `ps -ef |grep service-api |grep -v grep |awk '{print $2}'`; go run resource-management/cmds/service-api/service-api.go --master_ip=ec2-52-11-1-193.us-west-2.compute.amazonaws.com --resource_urls=ec2-54-187-22-27.us-west-2.compute.amazonaws.com:9119 --redis_port=7379 --enable_metrics=false -v=3  > ~/TMP/service.log.2022-09-19.v000182 2>&1 &

--- 1 simulator

ubuntu@ip-172-31-8-205:~/go/src/GRS$ kill -9 `ps -ef |grep go |grep -v grep |awk {print $2}'`;kill -9 `ps -ef |grep go |grep -v grep |awk '{print $2}'`;go run resource-management/test/resourceRegionMgrSimulator/main.go --region_name=Beijing --rp_num=10 --nodes_per_rp=25000 --master_port=9119 --data_pattern=Daily  -v=3  > ~/TMP/simulator1.log.2022-09-19.v000182 2>&1 &

--- redis-store

ubuntu@ip-172-31-8-82:~/go/src/GRS/resource-management/pkg/store/redis$ redis-cli -h ip-172-31-8-82 -p 7379 info keyspace
# Keyspace
db0:keys=250001,expires=0,avg_ttl=0