Convert all old tests to new tests (#7522)

* add an example task to test

* main test function: save progress

* a working example: routing request

* improve log info and error handling

* introduce makefile

* run each test as a subtest; remove common setup from test.sh

* add another test.sh: fault-injection

* improve error handling

* check test environment

* add two more test.sh files

* fix make command for istio setup

* update two test.sh files from upstream

* add comments and update README.md

* update test.sh files from upstream

* support multiple test names

* update README

* update README.md for new framework

* remove documentation of migration steps

* undo format changes

* change separation line to '# @cleanup'

* move go code and makefile from content/ to tests/

* change package name

* make for loop more readable

* change the set of auto-sourced scripts

* add docs for all functions

* approach to deal with folders with the same name

* minor fixes to ensure everything still runs

* fix make gen error

* add a TIMEOUT argument

* make sure util/debug.sh works with new framework

* make lint-go happy

* [BIG CHANGE] allow different istio setup configs

* make linters happy

* make linters happier

* changed wording and function orders

* make error return as the 2nd argument

* add TODOs

* Update content/en/docs/tasks/traffic-management/traffic-shifting/test.sh

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* Update tests/README.md

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* Update tests/README.md

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* Update tests/README.md

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* Update tests/README.md

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* Update tests/README.md

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* Update tests/README.md

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* only test english docs

* Update tests/README.md

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* allow test.sh as suffix

* move adding setup configs to tests/setup

* recommend full paths

* Update tests/README.md

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* require full test paths

* converting old tests to new tests: traffic-management and misc

* converting old tests to new tests: security

* remove old tests

* Update content/en/docs/tasks/security/cert-management/dns-cert/test.sh

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* simplify setup configs

* Update content/en/docs/tasks/security/authentication/authn-policy/test.sh

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* Update content/en/docs/tasks/security/authentication/mtls-migration/test.sh

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* Update content/en/docs/tasks/security/authorization/authz-http/test.sh

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* do not let istioctl prompt y/n

* Update content/en/docs/tasks/traffic-management/ingress/ingress-sni-passthrough/test.sh

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* Update content/en/docs/tasks/traffic-management/ingress/secure-ingress/test.sh

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* Update content/en/docs/tasks/security/cert-management/plugin-ca-cert/test.sh

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* simplify stuff

* rename dns-cert test.sh to test_broken.sh

* fix dns-cert doc and test

* remove egress=disabled

* fix test

* Update content/en/docs/tasks/observability/logs/access-log/test.sh

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

* Update content/en/docs/tasks/security/authentication/authn-policy/test.sh

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>
This commit is contained in:
Hongyi Zhang 2020-06-11 18:15:48 +00:00 committed by GitHub
parent bce48d42e7
commit 5fbb14bedc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 165 additions and 1978 deletions

View File

@ -160,12 +160,15 @@ endif
@export TAG
@echo "TAG=${TAG}"
# old test framework
include tests/old_tests.mk
# new test framework
# doc test framework
include tests/tests.mk
# remains of old framework to pass istio-testing
test.kube.presubmit: doc.test
# remains of old framework to pass istio-testing
test.kube.postsubmit: test.kube.presubmit
test_status:
@scripts/test_status.sh

View File

@ -19,8 +19,9 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/examples/bookinfo/snips.sh"
source "${REPO_ROOT}/tests/util/samples.sh"
source "tests/util/samples.sh"
# @setup profile=demo
# remove the injection label to prevent the following command from failing
kubectl label namespace default istio-injection-
@ -51,3 +52,7 @@ _set_ingress_environment_variables
snip_determine_the_ingress_ip_and_port_3
_verify_contains snip_confirm_the_app_is_accessible_from_outside_the_cluster_1 "$snip_confirm_the_app_is_accessible_from_outside_the_cluster_1_out"
# @cleanup
set +e # ignore cleanup errors
snip_cleanup_1

View File

@ -19,7 +19,7 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/ops/configuration/mesh/app-health-check/snips.sh"
# @setup profile=default
snip_liveness_and_readiness_probes_with_command_option_1
@ -71,3 +71,8 @@ kubectl -n istio-sep-port rollout status deployment liveness-http --timeout 60s
_verify_like snip_separate_port_2 "$snip_separate_port_2_out"
kubectl -n istio-sep-port delete -f samples/health-check/liveness-http.yaml
# @cleanup
set +e # ignore cleanup errors
snip_cleanup_1
kubectl delete ns health-annotate

View File

@ -19,8 +19,9 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/observability/logs/access-log/snips.sh"
source "${REPO_ROOT}/tests/util/samples.sh"
source "tests/util/samples.sh"
# @setup profile=demo
# Install Istio with access logging enabled
_verify_elided snip_enable_envoys_access_logging_1 "$snip_enable_envoys_access_logging_1_out"
@ -44,3 +45,8 @@ _verify_contains snip_test_the_access_log_1 "-=[ teapot ]=-"
# Check the logs
_verify_contains snip_test_the_access_log_2 "outbound|8000||httpbin.default.svc.cluster.local"
_verify_contains snip_test_the_access_log_3 "inbound|8000|http|httpbin.default.svc.cluster.local"
# @cleanup
set +e # ignore cleanup errors
snip_cleanup_1
snip_disable_envoys_access_logging_1

View File

@ -21,7 +21,7 @@ the underlying concepts in the [authentication overview](/docs/concepts/security
[installation steps](/docs/setup/getting-started).
{{< text bash >}}
$ istioctl install
$ istioctl install --set profile=default
{{< /text >}}
### Setup

View File

@ -21,7 +21,7 @@
####################################################################################################
snip_before_you_begin_1() {
istioctl install
istioctl install --set profile=default
}
snip_setup_1() {

View File

@ -19,7 +19,8 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/security/authentication/authn-policy/snips.sh"
# @setup profile=default
_wait_for_deployment istio-system istiod
snip_setup_1
@ -98,3 +99,11 @@ snip_require_valid_tokens_perpath_1
_verify_same snip_require_valid_tokens_perpath_2 "$snip_require_valid_tokens_perpath_2_out"
_verify_same snip_require_valid_tokens_perpath_3 "$snip_require_valid_tokens_perpath_3_out"
# @cleanup
set +e # ignore cleanup errors
snip_cleanup_part_1_1
snip_cleanup_part_2_1
snip_cleanup_part_3_1
snip_cleanup_part_3_2
snip_cleanup_part_3_3

View File

@ -19,7 +19,7 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/security/authentication/mtls-migration/snips.sh"
# @setup profile=demo
# create_ns_foo_bar_legacy
snip_set_up_the_cluster_1
@ -75,3 +75,7 @@ _verify_same snip_lock_down_mutual_tls_for_the_entire_mesh_2 "$expected"
# Restore error handling
set -e
set -o pipefail
# @cleanup
snip_clean_up_the_example_1
snip_clean_up_the_example_2

View File

@ -19,7 +19,7 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/security/authorization/authz-deny/snips.sh"
# @setup profile=default
# Set retries to a higher value for some flakiness.
# TODO: remove this when istioctl wait calls are added
@ -51,3 +51,7 @@ _verify_same snip_explicitly_deny_a_request_8 "$snip_explicitly_deny_a_request_8
_verify_same snip_explicitly_deny_a_request_9 "$snip_explicitly_deny_a_request_9_out"
_verify_same snip_explicitly_deny_a_request_10 "$snip_explicitly_deny_a_request_10_out"
# @cleanup
set +e # ignore cleanup errors
snip_clean_up_1

View File

@ -19,8 +19,9 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/security/authorization/authz-http/snips.sh"
source "${REPO_ROOT}/tests/util/samples.sh"
source "tests/util/samples.sh"
# @setup profile=default
REPEAT=${REPEAT:-100}
THRESHOLD=${THRESHOLD:-1}
@ -114,3 +115,11 @@ snip_configure_access_control_for_workloads_using_http_traffic_5
# Verify we now have access.
verify 200 "William Shakespeare" "Book Details" "Book Reviews"
# @cleanup
set +e # ignore cleanup errors
snip_clean_up_1
# remaining cleanup (undocumented).
cleanup_bookinfo_sample
cleanup_sleep_sample
kubectl delete -f samples/bookinfo/networking/virtual-service-reviews-v3.yaml

View File

@ -19,7 +19,7 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/security/authorization/authz-ingress/snips.sh"
# @setup profile=default
export CLIENT_IP
@ -49,3 +49,8 @@ _verify_same snip_ipbased_allow_list_and_deny_list_4 "$snip_ipbased_allow_list_a
snip_ipbased_allow_list_and_deny_list_5
_verify_same snip_ipbased_allow_list_and_deny_list_6 "$snip_ipbased_allow_list_and_deny_list_6_out"
# @cleanup
set +e # ignore cleanup errors
snip_clean_up_1
snip_clean_up_2

View File

@ -19,7 +19,7 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/security/authorization/authz-jwt/snips.sh"
# @setup profile=default
# Set retries to a higher value for some flakiness.
# TODO: remove this when istioctl wait calls are added
@ -69,3 +69,7 @@ TOKEN_GROUP=$(curl "${TOKEN_GROUP_URL}" -s)
_verify_same snip_allow_requests_with_valid_jwt_and_listtyped_claims_10 "$snip_allow_requests_with_valid_jwt_and_listtyped_claims_10_out"
_verify_same snip_allow_requests_with_valid_jwt_and_listtyped_claims_11 "$snip_allow_requests_with_valid_jwt_and_listtyped_claims_11_out"
# @cleanup
set +e # ignore cleanup errors
snip_clean_up_1

View File

@ -19,7 +19,7 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/security/authorization/authz-tcp/snips.sh"
# @setup profile=default
snip_before_you_begin_1
@ -62,3 +62,7 @@ snip_configure_access_control_for_a_tcp_workload_8
_verify_same snip_configure_access_control_for_a_tcp_workload_9 "$snip_configure_access_control_for_a_tcp_workload_9_out"
_verify_same snip_configure_access_control_for_a_tcp_workload_10 "$snip_configure_access_control_for_a_tcp_workload_10_out"
# @cleanup
set +e # ignore cleanup errors
snip_clean_up_1

View File

@ -27,13 +27,12 @@ $ cat <<EOF > ./istio.yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
values:
global:
certificates:
- secretName: dns.example1-service-account
dnsNames: [example1.istio-system.svc, example1.istio-system]
- secretName: dns.example2-service-account
dnsNames: [example2.istio-system.svc, example2.istio-system]
meshConfig:
certificates:
- secretName: dns.example1-service-account
dnsNames: [example1.istio-system.svc, example1.istio-system]
- secretName: dns.example2-service-account
dnsNames: [example2.istio-system.svc, example2.istio-system]
EOF
$ istioctl install -f ./istio.yaml
{{< /text >}}

View File

@ -25,13 +25,12 @@ cat <<EOF > ./istio.yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
values:
global:
certificates:
- secretName: dns.example1-service-account
dnsNames: [example1.istio-system.svc, example1.istio-system]
- secretName: dns.example2-service-account
dnsNames: [example2.istio-system.svc, example2.istio-system]
meshConfig:
certificates:
- secretName: dns.example1-service-account
dnsNames: [example1.istio-system.svc, example1.istio-system]
- secretName: dns.example2-service-account
dnsNames: [example2.istio-system.svc, example2.istio-system]
EOF
istioctl install -f ./istio.yaml
}

View File

@ -21,7 +21,12 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/security/cert-management/dns-cert/snips.sh"
# @setup profile=none
export VERIFY_RETRIES=10
snip_before_you_begin_1
_wait_for_deployment istio-system istiod
# helper functions
check_dns_certs() {
@ -36,3 +41,7 @@ _verify_contains check_dns_certs "$snip_check_the_provisioning_of_dns_certificat
snip_regenerating_a_dns_certificate_1
_verify_contains regen_dns_certs "$snip_regenerating_a_dns_certificate_3"
# @cleanup
set +e # ignore cleanup errors
snip_cleanup_1

View File

@ -19,7 +19,11 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/security/cert-management/plugin-ca-cert/snips.sh"
# @setup profile=none
snip_plugging_in_existing_certificates_and_key_1
snip_plugging_in_existing_certificates_and_key_2
_wait_for_deployment istio-system istiod
# create_ns_foo_with_httpbin_sleep
snip_deploying_example_services_1
@ -47,3 +51,7 @@ _verify_same snip_verifying_the_certificates_3 "$snip_verifying_the_certificates
_verify_same snip_verifying_the_certificates_4 "$snip_verifying_the_certificates_4_out"
_verify_same snip_verifying_the_certificates_5 "$snip_verifying_the_certificates_5_out"
# @cleanup
set +e # ignore cleanup errors
snip_cleanup_1

View File

@ -19,8 +19,9 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/traffic-management/circuit-breaking/snips.sh"
source "${REPO_ROOT}/tests/util/samples.sh"
source "tests/util/samples.sh"
# @setup profile=default
kubectl label namespace default istio-injection=enabled --overwrite
@ -71,3 +72,8 @@ cluster.outbound|8000||httpbin.istio-io-circuitbreaker.svc.cluster.local.upstrea
cluster.outbound|8000||httpbin.istio-io-circuitbreaker.svc.cluster.local.upstream_rq_pending_overflow: ...
cluster.outbound|8000||httpbin.istio-io-circuitbreaker.svc.cluster.local.upstream_rq_pending_total: ..."
_verify_like snip_tripping_the_circuit_breaker_5 "$expected"
# @cleanup
set +e # ignore cleanup errors
snip_cleaning_up_1
snip_cleaning_up_2

View File

@ -19,8 +19,9 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/traffic-management/egress/egress-tls-origination/snips.sh"
source "${REPO_ROOT}/tests/util/samples.sh"
source "tests/util/samples.sh"
# @setup profile=default
# Deploy sample and set up variable pointing to it
startup_sleep_sample
@ -34,3 +35,8 @@ _verify_elided snip_curl_simple "$snip_curl_simple_out"
snip_apply_origination
_verify_elided snip_curl_origination_http "$snip_curl_origination_http_out"
_verify_elided snip_curl_origination_https "$snip_curl_origination_https_out"
# @cleanup
set +e # ignore cleanup errors
snip_cleanup_1
snip_cleanup_2

View File

@ -19,8 +19,9 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/traffic-management/ingress/ingress-control/snips.sh"
source "${REPO_ROOT}/tests/util/samples.sh"
source "tests/util/samples.sh"
# @setup profile=default
kubectl label namespace default istio-injection=enabled --overwrite
@ -68,3 +69,7 @@ curl_httpbin_headers() {
# access httpbin without host header
_verify_contains curl_httpbin_headers "HTTP/1.1 200 OK"
# @cleanup
set +e # ignore cleanup errors
snip_cleanup_1

View File

@ -19,7 +19,7 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/traffic-management/ingress/ingress-sni-passthrough/snips.sh"
# @setup profile=default
kubectl label namespace default istio-injection=enabled --overwrite
@ -48,3 +48,9 @@ snip_configure_an_ingress_gateway_2
# validate the output
_verify_contains snip_configure_an_ingress_gateway_3 "SSL certificate verify ok."
# @cleanup
set +e # ignore cleanup errors
snip_cleanup_1
snip_cleanup_2
snip_cleanup_3

View File

@ -19,8 +19,9 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/traffic-management/ingress/secure-ingress/snips.sh"
source "${REPO_ROOT}/tests/util/samples.sh"
source "tests/util/samples.sh"
# @setup profile=default
kubectl label namespace default istio-injection=enabled --overwrite
@ -109,3 +110,9 @@ _verify_lines snip_configure_a_mutual_tls_ingress_gateway_5 "
+ HTTP/2 418
+ -=[ teapot ]=-
"
# @cleanup
set +e # ignore cleanup errors
snip_cleanup_1
snip_cleanup_2
snip_cleanup_3

View File

@ -21,7 +21,7 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/traffic-management/mirroring/snips.sh"
# @setup profile=default
kubectl label namespace default istio-injection=enabled --overwrite
@ -67,3 +67,8 @@ snip_mirroring_traffic_to_v2_2
_verify_contains snip_mirroring_traffic_to_v2_3 "GET /headers HTTP/1.1"
_verify_contains snip_mirroring_traffic_to_v2_4 "GET /headers HTTP/1.1"
# @cleanup
set +e # ignore cleanup errors
snip_cleaning_up_1
snip_cleaning_up_2

View File

@ -19,8 +19,9 @@ set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/traffic-management/request-timeouts/snips.sh"
source "${REPO_ROOT}/tests/util/samples.sh"
source "tests/util/samples.sh"
# @setup profile=default
kubectl label namespace default istio-injection=enabled --overwrite
startup_sleep_sample # needed for sending test requests with curl
@ -58,3 +59,9 @@ sleep 5s # TODO: call proper wait utility (e.g., istioctl wait)
# verify product reviews are unavailable
_verify_contains get_productpage "Sorry, product reviews are currently unavailable for this book."
# @cleanup
set +e # ignore cleanup errors
snip_cleanup_1
cleanup_bookinfo_sample
cleanup_sleep_sample

View File

@ -189,7 +189,7 @@ You can also find this information by running `make doc.test.help`. The bash tra
Use the following command:
```bash
TEST_ENV=kind ADDITIONAL_CONTAINER_OPTIONS="--network host" make test.kube.presubmit
TEST_ENV=kind ADDITIONAL_CONTAINER_OPTIONS="--network host" make doc.test
```
1. If HUB and TAG aren't set, then their default values will match what is used by the prow tests.

View File

@ -1,44 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package configuration
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
// https://istio.io/docs/ops/configuration/mesh/app-health-check/
func TestHealthCheck(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("ops__configuration__mesh__app_health_check").
Add(istioio.Script{
Input: istioio.Path("scripts/liveness_and_readiness_probes.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/ops/configuration/mesh/app-health-check/snips.sh
snip_cleanup_1
kubectl delete ns health-annotate`,
},
}).
Build())
}

View File

@ -1,37 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package configuration
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/label"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
inst istio.Instance
)
func TestMain(m *testing.M) {
framework.
NewSuite("configuration", m).
Label(label.CustomSetup).
SetupOnEnv(environment.Kube, istio.Setup(&inst, nil)).
RequireEnvironment(environment.Kube).
Run()
}

View File

@ -1,42 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package examples
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestBookinfo(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("examples__bookinfo").
Add(istioio.Script{
Input: istioio.Path("scripts/bookinfo.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/examples/bookinfo/snips.sh
snip_cleanup_1`,
},
}).
Build())
}

View File

@ -1,44 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package examples
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/label"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
ist istio.Instance
)
const profileDemo = "profile: demo"
func TestMain(m *testing.M) {
// Integration test for the Bookinfo flow.
framework.
NewSuite("examples", m).
Label(label.CustomSetup).
SetupOnEnv(environment.Kube, istio.Setup(&ist, setupConfig)).
RequireEnvironment(environment.Kube).
Run()
}
func setupConfig(cfg *istio.Config) {
cfg.ControlPlaneValues = profileDemo
}

View File

@ -1,43 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package observability
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestAccessLog(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__observability__logs__access-log").
Add(istioio.Script{
Input: istioio.Path("scripts/access_log.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/observability/logs/access-log/snips.sh
snip_cleanup_1
snip_disable_envoys_access_logging_1`,
},
}).
Build())
}

View File

@ -1,44 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package observability
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/label"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
ist istio.Instance
)
const profileDemo = "profile: demo"
func TestMain(m *testing.M) {
// Integration test for the Bookinfo flow.
framework.
NewSuite("observability", m).
Label(label.CustomSetup).
SetupOnEnv(environment.Kube, istio.Setup(&ist, setupConfig)).
RequireEnvironment(environment.Kube).
Run()
}
func setupConfig(cfg *istio.Config) {
cfg.ControlPlaneValues = profileDemo
}

View File

@ -1,51 +0,0 @@
# The following flags (in addition to ${V}) can be specified on the command-line, or the environment. This
# is primarily used by the CI systems.
_INTEGRATION_TEST_FLAGS ?= $(INTEGRATION_TEST_FLAGS)
# $(CI) specifies that the test is running in a CI system. This enables CI specific logging.
ifneq ($(CI),)
_INTEGRATION_TEST_FLAGS += --istio.test.ci
_INTEGRATION_TEST_FLAGS += --istio.test.pullpolicy=IfNotPresent
endif
ifeq ($(TEST_ENV),minikube)
_INTEGRATION_TEST_FLAGS += --istio.test.kube.minikube
else ifeq ($(TEST_ENV),minikube-none)
_INTEGRATION_TEST_FLAGS += --istio.test.kube.minikube
else ifeq ($(TEST_ENV),kind)
_INTEGRATION_TEST_FLAGS += --istio.test.kube.minikube
endif
ifneq ($(ARTIFACTS),)
_INTEGRATION_TEST_FLAGS += --istio.test.work_dir=$(ARTIFACTS)
endif
ifneq ($(HUB),)
_INTEGRATION_TEST_FLAGS += --istio.test.hub=$(HUB)
endif
# $(INTEGRATION_TEST_KUBECONFIG) specifies the kube config file to be used. If not specified, then
# ~/.kube/config is used.
# TODO: This probably needs to be more intelligent and take environment variables into account.
KUBECONFIG ?= ~/.kube/config
_INTEGRATION_TEST_FLAGS += --istio.test.kube.config=$(KUBECONFIG)
test.kube.presubmit: init | $(JUNIT_REPORT)
$(eval INTEGRATION_TEST_FLAGS += --istio.test.tag=$(TAG))
PATH=${PATH}:${ISTIO_OUT} $(GO) test -p 1 ${T} ./tests/... -timeout 30m \
--istio.test.select -postsubmit,-flaky \
--istio.test.env kube \
${_INTEGRATION_TEST_FLAGS} \
2>&1 | tee >($(JUNIT_REPORT) > $(JUNIT_OUT))
test.kube.postsubmit: test.kube.presubmit
test.kube.%: init | $(JUNIT_REPORT)
$(eval INTEGRATION_TEST_FLAGS += --istio.test.tag=$(TAG))
PATH=${PATH}:${ISTIO_OUT} $(GO) test -p 1 ${T} ./tests/$(subst .,/,$*)/... -timeout 30m \
--istio.test.select -postsubmit,-flaky \
--istio.test.env kube \
--log_output_level=script:debug \
${_INTEGRATION_TEST_FLAGS} \
2>&1 | tee >($(JUNIT_REPORT) > $(JUNIT_OUT))

View File

@ -1,50 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package authnpolicy
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
//https://istio.io/docs/tasks/security/authentication/authn-policy/
//https://github.com/istio/istio.io/blob/release-1.5/content/en/docs/tasks/security/authentication/authn-policy/index.md
func TestAuthnPolicy(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__security___authn_policy").
Add(istioio.Script{
Input: istioio.Path("scripts/authn_policy.sh"),
}).
// Cleanup.
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/security/authentication/authn-policy/snips.sh
snip_cleanup_part_1_1
snip_cleanup_part_2_1
snip_cleanup_part_3_1
snip_cleanup_part_3_2
snip_cleanup_part_3_3`,
},
}).
Build())
}

View File

@ -1,34 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package authnpolicy
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
ist istio.Instance
)
func TestMain(m *testing.M) {
framework.NewSuite("authn_policy", m).
SetupOnEnv(environment.Kube, istio.Setup(&ist, nil)).
RequireEnvironment(environment.Kube).
Run()
}

View File

@ -1,46 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package authzdeny
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
//https://istio.io/docs/tasks/security/authorization/authz-deny/
//https://github.com/istio/istio.io/blob/release-1.5/content/en/docs/tasks/security/authorization/authz-deny/index.md
func TestAuthzDeny(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__security___authz_deny").
Add(istioio.Script{
Input: istioio.Path("scripts/authz_deny.sh"),
}).
// Cleanup.
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/security/authorization/authz-deny/snips.sh
snip_clean_up_1`,
},
}).
Build())
}

View File

@ -1,34 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package authzdeny
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
ist istio.Instance
)
func TestMain(m *testing.M) {
framework.NewSuite("authz_deny", m).
SetupOnEnv(environment.Kube, istio.Setup(&ist, nil)).
RequireEnvironment(environment.Kube).
Run()
}

View File

@ -1,49 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package security
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
// TestAuthorizationForHTTPServices simulates the task in https://www.istio.io/docs/tasks/security/authz-http/
func TestAuthorizationForHTTPServices(t *testing.T) {
//t.Skip("https://github.com/istio/istio/issues/18511")
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__security__authorization_for_http_services").
Add(istioio.Script{
Input: istioio.Path("scripts/authz_http.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/security/authorization/authz-http/snips.sh
source ${REPO_ROOT}/tests/util/samples.sh
snip_clean_up_1
# remaining cleanup (undocumented).
cleanup_bookinfo_sample
cleanup_sleep_sample
kubectl delete -f samples/bookinfo/networking/virtual-service-reviews-v3.yaml
`,
},
}).Build())
}

View File

@ -1,47 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package authzingress
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
//https://istio.io/docs/tasks/security/authorization/authz-ingress/
//https://github.com/istio/istio.io/blob/release-1.5/content/en/docs/tasks/security/authorization/authz-ingress/index.md
func TestAuthzIngress(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__security___authz_ingress").
Add(istioio.Script{
Input: istioio.Path("scripts/authz_ingress.sh"),
}).
// Cleanup.
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/security/authorization/authz-ingress/snips.sh
snip_clean_up_1
snip_clean_up_2`,
},
}).
Build())
}

View File

@ -1,34 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package authzingress
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
ist istio.Instance
)
func TestMain(m *testing.M) {
framework.NewSuite("authz_ingress", m).
SetupOnEnv(environment.Kube, istio.Setup(&ist, nil)).
RequireEnvironment(environment.Kube).
Run()
}

View File

@ -1,46 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package authzjwt
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
//https://istio.io/docs/tasks/security/authorization/authz-jwt/
//https://github.com/istio/istio.io/blob/release-1.5/content/en/docs/tasks/security/authorization/authz-jwt/index.md
func TestAuthzJWT(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__security___authz_jwt").
Add(istioio.Script{
Input: istioio.Path("scripts/authz_jwt.sh"),
}).
// Cleanup.
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/security/authorization/authz-jwt/snips.sh
snip_clean_up_1`,
},
}).
Build())
}

View File

@ -1,34 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package authzjwt
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
ist istio.Instance
)
func TestMain(m *testing.M) {
framework.NewSuite("authz_jwt", m).
SetupOnEnv(environment.Kube, istio.Setup(&ist, nil)).
RequireEnvironment(environment.Kube).
Run()
}

View File

@ -1,46 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package authztcp
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
//https://istio.io/docs/tasks/security/authorization/authz-tcp/
//https://github.com/istio/istio.io/blob/release-1.5/content/en/docs/tasks/security/authorization/authz-tcp/index.md
func TestAuthzTCP(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__security___authz_tcp").
Add(istioio.Script{
Input: istioio.Path("scripts/authz_tcp.sh"),
}).
// Cleanup.
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/security/authorization/authz-tcp/snips.sh
snip_clean_up_1`,
},
}).
Build())
}

View File

@ -1,34 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package authztcp
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
ist istio.Instance
)
func TestMain(m *testing.M) {
framework.NewSuite("authz_tcp", m).
SetupOnEnv(environment.Kube, istio.Setup(&ist, nil)).
RequireEnvironment(environment.Kube).
Run()
}

View File

@ -1,45 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package dnscert
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
//https://istio.io/docs/tasks/security/cert-management/dns-cert/
//https://github.com/istio/istio.io/blob/release-1.5/content/en/docs/tasks/security/cert-management/dns-cert/index.md
func TestDNSCert(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__security___dns_cert").
Add(istioio.Script{
Input: istioio.Path("scripts/dns_cert.sh"),
}).
// Cleanup.
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/security/cert-management/dns-cert/snips.sh
snip_cleanup_1`,
},
}).
Build())
}

View File

@ -1,51 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package dnscert
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/label"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
ist istio.Instance
)
func TestMain(m *testing.M) {
framework.NewSuite("dns_cert", m).
Label(label.CustomSetup).
SetupOnEnv(environment.Kube, istio.Setup(&ist, setupConfig)).
RequireEnvironment(environment.Kube).
Run()
}
func setupConfig(cfg *istio.Config) {
if cfg == nil {
return
}
cfg.ControlPlaneValues = `
values:
meshConfig:
certificates:
- secretName: dns.example1-service-account
dnsNames: [example1.istio-system.svc, example1.istio-system]
- secretName: dns.example2-service-account
dnsNames: [example2.istio-system.svc, example2.istio-system]
`
}

View File

@ -1,45 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package security
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/label"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
ist istio.Instance
)
func TestMain(m *testing.M) {
framework.NewSuite("security", m).
Label(label.CustomSetup).
SetupOnEnv(environment.Kube, istio.Setup(&ist, setupConfig)).
RequireEnvironment(environment.Kube).
Run()
}
//grafana is disabled in the default test framework config. Enable it.
func setupConfig(cfg *istio.Config) {
if cfg == nil {
return
}
cfg.Values["grafana.enabled"] = "true"
}

View File

@ -1,46 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package security
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
//https://istio.io/docs/tasks/security/mtls-migration/
//https://github.com/istio/istio.io/blob/release-1.2/content/docs/tasks/security/mtls-migration/index.md
func TestMutualTLSMigration(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__security__mututal_tls_migration").
Add(istioio.Script{
Input: istioio.Path("scripts/mtls_migration.sh"),
}).
// Cleanup.
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
source ${REPO_ROOT}/content/en/docs/tasks/security/authentication/mtls-migration/snips.sh
snip_clean_up_the_example_1
snip_clean_up_the_example_2`,
},
}).
Build())
}

View File

@ -1,37 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package plugincacert
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/label"
"istio.io/istio/pkg/test/framework/resource/environment"
"istio.io/istio/tests/integration/security/util/cert"
)
var (
ist istio.Instance
)
func TestMain(m *testing.M) {
framework.NewSuite("plugin_ca_cert", m).
Label(label.CustomSetup).
SetupOnEnv(environment.Kube, istio.Setup(&ist, nil, cert.CreateCASecret)).
RequireEnvironment(environment.Kube).
Run()
}

View File

@ -1,46 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package plugincacert
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
//https://istio.io/docs/tasks/security/cert-management/plugin-ca-cert/
//https://github.com/istio/istio.io/blob/release-1.5/content/en/docs/tasks/security/cert-management/plugin-ca-cert/index.md
func TestPluginCACert(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__security___plugin_ca_cert").
Add(istioio.Script{
Input: istioio.Path("scripts/plugin_ca_cert.sh"),
}).
// Cleanup.
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/security/cert-management/plugin-ca-cert/snips.sh
snip_cleanup_1`,
},
}).
Build())
}

View File

@ -9,8 +9,8 @@ doc.test: init
doc.test.help:
@echo "The command \"make doc.test\" accepts three optional environment variables."
@echo -e "TEST: \n\tSpecify the test(s) to run using the directory name. Default is all."
@echo -e "TEST: \n\tSpecify the test(s) to run using the directory path relative to content/en/docs. Default is all."
@echo -e "\tMultiple test names can be specified by separating them by commas."
@echo -e "TIMEOUT: \n\tSet the time limit exceeding which all tests will halt. Default is 30m."
@echo -e "ENV: \n\tTest environment. This should be either native or kube. Default is kube."
@echo -e "Example: \n\tmake doc.test TEST=request-routing,fault-injection TIMEOUT=1h"
@echo -e "Example: \n\tmake doc.test TEST=tasks/traffic-management TIMEOUT=1h"

View File

@ -1,42 +0,0 @@
// Copyright 2020 Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package trafficmanagement
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestCircuitBreaking(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__traffic_management__circuit_breaking").
Add(istioio.Script{
Input: istioio.Path("scripts/circuit_breaking.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/traffic-management/circuit-breaking/snips.sh
snip_cleaning_up_1
snip_cleaning_up_2`,
},
}).
Build())
}

View File

@ -1,37 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package egress
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
inst istio.Instance
)
func TestMain(m *testing.M) {
// Integration test for Egress
framework.
NewSuite("trafficmanagement_egress", m).
SetupOnEnv(environment.Kube, istio.Setup(&inst, nil)).
RequireEnvironment(environment.Kube).
Run()
}

View File

@ -1,43 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package egress
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestTlsOrigination(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__traffic_management__egress_tls_origination").
Add(istioio.Script{
Input: istioio.Path("scripts/tls_origination.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source "${REPO_ROOT}/content/en/docs/tasks/traffic-management/egress/egress-tls-origination/snips.sh"
snip_cleanup_1
snip_cleanup_2`,
},
}).
Build())
}

View File

@ -1,45 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package trafficmanagement
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestFaultInjection(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__traffic_management__fault_injection").
Add(istioio.Script{
Input: istioio.Path("scripts/fault_injection.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/traffic-management/fault-injection/snips.sh
source ${REPO_ROOT}/tests/util/samples.sh
snip_cleanup_1
cleanup_bookinfo_sample
cleanup_sleep_sample`,
},
}).
Build())
}

View File

@ -1,42 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ingress
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestIngressControl(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__traffic_management__ingress_control").
Add(istioio.Script{
Input: istioio.Path("scripts/ingress_control.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/traffic-management/ingress/ingress-control/snips.sh
snip_cleanup_1`,
},
}).
Build())
}

View File

@ -1,44 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ingress
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestIngressSNIPassthrough(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__traffic_management__ingress_sni_passthrough").
Add(istioio.Script{
Input: istioio.Path("scripts/ingress_sni_passthrough.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/traffic-management/ingress/ingress-sni-passthrough/snips.sh
snip_cleanup_1
snip_cleanup_2
snip_cleanup_3`,
},
}).
Build())
}

View File

@ -1,46 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ingress
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/label"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
inst istio.Instance
)
func TestMain(m *testing.M) {
// Integration test for the ingress SDS Gateway flow.
framework.
NewSuite("trafficmanagement_ingress", m).
Label(label.CustomSetup).
SetupOnEnv(environment.Kube, istio.Setup(&inst, setupForSDS)).
RequireEnvironment(environment.Kube).
Run()
}
func setupForSDS(cfg *istio.Config) {
if cfg == nil {
return
}
cfg.Values["gateways.istio-egressgateway.enabled"] = "false"
}

View File

@ -1,44 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ingress
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestSecureIngress(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__traffic_management__secure_ingress").
Add(istioio.Script{
Input: istioio.Path("scripts/secure_ingress.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/traffic-management/ingress/secure-ingress/snips.sh
snip_cleanup_1
snip_cleanup_2
snip_cleanup_3`,
},
}).
Build())
}

View File

@ -1,35 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package trafficmanagement
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/resource/environment"
)
var (
inst istio.Instance
)
func TestMain(m *testing.M) {
framework.
NewSuite("trafficmanagement", m).
SetupOnEnv(environment.Kube, istio.Setup(&inst, nil)).
RequireEnvironment(environment.Kube).
Run()
}

View File

@ -1,44 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package trafficmanagement
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestMirroring(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__traffic_management__mirroring").
Add(istioio.Script{
Input: istioio.Path("scripts/mirroring.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/traffic-management/mirroring/snips.sh
snip_cleaning_up_1
snip_cleaning_up_2
`,
},
}).
Build())
}

View File

@ -1,45 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package trafficmanagement
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestRequestRouting(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__traffic_management__request_routing").
Add(istioio.Script{
Input: istioio.Path("scripts/request_routing.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/traffic-management/request-routing/snips.sh
source ${REPO_ROOT}/tests/util/samples.sh
snip_cleanup_1
cleanup_bookinfo_sample
cleanup_sleep_sample`,
},
}).
Build())
}

View File

@ -1,45 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package trafficmanagement
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestRequestTimeouts(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__traffic_management__request_timeouts").
Add(istioio.Script{
Input: istioio.Path("scripts/request_timeouts.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/traffic-management/request-timeouts/snips.sh
source ${REPO_ROOT}/tests/util/samples.sh
snip_cleanup_1
cleanup_bookinfo_sample
cleanup_sleep_sample`,
},
}).
Build())
}

View File

@ -1,65 +0,0 @@
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC2154
# Copyright Istio Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/traffic-management/fault-injection/snips.sh"
source "${REPO_ROOT}/tests/util/samples.sh"
# helper functions
get_bookinfo_productpage() {
sample_http_request "/productpage"
}
get_bookinfo_productpage_jason() {
sample_http_request "/productpage" "jason"
}
kubectl label namespace default istio-injection=enabled --overwrite
startup_sleep_sample # needed for sending test requests with curl
# launch the bookinfo app
startup_bookinfo_sample
# set route rules
snip_before_you_begin_1
# inject the delay fault
snip_injecting_an_http_delay_fault_1
# wait for rules to propagate
sleep 5s # TODO: call proper wait utility (e.g., istioctl wait)
# confirm rules are set
_verify_elided snip_injecting_an_http_delay_fault_2 "$snip_injecting_an_http_delay_fault_2_out"
# check that requests from user jason return error
_verify_contains get_bookinfo_productpage_jason "$snip_testing_the_delay_configuration_1"
# inject the abort fault
snip_injecting_an_http_abort_fault_1
# wait for rules to propagate
sleep 5s # TODO: call proper wait utility (e.g., istioctl wait)
# confirm rules are set
_verify_elided snip_injecting_an_http_abort_fault_2 "$snip_injecting_an_http_abort_fault_2_out"
# check that requests from user jason return error and other request do not
_verify_contains get_bookinfo_productpage_jason "Ratings service is currently unavailable"
_verify_not_contains get_bookinfo_productpage "Ratings service is currently unavailable"

View File

@ -1,70 +0,0 @@
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC2154
# Copyright Istio Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/traffic-management/request-routing/snips.sh"
source "${REPO_ROOT}/tests/util/samples.sh"
# helper functions
get_bookinfo_productpage() {
sample_http_request "/productpage"
}
get_bookinfo_productpage_jason() {
sample_http_request "/productpage" "jason"
}
kubectl label namespace default istio-injection=enabled --overwrite
startup_sleep_sample # needed for sending test requests with curl
# launch the bookinfo app
startup_bookinfo_sample
# set default route rules
snip_apply_a_virtual_service_1
# wait for rules to propagate
sleep 5s # TODO: call proper wait utility (e.g., istioctl wait)
# confirm route rules are set
_verify_elided snip_apply_a_virtual_service_2 "$snip_apply_a_virtual_service_2_out"
# check destination rules
_verify_lines snip_apply_a_virtual_service_3 "
+ productpage
+ reviews
+ ratings
+ details
"
# check that requests do not return ratings
_verify_not_contains get_bookinfo_productpage "glyphicon glyphicon-star"
# route traffic for user jason to reviews:v2
snip_route_based_on_user_identity_1
# wait for rules to propagate
sleep 5s # TODO: call proper wait utility (e.g., istioctl wait)
# confirm route rules are set
_verify_elided snip_route_based_on_user_identity_2 "$snip_route_based_on_user_identity_2_out"
# check that requests from user jason return ratings and other requests do not
_verify_contains get_bookinfo_productpage_jason "glyphicon glyphicon-star"
_verify_not_contains get_bookinfo_productpage "glyphicon glyphicon-star"

View File

@ -1,69 +0,0 @@
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC2154
# Copyright Istio Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/traffic-management/tcp-traffic-shifting/snips.sh"
# TODO: why is the following needed in the test if it's not a needed step in the doc?
# add the TCP port to the ingress-gateway
kubectl -n istio-system patch service istio-ingressgateway --patch "
spec:
ports:
- port: 31400
targetPort: 31400
name: tcp
"
# create a new namespace for testing purposes and enable automatic Istio sidecar injection
snip_set_up_the_test_environment_1
# start the sleep sample
snip_set_up_the_test_environment_2
# start the v1 and v2 versions of the echo service
snip_set_up_the_test_environment_3
# wait for deployments to start
_wait_for_deployment istio-io-tcp-traffic-shifting tcp-echo-v1
_wait_for_deployment istio-io-tcp-traffic-shifting tcp-echo-v2
_wait_for_deployment istio-io-tcp-traffic-shifting sleep
# export the INGRESS_ environment variables
_set_ingress_environment_variables
# Route all traffic to echo v1
snip_apply_weightbased_tcp_routing_1
_verify_lines snip_apply_weightbased_tcp_routing_2 "
+ one
- two
"
snip_apply_weightbased_tcp_routing_3
# wait for rules to propagate
sleep 5s # TODO: call proper wait utility (e.g., istioctl wait)
_verify_elided snip_apply_weightbased_tcp_routing_4 "$snip_apply_weightbased_tcp_routing_4_out"
_verify_lines snip_apply_weightbased_tcp_routing_5 "
+ one
+ two
"

View File

@ -1,95 +0,0 @@
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC2154
# Copyright Istio Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
set -u
set -o pipefail
source "${REPO_ROOT}/content/en/docs/tasks/traffic-management/traffic-shifting/snips.sh"
source "${REPO_ROOT}/tests/util/samples.sh"
kubectl label namespace default istio-injection=enabled --overwrite
startup_sleep_sample # needed for sending test requests with curl
# launch the bookinfo app
startup_bookinfo_sample
# Verification util
SLEEP_POD=$(kubectl get pod -l app=sleep -n default -o 'jsonpath={.items..metadata.name}')
INGRESS_URL="http://istio-ingressgateway.istio-system"
# reviews_v3_traffic_percentage
# gets the % of productpage requests with reviews from reviews:v3 service
function reviews_v3_traffic_percentage() {
set +e
local total_request_count=100
local v3_count=0
local v3_search_string="glyphicon glyphicon-star" # search string present in reviews_v3 response html
for ((i = 1; i <= total_request_count; i++)); do
if (kubectl exec "${SLEEP_POD}" -c sleep -n "default" -- curl -s $INGRESS_URL/productpage | grep -q "$v3_search_string"); then
v3_count=$((v3_count + 1))
fi
done
set -e
function is_in_range() {
local tol=10 #tolerance
local lower_bound=$(($2 - tol))
local upper_bound=$(($2 + tol))
if ((lower_bound < $1 && $1 < upper_bound)); then
return 0
fi
return 1
}
declare -a ranges=(0 25 50 75 100)
for i in "${ranges[@]}"; do
if is_in_range $v3_count "$i"; then
echo "$i"
fi
done
}
# Step 1 configure all traffic to v1
expected="virtualservice.networking.istio.io/productpage created
virtualservice.networking.istio.io/reviews created
virtualservice.networking.istio.io/ratings created
virtualservice.networking.istio.io/details created"
_verify_same snip_config_all_v1 "$expected"
# Step 2: verify no rating stars visible, (reviews-v3 traffic=0%)
_verify_same reviews_v3_traffic_percentage 0
# Step 3: switch 50% traffic to v3
_verify_same snip_config_50_v3 "virtualservice.networking.istio.io/reviews configured"
istioctl experimental wait --for=distribution VirtualService reviews.default
# Step 4: Confirm the rule was replaced
_verify_elided snip_verify_config_50_v3 "$snip_verify_config_50_v3_out"
# Step 5: verify rating stars visible 50% of the time
_verify_same reviews_v3_traffic_percentage 50
# Step 6: route 100% traffic to v3
snip_config_100_v3
_verify_same reviews_v3_traffic_percentage 100

View File

@ -1,43 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package trafficmanagement
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestTCPTrafficShifting(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__traffic_management__tcp_traffic_shifting").
Add(istioio.Script{
Input: istioio.Path("scripts/tcp_trafficshifting.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/traffic-management/tcp-traffic-shifting/snips.sh
source ${REPO_ROOT}/tests/util/samples.sh
snip_cleanup_1
cleanup_sleep_sample`,
},
}).
Build())
}

View File

@ -1,45 +0,0 @@
// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package trafficmanagement
import (
"testing"
"istio.io/istio/pkg/test/framework"
"istio.io/istio.io/pkg/test/istioio"
)
func TestTrafficShifting(t *testing.T) {
framework.
NewTest(t).
Run(istioio.NewBuilder("tasks__traffic_management__traffic_shifting").
Add(istioio.Script{
Input: istioio.Path("scripts/traffic_shifting.sh"),
}).
Defer(istioio.Script{
Input: istioio.Inline{
FileName: "cleanup.sh",
Value: `
set +e # ignore cleanup errors
source ${REPO_ROOT}/content/en/docs/tasks/traffic-management/traffic-shifting/snips.sh
source ${REPO_ROOT}/tests/util/samples.sh
snip_cleanup
cleanup_bookinfo_sample
cleanup_sleep_sample`,
},
}).
Build())
}