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 c132869
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 176 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 @@ -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 c132869

Please sign in to comment.