Skip to content

Commit

Permalink
Cleanup test code
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Ding <[email protected]>
  • Loading branch information
Dyanngg committed Feb 28, 2022
1 parent e3562c0 commit 3bbd2f5
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 179 deletions.
148 changes: 0 additions & 148 deletions ci/jenkins/clean-mc.sh

This file was deleted.

26 changes: 13 additions & 13 deletions ci/jenkins/test-mc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ DEFAULT_KUBECONFIG_PATH=$DEFAULT_WORKDIR/kube.conf
WORKDIR=$DEFAULT_WORKDIR
TESTCASE=""
TEST_FAILURE=false
DOCKER_REGISTRY=$(head -n1 "/var/lib/jenkins/antrea/ci/docker-registry")
GO_VERSION=$(head -n1 "/var/lib/jenkins/antrea/build/images/deps/go-version")
DOCKER_REGISTRY=$(head -n1 "${WORKSPACE}/ci/docker-registry")
GO_VERSION=$(head -n1 "${WORKSPACE}/build/images/deps/go-version")
IMAGE_PULL_POLICY="Always"
MULTICLUSTER_KUBECONFIG_PATH=$WORKDIR/.kube
LEADER_CLUSTER_CONFIG="--kubeconfig=$MULTICLUSTER_KUBECONFIG_PATH/leader"
Expand Down Expand Up @@ -115,11 +115,11 @@ function cleanup_multicluster_ns {
function cleanup_multicluster_controller {
echo "====== Cleanup Multicluster Controller Installation ======"
kubeconfig=$1
for multicluster_yml in /var/lib/jenkins/antrea/multicluster/test/yamls/*.yml; do
for multicluster_yml in ${WORKSPACE}/multicluster/test/yamls/*.yml; do
kubectl delete -f $multicluster_yml $kubeconfig --ignore-not-found=true --timeout=30s || true
done

for multicluster_yml in /var/lib/jenkins/antrea/multicluster/build/yamls/*.yml; do
for multicluster_yml in ${WORKSPACE}/multicluster/build/yamls/*.yml; do
kubectl delete -f $multicluster_yml $kubeconfig --ignore-not-found=true --timeout=30s || true
done
}
Expand Down Expand Up @@ -278,17 +278,17 @@ function run_multicluster_e2e {

done

# set +e
# mkdir -p `pwd`/antrea-multicluster-test-logs
# go test -v antrea.io/antrea/multicluster/test/e2e --logs-export-dir `pwd`/antrea-multicluster-test-logs
# if [[ "$?" != "0" ]]; then
# TEST_FAILURE=true
# fi
# set -e
set +e
mkdir -p `pwd`/antrea-multicluster-test-logs
go test -v antrea.io/antrea/multicluster/test/e2e --logs-export-dir `pwd`/antrea-multicluster-test-logs
if [[ "$?" != "0" ]]; then
TEST_FAILURE=true
fi
set -e
}

#trap clean_multicluster EXIT
#clean_tmp
trap clean_multicluster EXIT
clean_tmp

if [[ ${TESTCASE} =~ "e2e" ]]; then
deliver_antrea_multicluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (r *ResourceExport) Default() {
if namespaceLabelVal, exists := r.Labels[common.SourceNamespace]; !exists || namespaceLabelVal != "" {
r.Labels[common.SourceNamespace] = ""
}
// TODO: put sourceClusterID for leader cluster?
if kindLabelVal, exists := r.Labels[common.SourceKind]; !exists || kindLabelVal != common.AntreaClusterNetworkPolicyKind {
r.Labels[common.SourceKind] = common.AntreaClusterNetworkPolicyKind
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,22 +377,24 @@ func (r *ResourceImportReconciler) handleResImpUpdateForClusterNetworkPolicy(ctx
tierKind, tierName := &v1alpha1.Tier{}, acnpObj.Spec.Tier
err = r.localClusterClient.Get(ctx, types.NamespacedName{Namespace: "", Name: tierName}, tierKind)
tierNotFound := apierrors.IsNotFound(err)
if acnpNotFound && !tierNotFound {
if err = r.localClusterClient.Create(ctx, acnpObj, &client.CreateOptions{}); err != nil {
klog.ErrorS(err, "failed to create imported Antrea ClusterNetworkPolicy", "acnp", klog.KObj(acnpObj))
return ctrl.Result{}, err
if !tierNotFound {
if acnpNotFound {
if err = r.localClusterClient.Create(ctx, acnpObj, &client.CreateOptions{}); err != nil {
klog.ErrorS(err, "failed to create imported Antrea ClusterNetworkPolicy", "acnp", klog.KObj(acnpObj))
return ctrl.Result{}, err
}
} else if !apiequality.Semantic.DeepEqual(acnp.Spec, acnpObj.Spec) {
acnp.Spec = acnpObj.Spec
if err = r.localClusterClient.Update(ctx, acnp, &client.UpdateOptions{}); err != nil {
klog.ErrorS(err, "failed to update imported Antrea ClusterNetworkPolicy", "acnp", klog.KObj(acnpObj))
return ctrl.Result{}, err
}
}
} else if !acnpNotFound && tierNotFound {
} else if tierNotFound && !acnpNotFound {
if err = r.localClusterClient.Delete(ctx, acnpObj, &client.DeleteOptions{}); err != nil {
klog.ErrorS(err, "failed to delete imported Antrea ClusterNetworkPolicy that no longer have a valid Tier for the current cluster", "acnp", klog.KObj(acnpObj))
return ctrl.Result{}, err
}
} else if !apiequality.Semantic.DeepEqual(acnp.Spec, acnpObj.Spec) {
acnp.Spec = acnpObj.Spec
if err = r.localClusterClient.Update(ctx, acnp, &client.UpdateOptions{}); err != nil {
klog.ErrorS(err, "failed to update imported Antrea ClusterNetworkPolicy", "acnp", klog.KObj(acnpObj))
return ctrl.Result{}, err
}
}
acnpImp := &multiclusterv1alpha1.ACNPImport{}
err = r.localClusterClient.Get(ctx, acnpImpName, acnpImp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func NewResourceExportReconciler(
// For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
func (r *ResourceExportReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
klog.InfoS("reconciling ResourceExport", "resourceexport", req.NamespacedName)
klog.V(2).InfoS("reconciling ResourceExport", "resourceexport", req.NamespacedName)
var resExport mcsv1alpha1.ResourceExport
if err := r.Client.Get(ctx, req.NamespacedName, &resExport); err != nil {
return ctrl.Result{}, client.IgnoreNotFound(err)
Expand All @@ -92,7 +92,6 @@ func (r *ResourceExportReconciler) Reconcile(ctx context.Context, req ctrl.Reque
// More details about using Finalizers, please refer to https://book.kubebuilder.io/reference/using-finalizers.html.
if !resExport.DeletionTimestamp.IsZero() {
if common.StringExistsInSlice(resExport.Finalizers, common.ResourceExportFinalizer) {
klog.Info("There are finalizers, handling delete event")
err := r.handleDeleteEvent(ctx, &resExport)
if err != nil {
return ctrl.Result{}, err
Expand All @@ -103,7 +102,6 @@ func (r *ResourceExportReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}
return ctrl.Result{}, nil
}
klog.Info("There are no finalizers, returning")
return ctrl.Result{}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ import (
)

var (
now = metav1.Now()
dropAction = v1alpha1.RuleActionDrop
svcLabels = map[string]string{
now = metav1.Now()
dropAction = v1alpha1.RuleActionDrop
svcLabels = map[string]string{
common.SourceNamespace: "default",
common.SourceName: "nginx",
common.SourceKind: "Service",
Expand Down

0 comments on commit 3bbd2f5

Please sign in to comment.