diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0360276 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,17 @@ +name: Build & Test +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.16.x + - name: Checkout code + uses: actions/checkout@v2 + - name: Build, Vet & Test + run: | + go build ./... + go vet ./... + go test -v ./... diff --git a/.gitignore b/.gitignore index f9429f5..5877af3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -job.db -job-data +# executable: cc-jobarchive -clusters + +/var/job-archive +/var/*.db + diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3beff03 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "frontend"] + path = frontend + url = git@github.com:ClusterCockpit/cc-svelte-datatable.git diff --git a/README.md b/README.md index 46eccee..03bfd6c 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,39 @@ -# Run server +# ClusterCockpit with a Golang backend (Only supports archived jobs) -* The server expects the SQLite Job database in `./job.db`. -* The metric data as JSON is expected in `./job-data//.../data.json`. -* A JSON-description of the clusters is expected in `./job-data//cluster.json`. -* Run `go run server.go` -* The GraphQL backend is located at http://localhost:8080/query . +[![Build](https://github.com/ClusterCockpit/cc-metric-store/actions/workflows/test.yml/badge.svg)](https://github.com/ClusterCockpit/cc-metric-store/actions/workflows/test.yml) -# Debugging and Testing +### Run server -There is a GraphQL PLayground for testing queries at http://localhost:8080/ . +```sh +# The frontend is a submodule, so use `--recursive` +git clone --recursive git@github.com:ClusterCockpit/cc-jobarchive.git -Example Query: -``` -query($filter: JobFilterList!, $sorting: OrderByInput!, $paging: PageRequest!) { - jobs( - filter: $filter - order: $sorting - page: $paging - ) { - count - items { - id - jobId - userId - startTime - duration - } - } -} +# Prepare frontend +cd ./cc-jobarchive/frontend +yarn install +yarn build + +cd .. +go get +go build + +# The job-archive directory must be organised the same way as +# as for the regular ClusterCockpit. +ln -s ./var/job-archive + +# Create empty job.db (Will be initialized as SQLite3 database) +touch ./var/job.db + +# This will first initialize the job.db database by traversing all +# `meta.json` files in the job-archive. After that, a HTTP server on +# the port 8080 will be running. The `--init-db` is only needed the first time. +./cc-jobarchive --init-db + +# Show other options: +./cc-jobarchive --help ``` -Using the Query variables: -``` -{ - "filter": { "list": [ - {"userId": {"contains": "unrz"}}, - {"duration": {"from": 60, "to": 1000}}, - {"startTime": {"from": "2019-06-01T00:00:00.00Z", "to": "2019-10-01T00:00:00.00Z"}}]}, - "sorting": { "field": "start_time", "order": "ASC" }, - "paging": { "itemsPerPage": 20, "page": 1 } -} -``` +### Update GraphQL schema -# Changing the GraphQL schema +This project uses [gqlgen](https://github.com/99designs/gqlgen) for the GraphQL API. The schema can be found in `./graph/schema.graphqls`. After changing it, you need to run `go run github.com/99designs/gqlgen` which will update `graph/model`. In case new resolvers are needed, they will be inserted into `graph/schema.resolvers.go`, where you will need to implement them. -* Edit ```./graph/schema.graphqls``` -* Regenerate code: ```gqlgen generate``` -* Implement callbacks in ```graph/resolvers.go``` diff --git a/frontend b/frontend new file mode 160000 index 0000000..b487af3 --- /dev/null +++ b/frontend @@ -0,0 +1 @@ +Subproject commit b487af3496b46942d9848337bc2821575a1390b2 diff --git a/var/ui.config.json b/var/ui.config.json new file mode 100644 index 0000000..f06828d --- /dev/null +++ b/var/ui.config.json @@ -0,0 +1 @@ +{"analysis_view_histogramMetrics":["flops_any","mem_bw","mem_used"],"analysis_view_scatterPlotMetrics":[["flops_any","mem_bw"],["flops_any","cpu_load"],["cpu_load","mem_bw"]],"job_view_nodestats_selectedMetrics":["flops_any","mem_bw","mem_used"],"job_view_polarPlotMetrics":["flops_any","mem_bw","mem_used","net_bw","file_bw"],"job_view_selectedMetrics":["flops_any","mem_bw","mem_used"],"plot_general_colorBackground":true,"plot_general_colorscheme":["#00bfff","#0000ff","#ff00ff","#ff0000","#ff8000","#ffff00","#80ff00"],"plot_general_lineWidth":1,"plot_list_jobsPerPage":10,"plot_list_selectedMetrics":["cpu_load","mem_used","flops_any","mem_bw","clock"],"plot_view_plotsPerRow":4,"plot_view_showPolarplot":true,"plot_view_showRoofline":true,"plot_view_showStatTable":true} \ No newline at end of file