You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/07/23 04:05:00 UTC

[GitHub] [shardingsphere-elasticjob] rudy2steiner commented on a change in pull request #1040: Add dag to lite

rudy2steiner commented on a change in pull request #1040:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1040#discussion_r459203720



##########
File path: elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/dag/DagJobRegisterTest.java
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.elasticjob.lite.dag;
+
+import org.apache.commons.lang3.RandomUtils;
+import org.apache.shardingsphere.elasticjob.lite.api.JobScheduler;
+import org.apache.shardingsphere.elasticjob.lite.api.JobType;
+import org.apache.shardingsphere.elasticjob.lite.api.ShardingContext;
+import org.apache.shardingsphere.elasticjob.lite.api.simple.SimpleJob;
+import org.apache.shardingsphere.elasticjob.lite.config.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.internal.config.ConfigurationService;
+import org.apache.shardingsphere.elasticjob.lite.internal.storage.JobNodeStorage;
+import org.junit.Test;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Test dag job register.
+ **/
+public class DagJobRegisterTest extends BaseRegCenterLocal {
+
+    @Test
+    public void test4CurrentZkData() {
+        JobNodeStorage jobNodeStorage = new JobNodeStorage(zkRegCenter, "jobA");
+        String originalJobClassName = jobNodeStorage.getJobRootNodeData();
+        System.out.println(originalJobClassName);
+        System.out.println(jobNodeStorage.isJobRootNodeExisted());
+    }
+
+    @Test
+    public void test4DagRegister() throws InterruptedException {
+        JobConfiguration jobConfiguration = simpleJobConfiguration("jobA", "1/10 * * * * ?", 3, "group1", "self");
+        JobScheduler jobScheduler = new JobScheduler(zkRegCenter, new TestSimpleJob(), jobConfiguration);
+        System.out.println("==============");
+        jobScheduler.init();
+
+        System.out.println("===============");
+        JobNodeStorage jobNodeStorage = new JobNodeStorage(zkRegCenter, "jobA");
+        String jobAConfigString = jobNodeStorage.getJobNodeData("config");
+        System.out.println(jobAConfigString);
+
+        DagNodeStorage dagNodeStorage = new DagNodeStorage(zkRegCenter, "group1", "jobA");
+        Map<String, Set<String>> allDagConfigJobs = dagNodeStorage.getAllDagConfigJobs();
+        allDagConfigJobs.forEach((key, value) -> System.out.println(key + "=" + value));
+
+        TimeUnit.SECONDS.sleep(500L);

Review comment:
       Every test should assert what you want to validate or check, please reference existed unit tests 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org