瀏覽代碼

add modify dependency version function2 (#448)

Signed-off-by: yongpengli-z <yongpeng.li@zilliz.com>
yongpengli-z 2 年之前
父節點
當前提交
bfcc316136

+ 1 - 1
tests/milvustest/pom.xml

@@ -84,7 +84,7 @@
         <dependency>
             <groupId>io.milvus</groupId>
             <artifactId>milvus-sdk-java</artifactId>
-            <version>2.2.2</version>
+            <version>2.2.3</version>
         </dependency>
         <!--Allure-->
         <dependency>

+ 11 - 0
tests/milvustest/pom.xslt

@@ -0,0 +1,11 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <xsl:output indent="yes" cdata-section-elements="address bio"/>
+    <xsl:strip-space elements="*"/>
+
+    <xsl:template match="@*|node()">
+        <xsl:copy>
+            <xsl:apply-templates select="@*|node()"/>
+        </xsl:copy>
+    </xsl:template>
+
+</xsl:stylesheet>

+ 83 - 0
tests/milvustest/src/test/java/com/zilliz/milvustest/ModifyXml.java

@@ -0,0 +1,83 @@
+package com.zilliz.milvustest;
+
+import org.w3c.dom.*;
+import org.xml.sax.SAXException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.*;
+
+/**
+ * @Author yongpeng.li
+ * @Date 2023/3/7 17:38
+ */
+public class ModifyXml {
+    private static final String FILENAME = "../../../pom.xml";
+    // xslt for pretty print only, no special task
+    private static final String FORMAT_XSLT = "../../../pom.xslt";
+    public static void main(String[] args) {
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        try (InputStream is = new FileInputStream(FILENAME)) {
+            DocumentBuilder db = dbf.newDocumentBuilder();
+            Document doc = db.parse(is);
+            NodeList dependencyList = doc.getElementsByTagName("dependency");
+           int num=0;
+            for (int i = 0; i < dependencyList.getLength(); i++) {
+                Node dependencyItem = dependencyList.item(i);
+                NodeList childNodes = dependencyItem.getChildNodes();
+                for (int j = 0; j < childNodes.getLength(); j++) {
+                    Node item = childNodes.item(j);
+                    if ("artifactId".equalsIgnoreCase(item.getNodeName())&&item.getTextContent().equalsIgnoreCase("milvus-sdk-java")) {
+                       num=i;
+                       break;
+                    }
+                }
+            }
+            NodeList childNodes = dependencyList.item(num).getChildNodes();
+            for (int i = 0; i < childNodes.getLength(); i++) {
+                 Node item = childNodes.item(i);
+                if ("version".equalsIgnoreCase(item.getNodeName())) {
+                    item.setTextContent(args[0]);
+                }
+            }
+            try (FileOutputStream output =
+                         new FileOutputStream(FILENAME)) {
+                writeXml(doc, output);
+            } catch (TransformerException e) {
+                throw new RuntimeException(e);
+            }
+
+        } catch (FileNotFoundException e) {
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } catch (ParserConfigurationException e) {
+            throw new RuntimeException(e);
+        } catch (SAXException e) {
+            throw new RuntimeException(e);
+        }
+        }
+
+
+        // write doc to output stream
+    private static void writeXml(Document doc,
+                                 OutputStream output)
+            throws TransformerException, UnsupportedEncodingException {
+        TransformerFactory transformerFactory = TransformerFactory.newInstance();
+        Transformer transformer = transformerFactory.newTransformer(
+                new StreamSource(new File(FORMAT_XSLT)));
+
+        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+        transformer.setOutputProperty(OutputKeys.STANDALONE, "no");
+        DOMSource source = new DOMSource(doc);
+        StreamResult result = new StreamResult(output);
+        transformer.transform(source, result);
+    }
+}

+ 2 - 2
tests/milvustest/src/test/java/com/zilliz/milvustest/index/CreateIndexTest.java

@@ -55,10 +55,10 @@ public class CreateIndexTest extends BaseTest {
       {IndexType.IVF_SQ8},
       {IndexType.IVF_PQ},
       {IndexType.HNSW},
-      {IndexType.ANNOY},
+/*      {IndexType.ANNOY},
       {IndexType.RHNSW_FLAT},
       {IndexType.RHNSW_PQ},
-      {IndexType.RHNSW_SQ},
+      {IndexType.RHNSW_SQ},*/
       {IndexType.DISKANN}
     };
   }

+ 2 - 2
tests/milvustest/src/test/java/com/zilliz/milvustest/index/IndexLoadTest.java

@@ -49,10 +49,10 @@ public class IndexLoadTest extends BaseTest {
                 {IndexType.IVF_SQ8},
                 {IndexType.IVF_PQ},
                 {IndexType.HNSW},
-                {IndexType.ANNOY},
+              /*  {IndexType.ANNOY},
                 {IndexType.RHNSW_FLAT},
                 {IndexType.RHNSW_PQ},
-                {IndexType.RHNSW_SQ}
+                {IndexType.RHNSW_SQ}*/
         };
     }