Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Aug 8, 2023
1 parent 4a0d696 commit d49fb4d
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 97 deletions.
127 changes: 62 additions & 65 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,72 +275,69 @@ jobs:
- name: Test Workable
shell: bash
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" && ( "${{ matrix.kwokctl-runtime }}" == "binary" || "${{ matrix.kwokctl-runtime }}" == "docker" ) ]]; then
export LAST_RELEASE_SIZE=20
fi
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}
- name: Test Multi Cluster
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_multi_cluster
- name: Test Snapshot
if: ${{ matrix.os != 'windows-latest' }} # TODO: fix snapshot test on windows
shell: bash
run: |
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_snapshot
- name: Test Audit
shell: bash
run: |
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_audit
- name: Test Scheduler
shell: bash
run: |
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_scheduler
- name: Test Authorization
shell: bash
run: |
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_authorization
- name: Test Restart
shell: bash
run: |
if [[ "${{ matrix.kwokctl-runtime }}" != 'ubuntu-latest' || ( "${{ matrix.kwokctl-runtime }}" == "nerdctl" && "${{ matrix.nerdctl-version }}" != "1.4.0" ) ]]; then
export SKIP_DRY_RUN=true
fi
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_restart
- name: Test Port Forward
if: ${{ matrix.os != 'windows-latest' }} # TODO: fix port-forward on windows
shell: bash
run: |
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_port_forward
- name: Test Exec
if: ${{ matrix.os != 'windows-latest' }} # TODO: fix exec on windows
shell: bash
run: |
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_exec
- name: Test Log
shell: bash
run: |
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_logs
- name: Test Attach
shell: bash
run: |
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_attach
- name: Test Metrics
shell: bash
run: |
./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_metric
#
# - name: Test Multi Cluster
# if: ${{ matrix.os == 'ubuntu-latest' }}
# shell: bash
# run: |
# ./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_multi_cluster
#
# - name: Test Snapshot
# if: ${{ matrix.os != 'windows-latest' }} # TODO: fix snapshot test on windows
# shell: bash
# run: |
# ./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_snapshot
#
# - name: Test Audit
# shell: bash
# run: |
# ./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_audit
#
# - name: Test Scheduler
# shell: bash
# run: |
# ./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_scheduler
#
# - name: Test Authorization
# shell: bash
# run: |
# ./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_authorization
#
# - name: Test Restart
# shell: bash
# run: |
# if [[ "${{ matrix.kwokctl-runtime }}" != 'ubuntu-latest' || ( "${{ matrix.kwokctl-runtime }}" == "nerdctl" && "${{ matrix.nerdctl-version }}" != "1.4.0" ) ]]; then
# export SKIP_DRY_RUN=true
# fi
# ./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_restart
#
# - name: Test Port Forward
# if: ${{ matrix.os != 'windows-latest' }} # TODO: fix port-forward on windows
# shell: bash
# run: |
# ./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_port_forward
#
# - name: Test Exec
# if: ${{ matrix.os != 'windows-latest' }} # TODO: fix exec on windows
# shell: bash
# run: |
# ./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_exec
#
# - name: Test Log
# shell: bash
# run: |
# ./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_logs
#
# - name: Test Attach
# shell: bash
# run: |
# ./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_attach
#
# - name: Test Metrics
# shell: bash
# run: |
# ./hack/e2e-test.sh kwokctl/kwokctl_${{ matrix.kwokctl-runtime }}_metric

- name: Test Benchmark
if: ${{ matrix.os == 'ubuntu-latest' && matrix.kwokctl-runtime != 'kind' && matrix.kwokctl-runtime != 'kind-podman' }}
Expand Down
5 changes: 5 additions & 0 deletions cmd/kwok/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main

import (
"os"
"runtime"

"github.com/spf13/pflag"

Expand All @@ -28,6 +29,10 @@ import (
"sigs.k8s.io/kwok/pkg/utils/signals"
)

func init() {
runtime.GOMAXPROCS(1)
}

func main() {
flagset := pflag.NewFlagSet("global", pflag.ContinueOnError)
flagset.ParseErrorsWhitelist.UnknownFlags = true
Expand Down
28 changes: 16 additions & 12 deletions pkg/kwok/controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,23 @@ func (c *Controller) Start(ctx context.Context) error {
}
onLeaseNodeManageFunc = func(nodeName string) {
// Manage the node and play stage all pods on the node
err := nodesInformer.Update(ctx, Option{
FieldSelector: fields.OneTermEqualSelector("metadata.name", nodeName).String(),
}, nodeCh)
if err != nil {
logger.Error("failed to update node", err, "node", nodeName)
}
go func() {
err := nodesInformer.Update(ctx, Option{
FieldSelector: fields.OneTermEqualSelector("metadata.name", nodeName).String(),
}, nodeCh)
if err != nil {
logger.Error("failed to update node", err, "node", nodeName)
}
}()

err = podsInformer.Update(ctx, Option{
FieldSelector: fields.OneTermEqualSelector("spec.nodeName", nodeName).String(),
}, podsCh)
if err != nil {
logger.Error("failed to update pods on node", err, "node", nodeName)
}
go func() {
err = podsInformer.Update(ctx, Option{
FieldSelector: fields.OneTermEqualSelector("spec.nodeName", nodeName).String(),
}, podsCh)
if err != nil {
logger.Error("failed to update pods on node", err, "node", nodeName)
}
}()
}

onNodeManagedFunc = func(nodeName string) {
Expand Down
21 changes: 4 additions & 17 deletions pkg/kwok/controllers/node_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,10 @@ func (c *NodeController) watchResources(ctx context.Context, events <-chan Event
break loop
}
switch event.Type {
case Added, Sync:
case Added, Modified, Sync:
node := event.Object
if c.need(node) {
c.putNodeInfo(node)
if c.onNodeManagedFunc != nil {
c.onNodeManagedFunc(node.Name)
}
if c.readOnly(node.Name) {
logger.Debug("Skip node",
"reason", "read only",
Expand All @@ -246,19 +243,9 @@ func (c *NodeController) watchResources(ctx context.Context, events <-chan Event
c.preprocessChan <- node
}
}
case Modified:
node := event.Object
if c.need(node) {
c.putNodeInfo(node)
if c.readOnly(node.Name) {
logger.Debug("Skip node",
"reason", "read only",
"event", event.Type,
"node", node.Name,
)
} else {
c.preprocessChan <- node
}

if c.onNodeManagedFunc != nil && event.Type != Modified {
c.onNodeManagedFunc(node.Name)
}
case Deleted:
node := event.Object
Expand Down
6 changes: 3 additions & 3 deletions test/kwokctl/kwokctl_benchmark_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ function main() {
echo "Benchmarking on ${KWOK_RUNTIME}"
name="benchmark-${KWOK_RUNTIME}"

create_cluster "${name}" "${release}" --disable-qps-limits
create_cluster "${name}" "${release}" -v debug --disable-qps-limits --controller-port 8080
child_timeout 120 scale_create_node "${name}" 1000 || failed+=("scale_create_node_timeout_${name}")
child_timeout 120 scale_create_pod "${name}" 1000 || failed+=("scale_create_pod_timeout_${name}")
child_timeout 120 scale_delete_pod "${name}" 0 || failed+=("scale_delete_pod_timeout_${name}")
# child_timeout 120 scale_create_pod "${name}" 1000 || failed+=("scale_create_pod_timeout_${name}")
# child_timeout 120 scale_delete_pod "${name}" 0 || failed+=("scale_delete_pod_timeout_${name}")
delete_cluster "${name}"

if [[ "${#failed[@]}" -ne 0 ]]; then
Expand Down

0 comments on commit d49fb4d

Please sign in to comment.