-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add basic test setup to reproduce current tests
Problem: we need to reproduce tests currently in flux-sched here. Solution: separate the tests (modules and binary) in a Makefile, also adding support for make build to build the binary (and assert that the fluxmodule and fluxcli are functioning as expected). Signed-off-by: vsoch <[email protected]>
- Loading branch information
Showing
13 changed files
with
3,708 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM fluxrm/flux-sched:bookworm | ||
|
||
LABEL maintainer="Vanessasaurus <@vsoch>" | ||
|
||
# Match the default user id for a single system so we aren't root | ||
ARG USERNAME=vscode | ||
ARG USER_UID=1000 | ||
ARG USER_GID=1000 | ||
ENV USERNAME=${USERNAME} | ||
ENV USER_UID=${USER_UID} | ||
ENV USER_GID=${USER_GID} | ||
USER root | ||
RUN apt-get update && apt-get install -y less | ||
|
||
# Install Go 19 (we should update this) | ||
RUN wget https://go.dev/dl/go1.19.10.linux-amd64.tar.gz && tar -xvf go1.19.10.linux-amd64.tar.gz && \ | ||
mv go /usr/local && rm go1.19.10.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 && \ | ||
cd /opt/flux-sched && \ | ||
git fetch && \ | ||
export FLUX_SCHED_VERSION=0.58.0 && \ | ||
./autogen.sh && \ | ||
./configure --prefix=/usr && \ | ||
make && make install | ||
|
||
# Add the group and user that match our ids | ||
RUN groupadd -g ${USER_GID} ${USERNAME} && \ | ||
adduser --disabled-password --uid ${USER_UID} --gid ${USER_GID} --gecos "" ${USERNAME} && \ | ||
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers | ||
|
||
USER $USERNAME | ||
# Assuming installing to /usr/local | ||
ENV LD_LIBRARY_PATH=/usr/lib:/usr/lib/flux:/usr/local/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "Fluxion Go", | ||
"dockerFile": "Dockerfile", | ||
"context": "../", | ||
|
||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.defaultProfile.linux": "bash" | ||
}, | ||
"extensions": [ | ||
"ms-vscode.cmake-tools", | ||
"golang.go" | ||
] | ||
} | ||
}, | ||
"postStartCommand": "git config --global --add safe.directory /workspaces/fluxion-go" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: test fluxion-go | ||
|
||
# This will be expanded for more robust testing | ||
# right now we build and run the main test command | ||
# and test the package "types" directory | ||
|
||
on: | ||
pull_request: [] | ||
|
||
jobs: | ||
test: | ||
name: Test fluxion-go | ||
runs-on: ubuntu-latest | ||
|
||
# TODO add more configurations | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
test: [["fluxrm/flux-sched:bookworm"]] | ||
|
||
container: | ||
image: ${{ matrix.test[0] }} | ||
options: --user root | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ^1.19 | ||
# TODO: do we want this to be for different versions? Need to coincide with container bases | ||
- name: flux-sched Clone | ||
run: git clone https://github.com/flux-framework/flux-sched /opt/flux-sched | ||
- name: Build | ||
run: make build | ||
- name: Test Binary | ||
run: make test-binary | ||
- name: Test Modules | ||
run: make test-modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vendor | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
HERE ?= $(shell pwd) | ||
LOCALBIN ?= $(shell pwd)/bin | ||
JGF ?= $(HERE)/cmd/test/data/tiny.json | ||
JOBSPECS ?= $(HERE)/cmd/test/data/jobspecs | ||
|
||
# This assumes a build in the .devcontainer Dockerfile environment | ||
FLUX_SCHED_ROOT ?= /opt/flux-sched | ||
INSTALL_PREFIX ?= /usr | ||
COMMONENVVAR=GOOS=$(shell uname -s | tr A-Z a-z) | ||
|
||
BUILDENVVAR=CGO_CFLAGS="-I${FLUX_SCHED_ROOT} -I${FLUX_SCHED_ROOT}/resource/reapi/bindings/c" CGO_LDFLAGS="-L${INSTALL_PREFIX}/lib -L${INSTALL_PREFIX}/lib/flux -L${FLUX_SCHED_ROOT}/resource/reapi/bindings -lreapi_cli -lflux-idset -lstdc++ -lczmq -ljansson -lhwloc -lboost_system -lflux-hostlist -lboost_graph -lyaml-cpp" | ||
# BUILDENVAR=CGO_CFLAGS="${CGO_CFLAGS}" CGO_LDFLAGS='${CGO_LIBRARY_FLAGS}' go build -ldflags '-w' | ||
|
||
|
||
.PHONY: all | ||
all: build | ||
|
||
.PHONY: test | ||
test: test-binary test-modules | ||
|
||
.PHONY: test-modules | ||
test-modules: | ||
go test -v ./pkg/types | ||
|
||
.PHONY: test-binary | ||
test-binary: | ||
$(LOCALBIN)/test --jgf=$(JGF) --jobspec=$(JOBSPECS)/test001.yaml | ||
|
||
# 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 | ||
#' | ||
|
||
.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: 9999 | ||
resources: | ||
- type: cluster | ||
count: 1 | ||
with: | ||
- type: rack | ||
count: 1 | ||
with: | ||
- type: node | ||
count: 1 | ||
with: | ||
- type: slot | ||
count: 1 | ||
label: default | ||
with: | ||
- type: socket | ||
count: 1 | ||
with: | ||
- type: core | ||
count: 1 | ||
# a comment | ||
attributes: | ||
system: | ||
duration: 3600 | ||
tasks: | ||
- command: [ "app" ] | ||
slot: default | ||
count: | ||
per_slot: 1 | ||
|
Oops, something went wrong.