Skip to content

Commit

Permalink
NeoEden : add a set of sample tests
Browse files Browse the repository at this point in the history
Signed-off-by: Shahriyar Jalayeri <shahriyar@zededa.com>
  • Loading branch information
shjala committed Sep 24, 2024
1 parent 5cd788d commit 86fec04
Show file tree
Hide file tree
Showing 14 changed files with 3,348 additions and 116 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ install: build

build: $(BIN) $(EMPTY_DRIVE).raw $(EMPTY_DRIVE).qcow2 $(EMPTY_DRIVE).qcow $(EMPTY_DRIVE).vmdk $(EMPTY_DRIVE).vhdx $(LINUXKIT)
$(LOCALBIN): $(BINDIR) pkg/eden/*.go
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags "-s -w" -o $@ pkg/eden/*.go
cd pkg/eden && CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags "-s -w" -o ../../$@ *.go
mkdir -p dist/scripts/shell
cp -r shell-scripts/* dist/scripts/shell/

Expand Down
3 changes: 0 additions & 3 deletions go.work

This file was deleted.

5 changes: 0 additions & 5 deletions go.work.sum

This file was deleted.

107 changes: 0 additions & 107 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,107 +0,0 @@
# Eden Integration Tests

This directory contains a series of integration tests that meet the
[eden task API](../docs/task-writing.md), and thus can be launched using
`eden test`. Each subdirectory contains an individual test suite with one or
more tests.

The general principles for integration testing of EVE are available at
[EVE+Integration+Testing](https://wiki.lfedge.org/display/EVE/EVE+Integration+Testing)

The testing workflow for CI/CD of this eden project is at [workflow/README.MD](workflow/README.MD)

## Running Integration Tests

You can run either the entire suite of tests in this repository, or an
individual test or suite.

### Running The Entire Test Suite

To run the entire suite of integration tests, run either:

* `make test` in the root of this repository
* `make test` in this `tests/` directory

### Running Individual Tests

To run any single suite of integration tests, launch them like any other
[eden test/task](../docs/test-running.md):

```console
eden test tests/testdir/
```

You also can run `make test` in any individual test suite directory.

If you want to run one specific test, run:

```console
eden test tests/testdir/ -t <TestName>
```

See the [documentation for running eden tests](../docs/test-running.md) for
more options.

## Building Integration Tests

The integration tests under `tests/` ship as source code. If you want to
run them, you will need to build them. You can do this in one of several ways:

* To build an individual test, in its directory, run `make build`
* To build all tests, in this directory `tests/`, run `make build`
* To build all tests, in the root directory of the `eden` repository, run one of:
* `make build-tests` - builds `eden` and all integration tests
* `make testbin` - builds all integration tests

## Writing Integration Tests

### Test Suite Structure

Each test suite, in its own directory, must implement the
[eden task API](../docs/test-writing.md), and thus contains, at least:

* the configuration file `eden-config.yml` with the corresponding fields
* `eden.test-bin` - references the name of the binary built by `make build`
* `eden.test-script` - references the test script in the test directory
* a test script

In addition, each directory, in order to be part of the integration test suite,
contains a Makefile with at least the following targets:

* `build` - build the test binary, if any, and places it in a directed bindir
* `setup` - sets up the test environment
* `clean` - removes any artifacts
* `test` - executes the built test binary

The above targets must exist; if any is unneeded, it should be an empty target.

The bindir is expected to be `$(WORKDIR)/bin/`. For example, if the test binary
is to be named `footest`, then the following should be the behaviour:

* `make build WORKDIR=/tmp` -> `/tmp/bin/footest`
* `make build WORKDIR=/usr/local` -> `/usr/local/bin/footest`
* `make build` -> whatever the `Makefile` uses as its default

These `Makefile` are not requirements for the general
[eden task API](../docs/test-writing.md),but rather to be part of the
standard set of integration tests that are launched by this repository.

### Test Suite Language

The tests in this directory are implemented in Golang. They meet
the [Golang testing standard](https://golang.org/doc/code#Testing) by naming all
test files `_test.go`, and thus can be compiled via `go test -c`. The compiled
standalone binaries and individual tests/subtests from them can be combined in test scripts
with the ability to configure runtime parameters and a specific
EDEN configuration environment. In test scenarios and configuration files
may be used standard Go templates machinery with some EDEN-specific extensions.

However, it is not _required_ that a test be built in go. Future tests in this
directory may use different languages, provided that they meet the
[eden task API](../docs/test-writing.md) and the `Makefile` structure.

## Useful links

* [EVE+Integration+Testing](https://wiki.lfedge.org/display/EVE/EVE+Integration+Testing)
* [Eden testing README](https://github.com/lf-edge/eden/blob/master/tests/README.md)
* [Description of existing tests](https://wiki.lfedge.org/display/EVE/Tests)
Empty file added tests/app/.gitkeep
Empty file.
72 changes: 72 additions & 0 deletions tests/eve/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
DEBUG ?= "debug"

# HOSTARCH is the host architecture
# ARCH is the target architecture
# we need to keep track of them separately
HOSTARCH ?= $(shell uname -m)
HOSTOS ?= $(shell uname -s | tr A-Z a-z)

# canonicalized names for host architecture
override HOSTARCH := $(subst aarch64,arm64,$(subst x86_64,amd64,$(HOSTARCH)))

# unless otherwise set, I am building for my own architecture, i.e. not cross-compiling
# and for my OS
ARCH ?= $(HOSTARCH)
OS ?= $(HOSTOS)

# canonicalized names for target architecture
override ARCH := $(subst aarch64,arm64,$(subst x86_64,amd64,$(ARCH)))

WORKDIR ?= $(CURDIR)/../../dist
TESTDIR := tests/$(shell basename $(CURDIR))
BINDIR := $(WORKDIR)/bin
DATADIR := $(WORKDIR)/$(TESTDIR)/
BIN := eden
LOCALBIN := $(BINDIR)/$(BIN)-$(OS)-$(ARCH)
TESTNAME := eden.eve
TESTBIN := $(TESTNAME).testsuite
LOCALTESTBIN := $(TESTBIN)-$(OS)-$(ARCH)
.DEFAULT_GOAL := help

clean:
rm -rf $(LOCALTESTBIN) $(BINDIR)/$(TESTBIN) $(CURDIR)/$(TESTBIN) $(BINDIR)/$(TESTBIN)

$(BINDIR):
mkdir -p $@
$(DATADIR):
mkdir -p $@

test:
$(LOCALBIN) test $(CURDIR) -v $(DEBUG)

build: setup

testbin: $(TESTBIN)
$(LOCALTESTBIN): $(BINDIR) *.go
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go test -c -ldflags "-s -w" -o $@ *.go

$(TESTBIN): $(LOCALTESTBIN)
ln -sf $(LOCALTESTBIN) $(CURDIR)/$(TESTBIN)

setup: testbin $(BINDIR) $(DATADIR)
mv $(LOCALTESTBIN) $(CURDIR)/$(TESTBIN) $(BINDIR)

debug:
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go test -c -gcflags "all=-N -l" -o $@ *.go
dlv dap --listen=:12345 --headless=true exec ./debug -- -test.v

.PHONY: test build setup clean all testbin debug

help:
@echo "EDEN is the harness for testing EVE and ADAM"
@echo
@echo "This Makefile automates commons tasks of EDEN testing"
@echo
@echo "Commonly used maintenance and development targets:"
@echo " build build test-binary (OS and ARCH options supported, for ex. OS=linux ARCH=arm64)"
@echo " setup setup of test environment"
@echo " test run tests"
@echo " clean cleanup of test harness"
@echo
@echo "You need install requirements for EVE (look at https://github.com/lf-edge/eve#install-dependencies)."
@echo "You need access to docker socket and installed qemu packages."
144 changes: 144 additions & 0 deletions tests/eve/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
module eve_test

go 1.22.5

replace github.com/lf-edge/eden/pkg/eden => ../../pkg/eden

replace github.com/lf-edge/eden/sdn/vm => ../../pkg/sdn/vm

replace github.com/lf-edge/eve/libs/depgraph => github.com/lf-edge/eve/libs/depgraph v0.0.0-20220711144346-0659e3b03496

require (
github.com/bloomberg/go-testgroup v1.1.1
github.com/lf-edge/eden/pkg/eden v0.0.0-00010101000000-000000000000
github.com/sirupsen/logrus v1.9.3
)

require (
cloud.google.com/go/auth v0.9.3 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Insei/rolgo v0.0.2 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Microsoft/hcsshim v0.11.7 // indirect
github.com/amitbet/vncproxy v0.0.0-20200118084310-ea8f9b510913 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/containerd/containerd v1.7.22 // indirect
github.com/containerd/containerd/api v1.7.19 // indirect
github.com/containerd/continuity v0.4.2 // indirect
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/fifo v1.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
github.com/containerd/ttrpc v1.2.5 // indirect
github.com/containerd/typeurl/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/cli v27.1.1+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v27.2.1+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-containerregistry v0.20.2 // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/lf-edge/eden/eserver v0.0.0-20240912155252-98f9e9d49af1 // indirect
github.com/lf-edge/eden/sdn/vm v0.0.0-00010101000000-000000000000 // indirect
github.com/lf-edge/edge-containers v0.0.0-20240207093504-5dfda0619b80 // indirect
github.com/lf-edge/eve-api/go v0.0.0-20240829123634-7c8ebda876ff // indirect
github.com/lf-edge/eve/libs/depgraph v0.0.0-20220711144346-0659e3b03496 // indirect
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mcuadros/go-lookup v0.0.0-20230627150232-5415b5b32da8 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/signal v0.7.0 // indirect
github.com/moby/sys/user v0.3.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/nerd2/gexto v0.0.0-20190529073929-39468ec063f6 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runtime-spec v1.1.0 // indirect
github.com/opencontainers/selinux v1.11.0 // indirect
github.com/packethost/packngo v0.31.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/redis/go-redis/v9 v9.6.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef // indirect
github.com/vbatts/tar-split v0.11.3 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/api v0.197.0 // indirect
google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/grpc v1.66.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
oras.land/oras-go v1.2.6 // indirect
)
Loading

0 comments on commit 86fec04

Please sign in to comment.