2222import static org .junit .Assert .assertNull ;
2323import static org .junit .Assert .assertTrue ;
2424import static org .junit .Assert .fail ;
25+ import static org .junit .Assume .assumeFalse ;
2526
2627import com .google .api .gax .paging .Page ;
2728import com .google .cloud .dns .ChangeRequest ;
@@ -131,6 +132,9 @@ public class ITDnsTest {
131132 ChangeRequest .newBuilder ().delete (A_RECORD_ZONE1 ).delete (AAAA_RECORD_ZONE1 ).build ();
132133 private static final List <String > ZONE_NAMES =
133134 ImmutableList .of (ZONE_NAME1 , ZONE_NAME_EMPTY_DESCRIPTION );
135+ private static final boolean IS_VPC_TEST =
136+ System .getenv ("GOOGLE_CLOUD_TESTS_IN_VPCSC" ) != null
137+ && System .getenv ("GOOGLE_CLOUD_TESTS_IN_VPCSC" ).equalsIgnoreCase ("true" );
134138
135139 @ Rule public Timeout globalTimeout = Timeout .seconds (300 );
136140
@@ -211,6 +215,7 @@ private static void waitForChangeToComplete(ChangeRequest changeRequest) {
211215
212216 @ Test
213217 public void testCreateValidZone () {
218+ assumeFalse (IS_VPC_TEST );
214219 try {
215220 Zone created = DNS .create (ZONE1 );
216221 assertEquals (ZONE1 .getDescription (), created .getDescription ());
@@ -230,6 +235,7 @@ public void testCreateValidZone() {
230235
231236 @ Test
232237 public void testCreateValidZoneEmptyDescription () {
238+ assumeFalse (IS_VPC_TEST );
233239 try {
234240 Zone created = DNS .create (ZONE_EMPTY_DESCRIPTION );
235241 assertEquals (ZONE_EMPTY_DESCRIPTION .getDescription (), created .getDescription ());
@@ -271,6 +277,7 @@ public void testCreateZoneWithErrors() {
271277
272278 @ Test
273279 public void testCreateZoneWithOptions () {
280+ assumeFalse (IS_VPC_TEST );
274281 try {
275282 Zone created = DNS .create (ZONE1 , Dns .ZoneOption .fields (ZoneField .CREATION_TIME ));
276283 assertEquals (ZONE1 .getName (), created .getName ()); // always returned
@@ -372,6 +379,7 @@ public void testCreateZoneWithOptions() {
372379
373380 @ Test
374381 public void testZoneCreatedWithDnsSecConfig () {
382+ assumeFalse (IS_VPC_TEST );
375383 try {
376384 Zone created = DNS .create (ZONE_DNSSEC );
377385 assertEquals (ZONE_DNSSEC .getName (), created .getName ());
@@ -444,6 +452,7 @@ public void testNotAcceptableNonExistenceValue() {
444452
445453 @ Test
446454 public void testGetZone () {
455+ assumeFalse (IS_VPC_TEST );
447456 try {
448457 DNS .create (ZONE1 , Dns .ZoneOption .fields (ZoneField .NAME ));
449458 Zone created = DNS .getZone (ZONE1 .getName (), Dns .ZoneOption .fields (ZoneField .CREATION_TIME ));
@@ -548,6 +557,7 @@ public void testGetZone() {
548557
549558 @ Test
550559 public void testListZones () {
560+ assumeFalse (IS_VPC_TEST );
551561 try {
552562 List <Zone > zones = filter (DNS .listZones ().iterateAll ().iterator ());
553563 assertEquals (0 , zones .size ());
@@ -713,6 +723,7 @@ public void testListZones() {
713723
714724 @ Test
715725 public void testDeleteZone () {
726+ assumeFalse (IS_VPC_TEST );
716727 try {
717728 Zone created = DNS .create (ZONE1 );
718729 assertEquals (created , DNS .getZone (ZONE1 .getName ()));
@@ -725,6 +736,7 @@ public void testDeleteZone() {
725736
726737 @ Test
727738 public void testCreateChange () {
739+ assumeFalse (IS_VPC_TEST );
728740 try {
729741 DNS .create (ZONE1 , Dns .ZoneOption .fields (ZoneField .NAME ));
730742 ChangeRequest created = DNS .applyChangeRequest (ZONE1 .getName (), CHANGE_ADD_ZONE1 );
@@ -810,6 +822,7 @@ public void testCreateChange() {
810822
811823 @ Test
812824 public void testInvalidChangeRequest () {
825+ assumeFalse (IS_VPC_TEST );
813826 Zone zone = DNS .create (ZONE1 );
814827 RecordSet validA =
815828 RecordSet .newBuilder ("subdomain." + zone .getDnsName (), RecordSet .Type .A )
@@ -883,6 +896,7 @@ public void testInvalidChangeRequest() {
883896
884897 @ Test
885898 public void testListChanges () {
899+ assumeFalse (IS_VPC_TEST );
886900 try {
887901 // no such zone exists
888902 try {
@@ -1018,6 +1032,7 @@ public void testListChanges() {
10181032
10191033 @ Test
10201034 public void testGetChange () {
1035+ assumeFalse (IS_VPC_TEST );
10211036 try {
10221037 Zone zone = DNS .create (ZONE1 , Dns .ZoneOption .fields (ZoneField .NAME ));
10231038 ChangeRequest created = zone .applyChangeRequest (CHANGE_ADD_ZONE1 );
@@ -1106,6 +1121,7 @@ public void testGetProject() {
11061121
11071122 @ Test
11081123 public void testListDnsRecords () {
1124+ assumeFalse (IS_VPC_TEST );
11091125 try {
11101126 Zone zone = DNS .create (ZONE1 );
11111127 ImmutableList <RecordSet > recordSets =
@@ -1252,6 +1268,7 @@ public void testListDnsRecords() {
12521268
12531269 @ Test
12541270 public void testListZonesBatch () {
1271+ assumeFalse (IS_VPC_TEST );
12551272 try {
12561273 DnsBatch batch = DNS .batch ();
12571274 DnsBatchResult <Page <Zone >> result = batch .listZones ();
@@ -1421,6 +1438,7 @@ public void testListZonesBatch() {
14211438
14221439 @ Test
14231440 public void testCreateValidZoneBatch () {
1441+ assumeFalse (IS_VPC_TEST );
14241442 try {
14251443 DnsBatch batch = DNS .batch ();
14261444 DnsBatchResult <Zone > completeZoneResult = batch .createZone (ZONE1 );
@@ -1481,6 +1499,7 @@ public void testCreateZoneWithErrorsBatch() {
14811499
14821500 @ Test
14831501 public void testCreateZoneWithOptionsBatch () {
1502+ assumeFalse (IS_VPC_TEST );
14841503 try {
14851504 DnsBatch batch = DNS .batch ();
14861505 DnsBatchResult <Zone > batchResult =
@@ -1593,6 +1612,7 @@ public void testCreateZoneWithOptionsBatch() {
15931612
15941613 @ Test
15951614 public void testGetZoneBatch () {
1615+ assumeFalse (IS_VPC_TEST );
15961616 try {
15971617 DNS .create (ZONE1 , Dns .ZoneOption .fields (ZoneField .NAME ));
15981618 DnsBatch batch = DNS .batch ();
@@ -1691,6 +1711,7 @@ public void testGetZoneBatch() {
16911711
16921712 @ Test
16931713 public void testDeleteZoneBatch () {
1714+ assumeFalse (IS_VPC_TEST );
16941715 try {
16951716 Zone created = DNS .create (ZONE1 );
16961717 assertEquals (created , DNS .getZone (ZONE1 .getName ()));
@@ -1729,6 +1750,7 @@ public void testGetProjectBatch() {
17291750
17301751 @ Test
17311752 public void testCreateChangeBatch () {
1753+ assumeFalse (IS_VPC_TEST );
17321754 try {
17331755 DNS .create (ZONE1 , Dns .ZoneOption .fields (ZoneField .NAME ));
17341756 DnsBatch batch = DNS .batch ();
@@ -1833,6 +1855,7 @@ public void testCreateChangeBatch() {
18331855
18341856 @ Test
18351857 public void testGetChangeBatch () {
1858+ assumeFalse (IS_VPC_TEST );
18361859 try {
18371860 Zone zone = DNS .create (ZONE1 , Dns .ZoneOption .fields (ZoneField .NAME ));
18381861 ChangeRequest created = zone .applyChangeRequest (CHANGE_ADD_ZONE1 );
@@ -1916,6 +1939,7 @@ public void testGetChangeBatch() {
19161939
19171940 @ Test
19181941 public void testListChangesBatch () {
1942+ assumeFalse (IS_VPC_TEST );
19191943 try {
19201944 DnsBatch batch = DNS .batch ();
19211945 DnsBatchResult <Page <ChangeRequest >> result = batch .listChangeRequests (ZONE1 .getName ());
@@ -2045,6 +2069,7 @@ public void testListChangesBatch() {
20452069
20462070 @ Test
20472071 public void testListDnsRecordSetsBatch () {
2072+ assumeFalse (IS_VPC_TEST );
20482073 try {
20492074 Zone zone = DNS .create (ZONE1 );
20502075 DnsBatch batch = DNS .batch ();
@@ -2196,6 +2221,7 @@ public void testListDnsRecordSetsBatch() {
21962221
21972222 @ Test
21982223 public void testBatchCombined () {
2224+ assumeFalse (IS_VPC_TEST );
21992225 // only testing that the combination is possible
22002226 // the results are validated in the other test methods
22012227 try {
@@ -2229,6 +2255,7 @@ public void testBatchCombined() {
22292255
22302256 @ Test
22312257 public void testCAARecord () {
2258+ assumeFalse (IS_VPC_TEST );
22322259 try {
22332260 Zone zone = DNS .create (ZONE1 );
22342261 String caa = "0 issue \" ca.example.net\" " ;
0 commit comments