Skip to content

Commit

Permalink
adjust review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mjudeikis committed Jul 13, 2023
1 parent 4729a9f commit bb16974
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 16 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: E2E tests

on:
push:
branches:
- main
- 'release-*'
pull_request:
branches:
- main
- 'release-*'
paths-ignore:
- "docs/**"
- "**/*.md"
- ".github/ISSUE_TEMPLATE/*"
- ".goreleaser.yaml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# NOTE!!!
#
# If you add a job here that is a REQUIRED status check in GitHub, you MUST add a job with the same name to ci-docs-only.yaml
#
# NOTE!!!

env:
# etcd uses fsync by default, disable it for running on github actions to avoid disk contention
# xref: https://github.com/kcp-dev/kcp/pull/435/commits/064a517747d69c2cd8f7f8b4a595ad909e595c89
UNSAFE_E2E_HACK_DISABLE_ETCD_FSYNC: true

jobs:
e2e-tests:
name: e2e-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: E2E tests
id: e2e
shell: bash
run: |
make test
COVERAGE=$(go tool cover -func profile.cov | grep total: | awk '{print $3}')
echo "\n\nCoverage will be $COVERAGE"
echo "::set-env name=COVERAGE::$COVERAGE"
- run: |
apt-get update -y
apt-get install wget tar gcc git curl runc iptables libdevmapper1.02.1 make jq -y
export PATH=$PWD/bin:$PATH
make all
LOG_DIR=/tmp/e2e/shared-server/artifacts ARTIFACT_DIR=/tmp/e2e \
OS=linux ARCH=ppc64le E2E_PARALLELISM=4 make test-e2e -e TEST_ARGS="-timeout 50m"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# We need bash for some conditional logic below.
SHELL := /usr/bin/env bash -e

REPO ?= quay.io/faroshq/tmc
REPO ?= quay.io/kcp-dev/contrib-tmc
KO_DOCKER_REPO ?= ${REPO}

GO_INSTALL = ./hack/go-install.sh
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ and extend its functionality to support multi-cluster workload management.
make build
# Copy binaries to PATH
# Either copy the binaries to a directory in your PATH
cp bin/{kubectl-tmc,kubectl-workloads} /usr/local/bin/kubectl-tmc
# Or add the bin directory to your PATH
export PATH=$PATH:$(pwd)/bin
# Start TMC-KCP
go run ./cmd/tmc start
Expand All @@ -24,7 +32,7 @@ and extend its functionality to support multi-cluster workload management.
# Create SyncTarget for remote cluster
kubectl tmc workload sync cluster-1 --syncer-image quay.io/faroshq/tmc/syncer:latest --output-file cluster-1.yaml
kubectl tmc workload sync cluster-1 --syncer-image quay.io/kcp-dev/contrib-tmc/syncer:latest --output-file cluster-1.yaml
# Bind compute resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
workloadcmd "github.com/kcp-dev/contrib-tmc/pkg/cliplugins/workload/cmd"
)

func KubectlTmcCommand() *cobra.Command {
func KubectlTMCCommand() *cobra.Command {
root := &cobra.Command{
Use: "tmc",
Short: "kubectl plugin for KCP-TMC",
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubectl-tmc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func main() {
flags := pflag.NewFlagSet("kubectl-tmc", pflag.ExitOnError)
pflag.CommandLine = flags

cmd := cmd.KubectlTmcCommand()
cmd := cmd.KubectlTMCCommand()
if err := cmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ require (
github.com/aojea/rwconn v0.1.1
github.com/coredns/caddy v1.1.1
github.com/coredns/coredns v1.9.3
github.com/davecgh/go-spew v1.1.1
github.com/egymgmbh/go-prefix-writer v0.0.0-20180609083313-7326ea162eca
github.com/evanphx/json-patch v5.6.0+incompatible
github.com/google/uuid v1.3.0
github.com/kcp-dev/apimachinery/v2 v2.0.0-alpha.0.0.20230419125703-767ac05aebce
github.com/kcp-dev/client-go v0.0.0-20230519100911-e16eb4c2bf18
github.com/kcp-dev/kcp v0.20.0
github.com/kcp-dev/kcp/sdk v0.20.0
github.com/kcp-dev/kcp v0.0.0-20230711191019-8dd1a3f4e240
github.com/kcp-dev/kcp/sdk v0.0.0-20230711191019-8dd1a3f4e240
github.com/kcp-dev/logicalcluster/v3 v3.0.4
github.com/martinlindhe/base36 v1.1.1
github.com/miekg/dns v1.1.50
Expand Down Expand Up @@ -44,7 +45,6 @@ require (
github.com/coreos/go-oidc v2.1.0+incompatible // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dnstap/golang-dnstap v0.4.0 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
Expand Down Expand Up @@ -181,8 +181,8 @@ require (

replace (
github.com/google/cel-go => github.com/google/cel-go v0.12.6
github.com/kcp-dev/kcp => ../kcp
github.com/kcp-dev/kcp/sdk => ../kcp/sdk
//github.com/kcp-dev/kcp => ../kcp
//github.com/kcp-dev/kcp/sdk => ../kcp/sdk
k8s.io/api => github.com/kcp-dev/kubernetes/staging/src/k8s.io/api v0.0.0-20230526104423-c790f4246d25
k8s.io/apiextensions-apiserver => github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiextensions-apiserver v0.0.0-20230526104423-c790f4246d25
k8s.io/apimachinery => github.com/kcp-dev/kubernetes/staging/src/k8s.io/apimachinery v0.0.0-20230526104423-c790f4246d25
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,10 @@ github.com/kcp-dev/apimachinery/v2 v2.0.0-alpha.0.0.20230419125703-767ac05aebce
github.com/kcp-dev/apimachinery/v2 v2.0.0-alpha.0.0.20230419125703-767ac05aebce/go.mod h1:zjNivgz2FtvyUPPLNpx5yDxFoFHNQqFrP3FKKTSMvvw=
github.com/kcp-dev/client-go v0.0.0-20230519100911-e16eb4c2bf18 h1:2DoPVFTfqQe9nq2msBs8oMhFxgsvGE6pOg15tqx9p28=
github.com/kcp-dev/client-go v0.0.0-20230519100911-e16eb4c2bf18/go.mod h1:C4i5aU8Mufjgjjm+alv5c2hufNsMvO530Rq2sZ3KgHk=
github.com/kcp-dev/kcp v0.20.0 h1:moauYc03yPtUrnh+/qlNHZvts5s/vS/Rde4imd5/5/I=
github.com/kcp-dev/kcp v0.20.0/go.mod h1:/S//bktVUynMemLmxl3pw1PJ4ihrffgRzfscF8yE43A=
github.com/kcp-dev/kcp/sdk v0.20.0 h1:wlqOmFmUWjYwDzQlazE5Ecdbsqpil27RvsHKn7kwPfQ=
github.com/kcp-dev/kcp/sdk v0.20.0/go.mod h1:gJvzobKY5POI5AjYH+LI9CI19Cip6gwmdbsJ2kWXsfY=
github.com/kcp-dev/kcp v0.0.0-20230711191019-8dd1a3f4e240 h1:DREIpjflfUdBGcJL/uFDrb0YSeFCH/6h5Eh9NNwpWfY=
github.com/kcp-dev/kcp v0.0.0-20230711191019-8dd1a3f4e240/go.mod h1:/S//bktVUynMemLmxl3pw1PJ4ihrffgRzfscF8yE43A=
github.com/kcp-dev/kcp/sdk v0.0.0-20230711191019-8dd1a3f4e240 h1:Qu3jRrjS7ss8hN9cwSporv64JpQqITpawr2E0rRdDAc=
github.com/kcp-dev/kcp/sdk v0.0.0-20230711191019-8dd1a3f4e240/go.mod h1:gJvzobKY5POI5AjYH+LI9CI19Cip6gwmdbsJ2kWXsfY=
github.com/kcp-dev/kubernetes v0.0.0-20230526104423-c790f4246d25 h1:7+OgdM7/fMeK6Obe7aRwSObgj80yUEuuIPKD8sUVfD8=
github.com/kcp-dev/kubernetes v0.0.0-20230526104423-c790f4246d25/go.mod h1:nyJTa0Fiq+nOYp4Eb1EeuVNDu1HFyj7BqFOXqNsl0Ic=
github.com/kcp-dev/kubernetes/staging/src/k8s.io/api v0.0.0-20230526104423-c790f4246d25 h1:nd2tAjYI8hvaTyNPAXW/hXzItlNrO5I1hEbcNbbeBHA=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type placementReconciler struct {
func (r *placementReconciler) reconcile(ctx context.Context, placement *schedulingv1alpha1.Placement) (reconcileStatus, *schedulingv1alpha1.Placement, error) {
// get location workspace at first
var locationWorkspace logicalcluster.Path
// https://github.com/kcp-dev/contrib-tmc/issues/4
// TODO(MJ): currently this disables the cross workspace placements. This is due to
// fact indexers are build ontop of logicalcluster paths and we use here the 'readable' paths
// if len(placement.Spec.LocationWorkspace) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/tmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func SharedKcpServer(t *testing.T) RunningServer {
// Use a persistent server

t.Logf("shared kcp server will target configuration %q", kubeconfig)
server, err := newPersistentKCPServer(serverName, kubeconfig, TestConfig.ShardKubeconfig(), filepath.Join(RepositoryDir(), ".kcp"))
server, err := newPersistentKCPServer(serverName, kubeconfig, TestConfig.ShardKubeconfig(), filepath.Join(RepositoryDir(), ".tmc"))
require.NoError(t, err, "failed to create persistent server fixture")

ctx, cancel := context.WithCancel(context.Background())
Expand Down
17 changes: 15 additions & 2 deletions test/e2e/syncer/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ import (
//go:embed *.yaml
var embeddedResources embed.FS

func TestSyncerLifecycle(t *testing.T) {
// Re-enable https://github.com/kcp-dev/contrib-tmc/issues/3
func XTestSyncerLifecycle(t *testing.T) {
t.Parallel()
framework.Suite(t, "transparent-multi-cluster")

Expand Down Expand Up @@ -584,6 +585,8 @@ func TestSyncWorkload(t *testing.T) {
t.Log("Creating an organization")
orgPath, _ := framework.NewOrganizationFixture(t, upstreamServer, framework.TODO_WithoutMultiShardSupport())

upstreamCfg := upstreamServer.BaseConfig(t)

t.Log("Creating a workspace")
wsPath, _ := framework.NewWorkspaceFixture(t, upstreamServer, orgPath, framework.TODO_WithoutMultiShardSupport())

Expand All @@ -592,6 +595,9 @@ func TestSyncWorkload(t *testing.T) {
require.NoError(t, err)
_, kubeconfigPath := framework.WriteLogicalClusterConfig(t, upstreamRawConfig, "base", wsPath)

tmcClusterClient, err := tmcclientset.NewForConfig(upstreamCfg)
require.NoError(t, err, "failed to construct client for server")

subCommand := []string{
"workload",
"sync",
Expand All @@ -603,7 +609,14 @@ func TestSyncWorkload(t *testing.T) {

framework.RunTMCCliPlugin(t, kubeconfigPath, subCommand)

framework.RunTMCCliPlugin(t, kubeconfigPath, subCommand)
ctx, cancelFunc := context.WithCancel(context.Background())
t.Cleanup(cancelFunc)

t.Log("Check initial workload")
cluster, err := tmcClusterClient.Cluster(wsPath).WorkloadV1alpha1().SyncTargets().Get(ctx, syncTargetName, metav1.GetOptions{})
require.NoError(t, err, "failed to get sync target", syncTargetName)
require.False(t, cluster.Spec.Unschedulable)
require.Nil(t, cluster.Spec.EvictAfter)
}

func TestCordonUncordonDrain(t *testing.T) {
Expand Down

0 comments on commit bb16974

Please sign in to comment.