Skip to content

Commit

Permalink
test: improve testing setup for match and cancel
Browse files Browse the repository at this point in the history
Problem: the current testing is not standard for Go,
and makes it hard to understand or run in units.
Solution: move testing into proper test alongside
package, and break apart testing for cancel and match.
Additionally, we are using the same graphs / jobspecs
from flux-sched.

Signed-off-by: vsoch <[email protected]>
  • Loading branch information
vsoch committed Feb 5, 2025
1 parent 9f97485 commit f59eda2
Show file tree
Hide file tree
Showing 17 changed files with 4,871 additions and 484 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ RUN wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz && tar -xvf go${G
mv go /usr/local && rm go${GO_VERSION}.linux-amd64.tar.gz
ENV PATH=$PATH:/usr/local/go/bin:/home/vscode/go/bin

RUN git clone https://github.com/flux-framework/flux-sched /opt/flux-sched
# RUN git clone -b grow-api https://github.com/milroy/flux-sched /opt/flux-sched
COPY ./flux-sched /opt/flux-sched

# Add the group and user that match our ids
RUN groupadd -g ${USER_GID} ${USERNAME} && \
Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
matrix:
# container base and lib prefix
test: [["fluxrm/flux-sched:jammy", "/usr/lib"],
["fluxrm/flux-sched:fedora38", "/usr/lib64"],
["fluxrm/flux-sched:fedora40", "/usr/lib64"],
["fluxrm/flux-sched:bookworm-amd64", "/usr/lib"],
["fluxrm/flux-sched:el8", "/usr/lib64"]]

Expand All @@ -34,14 +34,9 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ^1.21
go-version: ^1.22

# TODO: we should consider distributing the header files with the release builds
- name: flux-sched build
run: git clone https://github.com/flux-framework/flux-sched /opt/flux-sched
- name: Build
run: LIB_PREFIX=${{ matrix.test[1] }} make build
- name: Test Binary
run: LIB_PREFIX=${{ matrix.test[1] }} make test-binary
- name: Test Modules
run: make test-modules
run: git clone -b grow-api https://github.com/milroy/flux-sched /opt/flux-sched
- name: Test
run: LIB_PREFIX=${{ matrix.test[1] }} make test
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz && tar -xvf go${G
mv go /usr/local && rm go${GO_VERSION}.linux-amd64.tar.gz
ENV PATH=$PATH:/usr/local/go/bin:/home/vscode/go/bin

RUN git clone https://github.com/flux-framework/flux-sched /opt/flux-sched
RUN git clone -b grow-api https://github.com/milroy/flux-sched /opt/flux-sched

# Assuming installing to /usr/local
ENV LD_LIBRARY_PATH=/usr/lib:/usr/lib/flux:/usr/local/lib
Expand Down
34 changes: 4 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,17 @@ LD_LIBRARY_PATH=$(LIB_PREFIX):$(LIB_PREFIX)/flux
BUILDENVVAR=CGO_CFLAGS="-I${FLUX_SCHED_ROOT} -I${FLUX_SCHED_ROOT}/resource/reapi/bindings/c" CGO_LDFLAGS="-L${LIB_PREFIX} -L${LIB_PREFIX}/flux -L${FLUX_SCHED_ROOT}/resource/reapi/bindings -lreapi_cli -lflux-idset -lstdc++ -ljansson -lhwloc -lflux-hostlist -lboost_graph -lyaml-cpp"

.PHONY: all
all: build
all: test

.PHONY: test
test: test-binary test-modules

.PHONY: test-modules
test-modules:
go test -v ./pkg/types

.PHONY: test-binary
test-binary:
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) $(LOCALBIN)/test --jgf=$(JGF) --jobspecs=$(JOBSPECS) --cancel=$(CANCELDATA)

# test001_desc="match allocate 1 slot: 1 socket: 1 core (pol=default)"
# test_expect_success "${test001_desc}" '
# ${main} --jgf=${jgf} --jobspec=${jobspec1} > 001.R.out &&
# sed -i -E "s/, 0\.[0-9]+//g" 001.R.out &&
# test_cmp 001.R.out ${exp_dir}/001.R.out
#'

#test002_desc="match allocate 2 slots: 2 sockets: 5 cores 1 gpu 6 memory"
#test_expect_success "${test002_desc}" '
# ${main} --jgf=${jgf} --jobspec=${jobspec2} > 002.R.out &&
# sed -i -E "s/, 0\.[0-9]+//g" 002.R.out &&
# test_cmp 002.R.out ${exp_dir}/002.R.out
#'
test:
# LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) $(LOCALBIN)/test --jgf=$(JGF) --jobspecs=$(JOBSPECS) --cancel=$(CANCELDATA)
$(COMMONENVVAR) $(BUILDENVVAR) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) go test -ldflags '-w' ./pkg/fluxcli ./pkg/types

.PHONY: $(LOCALBIN)
$(LOCALBIN):
mkdir -p $(LOCALBIN)

# This serves as a single test file to build a dummy main to test
.PHONY: build $(LOCALBIN)
build:
mkdir -p $(LOCALBIN)
$(COMMONENVVAR) $(BUILDENVVAR) go build -ldflags '-w' -o $(LOCALBIN)/test cmd/test/test.go

.PHONY: clean
clean:
rm -rf $(LOCALBIN)/test
129 changes: 0 additions & 129 deletions cmd/test/data/cancel/cancel.json

This file was deleted.

97 changes: 0 additions & 97 deletions cmd/test/data/cancel/partial-cancel.json

This file was deleted.

30 changes: 0 additions & 30 deletions cmd/test/data/jobspecs/test002.yaml

This file was deleted.

Loading

0 comments on commit f59eda2

Please sign in to comment.