diff options
author | Valerij Fredriksen <valerijf@yahooinc.com> | 2023-02-24 15:25:09 +0100 |
---|---|---|
committer | Valerij Fredriksen <valerijf@yahooinc.com> | 2023-02-24 15:25:09 +0100 |
commit | 8ef195669924b488974a3cd79858f28c22c7f564 (patch) | |
tree | eb5ebdad9589b726a9c0c0daafe5f995fd8e4cb1 /node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/ArchiveApiTest.java | |
parent | 99d8d804a7e478900585fc60244b6cfbb999c3db (diff) |
Allow patching account archive URI in /nodes/v2
Diffstat (limited to 'node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/ArchiveApiTest.java')
-rw-r--r-- | node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/ArchiveApiTest.java | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/ArchiveApiTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/ArchiveApiTest.java new file mode 100644 index 00000000000..80d79b036e2 --- /dev/null +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/ArchiveApiTest.java @@ -0,0 +1,67 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.provision.restapi; + +import com.yahoo.application.container.handler.Request; +import com.yahoo.config.provision.CloudAccount; +import com.yahoo.config.provision.SystemName; +import com.yahoo.text.Utf8; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; + +/** + * Test of the REST APIs provided by the node repository. + * + * Note: This class is referenced from our operations documentation and must not be renamed/moved without updating that. + * + * @author bratseth + */ +public class ArchiveApiTest { + + private RestApiTester tester; + + @Before + public void createTester() { + tester = new RestApiTester(SystemName.Public, CloudAccount.from("111222333444")); + } + + @After + public void closeTester() { + tester.close(); + } + + @Test + public void archive_uris() throws IOException { + tester.assertPartialResponse(new Request("http://localhost:8080/nodes/v2/node/host4.yahoo.com"), "archiveUri", false); + tester.assertResponse(new Request("http://localhost:8080/nodes/v2/archive"), "{\"archives\":[]}"); + + assertResponse(new Request("http://localhost:8080/nodes/v2/archive/tenant/tenant3", Utf8.toBytes("{\"uri\": \"ftp://host/dir\"}"), Request.Method.PATCH), + "{\"message\":\"Updated archive URI for tenant3\"}"); + assertResponse(new Request("http://localhost:8080/nodes/v2/archive/tenant2", Utf8.toBytes("{\"uri\": \"s3://my-bucket/dir\"}"), Request.Method.PATCH), + "{\"message\":\"Updated archive URI for tenant2\"}"); + assertResponse(new Request("http://localhost:8080/nodes/v2/archive/account/777888999000", Utf8.toBytes("{\"uri\": \"s3://acc-bucket\"}"), Request.Method.PATCH), + "{\"message\":\"Updated archive URI for 777888999000\"}"); + + + tester.assertPartialResponse(new Request("http://localhost:8080/nodes/v2/node/host4.yahoo.com"), "\"archiveUri\":\"ftp://host/dir/application3/instance3/id3/host4/\"", true); + tester.assertPartialResponse(new Request("http://localhost:8080/nodes/v2/node/dockerhost2.yahoo.com"), "\"archiveUri\":\"s3://acc-bucket/zoneapp/zoneapp/node-admin/dockerhost2/\"", true); + assertFile(new Request("http://localhost:8080/nodes/v2/archive"), "archives.json"); + + tester.assertResponse(new Request("http://localhost:8080/nodes/v2/archive/tenant/tenant3", new byte[0], Request.Method.DELETE), "{\"message\":\"Removed archive URI for tenant3\"}"); + tester.assertPartialResponse(new Request("http://localhost:8080/nodes/v2/node/host4.yahoo.com"), "archiveUri", false); + tester.assertResponse(new Request("http://localhost:8080/nodes/v2/archive/account/777888999000", new byte[0], Request.Method.DELETE), "{\"message\":\"Removed archive URI for 777888999000\"}"); + tester.assertPartialResponse(new Request("http://localhost:8080/nodes/v2/node/dockerhost2.yahoo.com"), "archiveUri", false); + } + + + private void assertFile(Request request, String file) throws IOException { + tester.assertFile(request, file); + } + + private void assertResponse(Request request, String response) throws IOException { + tester.assertResponse(request, response); + } + +} |