apache / incubator-hugegraph-toolchain

HugeGraph toolchain - include a series useful graph modules
https://hugegraph.apache.org/
Apache License 2.0
88 stars 92 forks source link

[Doc][Developer] Documentation about how to run test #618

Open Thespica opened 1 month ago

Thespica commented 1 month ago

Search before asking

Feature Description (功能描述)

Currently, it's little bit of complexity for developer who wants run test locally.

For example, I want to run client's test, and fund it relying on hugegraph server. Okay, then I start HugeGraph server, the test still failed. Then I took a look to it's CI, and fund this script which can not run directly on local.

Running tests is a good approach to understand the code, maybe we should provide some documentations and scripts for developers that teach how to test locally?

Are you willing to submit a PR?

Code of Conduct

imbajin commented 1 month ago

@dosu help the dev/user to provide more info/details about how to run hugegraph-client test locally (or in IDEA)

Or could you provide a simple way to run it quickly

dosubot[bot] commented 1 month ago

Hey @imbajin! 👋 I'm here to help you with any bugs, questions, or contributions while you wait for the human maintainer.

To run the HugeGraph client tests locally or in IntelliJ IDEA, follow these steps:

  1. Clone the HugeGraph repository and checkout the specific commit:

    git clone --depth 150 https://github.com/apache/hugegraph.git hugegraph
    cd hugegraph
    git checkout <COMMIT_ID>
  2. Build the HugeGraph server:

    mvn package -DskipTests -Dmaven.javadoc.skip=true -ntp
  3. Extract the HugeGraph server package:

    cd hugegraph-server
    mv apache-hugegraph-*.tar.gz ../../
    cd ../../
    rm -rf hugegraph
    tar zxf apache-hugegraph-*.tar.gz
  4. Configure and start the HugeGraph server:

    HTTP_SERVER_DIR=$(echo apache-hugegraph-*.*)
    HTTPS_SERVER_DIR="hugegraph_https"
    
    cp -r "${HTTP_SERVER_DIR}" "${HTTPS_SERVER_DIR}"
    
    # Config auth options just for http server (must keep '/.')
    cp -rf hugegraph-client/assembly/travis/conf/. "${HTTP_SERVER_DIR}"/conf/
    
    # Start HugeGraphServer with http protocol
    cd "${HTTP_SERVER_DIR}"
    echo -e "pa" | bin/init-store.sh
    bin/start-hugegraph.sh
  5. Configure and start the HugeGraph server with HTTPS protocol:

    cd ../"${HTTPS_SERVER_DIR}"
    REST_SERVER_CONFIG="conf/rest-server.properties"
    GREMLIN_SERVER_CONFIG="conf/gremlin-server.yaml"
    sed -i "s?http://127.0.0.1:8080?https://127.0.0.1:8443?g" "$REST_SERVER_CONFIG"
    sed -i "s/rpc.server_port=8091/rpc.server_port=8092/g" "$REST_SERVER_CONFIG"
    sed -i "s/#port: 8182/port: 8282/g" "$GREMLIN_SERVER_CONFIG"
    echo "gremlinserver.url=http://127.0.0.1:8282" >> ${REST_SERVER_CONFIG}
    
    # Start HugeGraphServer with https protocol
    bin/init-store.sh
    bin/start-hugegraph.sh
  6. Run the tests in IntelliJ IDEA:

    • Open IntelliJ IDEA and import the HugeGraph client project.
    • Ensure that the HugeGraph server is running.
    • Run the tests from the test classes or test methods in IntelliJ IDEA.

Additionally, you can follow the detailed guide provided in the HugeGraph documentation for setting up and debugging the HugeGraph server in IntelliJ IDEA:

  1. Copy Configuration Files:

    cp -r hugegraph-dist/src/assembly/static/scripts hugegraph-dist/src/assembly/static/conf path-to-your-directory
  2. Configure InitStore to initialize the graph:

    • Configure the database backend in path-to-your-directory/conf/graphs/hugegraph.properties:
      backend=rocksdb
      serializer=binary
      rocksdb.data_path=.
      rocksdb.wal_path=.
    • Create a new Application configuration in IntelliJ IDEA:
      • Use hugegraph-dist as the classpath of the module.
      • Set the Main class to org.apache.hugegraph.cmd.InitStore.
      • Set the program arguments to conf/rest-server.properties.
  3. Running HugeGraphServer:

    • Create a new Application configuration in IntelliJ IDEA:
      • Use hugegraph-dist as the classpath of the module.
      • Set the Main class to org.apache.hugegraph.dist.HugeGraphServer.
      • Set the program arguments to conf/gremlin-server.yaml conf/rest-server.properties.
  4. Debugging HugeGraphServer (optional):

    • Set breakpoints and use the RESTful API to request HugeGraphServer.
  5. Log4j2 Configuration:

    • Modify the Log4j2 configuration file path in IntelliJ IDEA to conf/log4j2.xml.

By following these steps and the detailed guide, you can manually set up the HugeGraph server and run the client tests locally or in IntelliJ IDEA [1][2][3].

To continue talking to Dosu, mention @dosu.