-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(knuu-example): Initial commit for the refactor (#291)
* refactor(knuu-example): Initial commit for the refactor Signed-off-by: Jose Ramon Mañes <jose@celestia.org> * refactor(knuu-example): add make actions Signed-off-by: Jose Ramon Mañes <jose@celestia.org> * chore: remove clutter * fix: import issue --------- Signed-off-by: Jose Ramon Mañes <jose@celestia.org> Co-authored-by: Mojtaba <mojtaba@celestia.org> Co-authored-by: Mojtaba <mojtaba-esk@users.noreply.github.com>
- Loading branch information
1 parent
76b7c6e
commit b16351a
Showing
40 changed files
with
8,306 additions
and
80 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,39 @@ | ||
name: Knuu Testing | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Set up Go 1.22.1 | ||
uses: actions/setup-go@v4.0.1 | ||
with: | ||
go-version: 1.22.1 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v4.1.2 | ||
|
||
- name: Setup kubeconfig | ||
env: | ||
KUBECONFIG_FILE: ${{ secrets.KNUU_KUBECONFIG_FILE }} | ||
run: | | ||
mkdir -p $HOME/.kube | ||
echo "${KUBECONFIG_FILE}" > $HOME/.kube/config | ||
- name: Run Tests | ||
run: make test-all | ||
env: | ||
KNUU_NAMESPACE: "knuu-test" | ||
KNUU_SKIP_CLEANUP: "false" | ||
KNUU_TIMEOUT: "240m" # needed as we run all the tests | ||
GRAFANA_ENDPOINT: ${{ secrets.GRAFANA_ENDPOINT }} | ||
GRAFANA_USERNAME: ${{ secrets.GRAFANA_USERNAME }} | ||
GRAFANA_TOKEN: ${{ secrets.GRAFANA_TOKEN }} |
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,32 @@ | ||
test-basic: | ||
go test -v ./e2e/basic -timeout 120m | ||
|
||
test-basic-file-cache: | ||
go test -v ./e2e/basic -run=TestFileCache -count=1 -timeout 120m | ||
|
||
test-basic-folder-cache: | ||
go test -v ./e2e/basic -run=TestFolderCache -count=1 -timeout 120m | ||
|
||
test-bittwister-packetloss: | ||
KNUU_TIMEOUT=120m go test -v ./e2e/basic --run=TestBittwister_Packetloss -timeout 60m -count=1 | ||
|
||
test-bittwister-bandwidth: | ||
KNUU_TIMEOUT=120m go test -v ./e2e/basic --run=TestBittwister_Bandwidth -timeout 60m -count=1 | ||
|
||
test-bittwister-latency: | ||
KNUU_TIMEOUT=120m go test -v ./e2e/basic --run=TestBittwister_Latency -timeout 60m -count=1 | ||
|
||
test-bittwister-jitter: | ||
KNUU_TIMEOUT=120m go test -v ./e2e/basic --run=TestBittwister_Jitter -timeout 60m -count=1 | ||
|
||
test-celestia-app: | ||
go test -v ./e2e/celestia_app | ||
|
||
test-celestia-node: | ||
go test -v ./e2e/celestia_node | ||
|
||
test-all: | ||
KNUU_TIMEOUT=300m go test -v ./e2e/... -timeout 120m | ||
|
||
.PHONY: test-all test-basic test-basic-file-cache test-basic-folder-cache test-bittwister-packetloss test-bittwister-bandwidth test-bittwister-latency test-bittwister-jitter test-celestia-app test-celestia-node | ||
|
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,62 @@ | ||
package basic | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/celestiaorg/knuu/pkg/knuu" | ||
) | ||
|
||
func TestBasic(t *testing.T) { | ||
t.Parallel() | ||
// Setup | ||
|
||
instance, err := knuu.NewInstance("alpine") | ||
if err != nil { | ||
t.Fatalf("Error creating instance '%v':", err) | ||
} | ||
err = instance.SetImage("docker.io/alpine:latest") | ||
if err != nil { | ||
t.Fatalf("Error setting image: %v", err) | ||
} | ||
err = instance.SetCommand("sleep", "infinity") | ||
if err != nil { | ||
t.Fatalf("Error setting command: %v", err) | ||
} | ||
err = instance.Commit() | ||
if err != nil { | ||
t.Fatalf("Error committing instance: %v", err) | ||
} | ||
|
||
t.Cleanup(func() { | ||
// Cleanup | ||
if os.Getenv("KNUU_SKIP_CLEANUP") == "true" { | ||
t.Log("Skipping cleanup") | ||
return | ||
} | ||
|
||
err = instance.Destroy() | ||
if err != nil { | ||
t.Fatalf("Error destroying instance: %v", err) | ||
} | ||
}) | ||
|
||
// Test logic | ||
|
||
err = instance.Start() | ||
if err != nil { | ||
t.Fatalf("Error starting instance: %v", err) | ||
} | ||
err = instance.WaitInstanceIsRunning() | ||
if err != nil { | ||
t.Fatalf("Error waiting for instance to be running: %v", err) | ||
} | ||
wget, err := instance.ExecuteCommand("echo", "Hello World!") | ||
if err != nil { | ||
t.Fatalf("Error executing command '%v':", err) | ||
} | ||
|
||
assert.Equal(t, wget, "Hello World!\n") | ||
} |
Oops, something went wrong.